Commit 060e6b1a5943a4f30a9376c0b3cb3a5909ebb42a

Authored by Benjamin Rodriguez
1 parent b1698a5276
Exists in develop

pantalla comanda

... ... @@ -29,11 +29,13 @@
29 29 ],
30 30 "styles": [
31 31 "./node_modules/bootstrap/dist/css/bootstrap.min.css",
  32 + "node_modules/@fortawesome/fontawesome-free/css/all.min.css",
32 33 "src/styles.scss"
33 34 ],
34 35 "scripts": [
35 36 "./node_modules/jquery/dist/jquery.slim.min.js",
36 37 "./node_modules/popper.js/dist/umd/popper.min.js",
  38 + "node_modules/@fortawesome/fontawesome-free/js/all.min.js",
37 39 "./node_modules/bootstrap/dist/js/bootstrap.min.js"
38 40 ]
39 41 },
... ... @@ -8389,14 +8389,6 @@
8389 8389 "resolved": "https://registry.npmjs.org/ngx-bootstrap/-/ngx-bootstrap-5.2.0.tgz",
8390 8390 "integrity": "sha512-fh+OmaEdxCZnVLQFLqexdw4Xv0Lp2Ueq7un52gF26lTENhTAypGWgf2c92HXzbp4W/B0tnwIZ9mzQPwdDMH91w=="
8391 8391 },
8392   - "ngx-spinner": {
8393   - "version": "8.1.0",
8394   - "resolved": "https://registry.npmjs.org/ngx-spinner/-/ngx-spinner-8.1.0.tgz",
8395   - "integrity": "sha512-VtIcKsxe+cNj9zCelNesSJZ/xarjxKL86GQG9h4JM++/Hf7HUJtPDBWXZ6lBk0CpgWdJ4++XX3aeOntI92ApEw==",
8396   - "requires": {
8397   - "tslib": "^1.9.0"
8398   - }
8399   - },
8400 8392 "nice-try": {
8401 8393 "version": "1.0.5",
8402 8394 "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz",
... ... @@ -30,7 +30,6 @@
30 30 "jquery": "^3.4.1",
31 31 "js-sha256": "^0.9.0",
32 32 "ngx-bootstrap": "^5.2.0",
33   - "ngx-spinner": "^8.1.0",
34 33 "popper.js": "^1.16.0",
35 34 "rxjs": "~6.4.0",
36 35 "tslib": "^1.10.0",
src/app/app.module.ts
... ... @@ -10,7 +10,7 @@ import { SplashScreenComponent } from './modules/splash-screen/splash-screen.com
10 10 import { AdminComponent } from './modules/admin/admin.component';
11 11 import { FooterComponent } from './shared/footer/footer.component';
12 12 import { SharedModule } from './modules/shared/shared.module';
13   -import { NgxSpinnerModule } from "ngx-spinner";
  13 +import { NgxSpinnerModule } from 'ngx-spinner';
14 14  
15 15 @NgModule({
16 16 declarations: [
src/app/modules/comanda/comanda.component.html
... ... @@ -34,11 +34,11 @@
34 34 </p>
35 35 <!-- TIMER PEDIDO -->
36 36 <div class="d-flex justify-content-between align-items-center mt-2">
37   - <p><i class="fas fa-user-clock"></i></p>
  37 + <p><i class="fas fa-user-clock text-info"></i></p>
38 38 <p class="text-center mb-1">
39 39 {{comanda.hoursPedido}}:{{comanda.minutesPedido}}:{{comanda.secondsPedido}}
40 40 </p>
41   - <p><i class="far fa-clock fa-spin"></i></p>
  41 + <p><i class="far fa-clock fa-spin text-info"></i></p>
42 42 </div>
43 43 <div *ngFor="let detalle of comanda.detalles">
44 44 <p
... ... @@ -88,12 +88,36 @@
88 88 *ngIf="comanda.estado === 2"
89 89 class="btn btn-block btn-deshacer btn-sm shadow-sm p-0"
90 90 (click)="updateComanda(comanda, 1, 'Pagado')">
91   - <div class="row justify-content-center">
92   - <span class="h6"><small>Deshacer</small></span>
  91 + <div class="row justify-content-between">
  92 + <div></div>
  93 + <span class="h6 ml-4"><small>Deshacer</small></span>
  94 + <i class="fas fa-undo-alt text-info mr-4 my-auto"></i>
93 95 </div>
94   - <i class="fas fa-undo-alt"></i>
95 96 </button>
96 97 </div>
  98 + <!-- TIMER DE ELABORACION -->
  99 + <div *ngIf="comanda.estado === 2" class="d-flex justify-content-between align-items-center mt-2">
  100 + <div *ngIf="comanda.estado !== 1">
  101 + <i class="fa fa-utensils text-info" aria-hidden="true"></i>
  102 + </div>
  103 + <span *ngIf="comanda.estado === 1" class="text-dark">
  104 + {{comanda.hoursElaboracion}}:{{comanda.minutesElaboracion}}:{{comanda.secondsElaboracion}}
  105 + </span>
  106 + <span *ngIf="comanda.estado !== 1" class="text-white">
  107 + {{comanda.hoursElaboracion}}:{{comanda.minutesElaboracion}}:{{comanda.secondsElaboracion}}
  108 + </span>
  109 + <i class="fas fa-clock fa-spin text-info"></i>
  110 + <!-- <ngx-spinner
  111 + name="{{comanda.id.toString()}}"
  112 + class="mr-2"
  113 + bdOpacity="0"
  114 + bdColor="rgba(255,255,255,0)"
  115 + size="small"
  116 + color="#fff"
  117 + type="timer"
  118 + [fullScreen]="false">
  119 + </ngx-spinner> -->
  120 + </div>
97 121 </div>
98 122 </div>
99 123 </div>
src/app/modules/comanda/comanda.component.ts
... ... @@ -2,6 +2,7 @@ import { Component, OnInit } from &#39;@angular/core&#39;;
2 2 import { IComanda, IComandaDetalle, IComponente } from 'src/app/interfaces/IComanda';
3 3 import { ComandaService } from 'src/app/services/comanda/comanda.service';
4 4 import * as _ from 'lodash';
  5 +import { NgxSpinnerService } from 'ngx-spinner'
5 6  
6 7 @Component({
7 8 selector: 'app-comanda',
... ... @@ -14,16 +15,27 @@ export class ComandaComponent implements OnInit {
14 15  
15 16 constructor(
16 17 private comandaService: ComandaService,
  18 + private spinnerService: NgxSpinnerService,
17 19 ) { }
18 20  
19 21 ngOnInit() {
20 22 this.getComandas();
  23 + this.timerGetComandas();
  24 + }
  25 +
  26 + ngOnDestroy() {
  27 + clearInterval(this.cicloTime);
  28 + }
  29 +
  30 + timerGetComandas() {
  31 + this.cicloTime = setInterval(() => {
  32 + this.getComandas();
  33 + }, 5000);
21 34 }
22 35  
23 36 getComandas() {
24 37 this.comandaService.getAll()
25 38 .subscribe((resComandas: IComanda[]) => {
26   - console.log(resComandas)
27 39 this.addNewComandas(resComandas);
28 40 }, e => console.error(e));
29 41 }
... ... @@ -38,7 +50,7 @@ export class ComandaComponent implements OnInit {
38 50 }
39 51 if (!resComandas.length) return;
40 52 Array.prototype.push.apply(this.comandas, resComandas);
41   - // this.startTimersPedido(resComandas);
  53 + this.startTimersPedido(resComandas);
42 54 }
43 55  
44 56 updateComanda(comanda: IComanda, estadoNuevo: number, observacionNueva: string) {
... ... @@ -54,6 +66,7 @@ export class ComandaComponent implements OnInit {
54 66 .subscribe(res => { }, err => console.error(err)
55 67 );
56 68 }
  69 +
57 70 if (estadoNuevo !== 2) comanda.detalles.forEach(d => d.seeDetalle = false);
58 71  
59 72 this.comandaService.update(data)
... ... @@ -61,6 +74,11 @@ export class ComandaComponent implements OnInit {
61 74 if (res.data) {
62 75 comanda.estado = estadoNuevo;
63 76 comanda.observacion = observacionNueva;
  77 + if (estadoNuevo == 2) {
  78 + this.startTimerElaboracion(comanda);
  79 + } else if (comanda.timerElaboracion) {
  80 + clearInterval(comanda.timerElaboracion)
  81 + }
64 82 }
65 83 }, e => console.error(e));
66 84 }
... ... @@ -78,7 +96,23 @@ export class ComandaComponent implements OnInit {
78 96 }
79 97  
80 98 hasTipo(componentes: IComponente[]) {
81   - return componentes.some(c => c.tipoArticulo == 6);
  99 + return componentes.some(c => c.tipoArticulo === 6);
82 100 }
83 101  
  102 + //#region TIMERS
  103 + startTimersPedido(comandas) {
  104 + comandas.forEach((comanda: IComanda) => {
  105 + this.comandaService.startTimerComanda(comanda, 'Pedido');
  106 + if (comanda.estado === 2) {
  107 + this.startTimerElaboracion(comanda);
  108 + }
  109 + });
  110 + }
  111 +
  112 + startTimerElaboracion(comanda: IComanda) {
  113 + this.spinnerService.show(comanda.id.toString());
  114 + this.comandaService.startTimerComanda(comanda, 'Elaboracion');
  115 + }
  116 + //#endregion
  117 +
84 118 }
src/app/services/comanda/comanda.service.ts
1 1 import { Injectable } from '@angular/core';
2   -<<<<<<< HEAD
3   -import { HttpClient } from "@angular/common/http";
4   -import { APP_SETTINGS } from "src/etc/AppSettings";
5   -import { IComanda } from 'src/app/interfaces/IComanda';
6   -=======
7 2 import { HttpClient } from '@angular/common/http';
8 3 import { APP_SETTINGS } from 'src/etc/AppSettings';
9   ->>>>>>> ef98cd0d724050b0dfc83575636af079b59235d8
  4 +import { IComanda } from 'src/app/interfaces/IComanda';
10 5  
11 6 @Injectable({
12 7 providedIn: 'root'