From 060e6b1a5943a4f30a9376c0b3cb3a5909ebb42a Mon Sep 17 00:00:00 2001
From: Benjamin
Date: Tue, 14 Jan 2020 13:10:26 -0300
Subject: [PATCH] pantalla comanda
---
angular.json | 2 ++
package-lock.json | 8 ------
package.json | 1 -
src/app/app.module.ts | 2 +-
src/app/modules/comanda/comanda.component.html | 34 ++++++++++++++++++----
src/app/modules/comanda/comanda.component.ts | 40 ++++++++++++++++++++++++--
src/app/services/comanda/comanda.service.ts | 7 +----
7 files changed, 70 insertions(+), 24 deletions(-)
diff --git a/angular.json b/angular.json
index 812b3b5..3d3110a 100644
--- a/angular.json
+++ b/angular.json
@@ -29,11 +29,13 @@
],
"styles": [
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
+ "node_modules/@fortawesome/fontawesome-free/css/all.min.css",
"src/styles.scss"
],
"scripts": [
"./node_modules/jquery/dist/jquery.slim.min.js",
"./node_modules/popper.js/dist/umd/popper.min.js",
+ "node_modules/@fortawesome/fontawesome-free/js/all.min.js",
"./node_modules/bootstrap/dist/js/bootstrap.min.js"
]
},
diff --git a/package-lock.json b/package-lock.json
index 20ebb30..9044968 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8389,14 +8389,6 @@
"resolved": "https://registry.npmjs.org/ngx-bootstrap/-/ngx-bootstrap-5.2.0.tgz",
"integrity": "sha512-fh+OmaEdxCZnVLQFLqexdw4Xv0Lp2Ueq7un52gF26lTENhTAypGWgf2c92HXzbp4W/B0tnwIZ9mzQPwdDMH91w=="
},
- "ngx-spinner": {
- "version": "8.1.0",
- "resolved": "https://registry.npmjs.org/ngx-spinner/-/ngx-spinner-8.1.0.tgz",
- "integrity": "sha512-VtIcKsxe+cNj9zCelNesSJZ/xarjxKL86GQG9h4JM++/Hf7HUJtPDBWXZ6lBk0CpgWdJ4++XX3aeOntI92ApEw==",
- "requires": {
- "tslib": "^1.9.0"
- }
- },
"nice-try": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz",
diff --git a/package.json b/package.json
index e360dc8..6e309f7 100644
--- a/package.json
+++ b/package.json
@@ -30,7 +30,6 @@
"jquery": "^3.4.1",
"js-sha256": "^0.9.0",
"ngx-bootstrap": "^5.2.0",
- "ngx-spinner": "^8.1.0",
"popper.js": "^1.16.0",
"rxjs": "~6.4.0",
"tslib": "^1.10.0",
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index c15c65e..aae6b41 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -10,7 +10,7 @@ import { SplashScreenComponent } from './modules/splash-screen/splash-screen.com
import { AdminComponent } from './modules/admin/admin.component';
import { FooterComponent } from './shared/footer/footer.component';
import { SharedModule } from './modules/shared/shared.module';
-import { NgxSpinnerModule } from "ngx-spinner";
+import { NgxSpinnerModule } from 'ngx-spinner';
@NgModule({
declarations: [
diff --git a/src/app/modules/comanda/comanda.component.html b/src/app/modules/comanda/comanda.component.html
index 69e850d..0989d36 100644
--- a/src/app/modules/comanda/comanda.component.html
+++ b/src/app/modules/comanda/comanda.component.html
@@ -34,11 +34,11 @@
-
+
{{comanda.hoursPedido}}:{{comanda.minutesPedido}}:{{comanda.secondsPedido}}
-
+
-
+
+
+
+
+
+
+ {{comanda.hoursElaboracion}}:{{comanda.minutesElaboracion}}:{{comanda.secondsElaboracion}}
+
+
+ {{comanda.hoursElaboracion}}:{{comanda.minutesElaboracion}}:{{comanda.secondsElaboracion}}
+
+
+
+
diff --git a/src/app/modules/comanda/comanda.component.ts b/src/app/modules/comanda/comanda.component.ts
index 2921455..094dc2c 100644
--- a/src/app/modules/comanda/comanda.component.ts
+++ b/src/app/modules/comanda/comanda.component.ts
@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { IComanda, IComandaDetalle, IComponente } from 'src/app/interfaces/IComanda';
import { ComandaService } from 'src/app/services/comanda/comanda.service';
import * as _ from 'lodash';
+import { NgxSpinnerService } from 'ngx-spinner'
@Component({
selector: 'app-comanda',
@@ -14,16 +15,27 @@ export class ComandaComponent implements OnInit {
constructor(
private comandaService: ComandaService,
+ private spinnerService: NgxSpinnerService,
) { }
ngOnInit() {
this.getComandas();
+ this.timerGetComandas();
+ }
+
+ ngOnDestroy() {
+ clearInterval(this.cicloTime);
+ }
+
+ timerGetComandas() {
+ this.cicloTime = setInterval(() => {
+ this.getComandas();
+ }, 5000);
}
getComandas() {
this.comandaService.getAll()
.subscribe((resComandas: IComanda[]) => {
- console.log(resComandas)
this.addNewComandas(resComandas);
}, e => console.error(e));
}
@@ -38,7 +50,7 @@ export class ComandaComponent implements OnInit {
}
if (!resComandas.length) return;
Array.prototype.push.apply(this.comandas, resComandas);
- // this.startTimersPedido(resComandas);
+ this.startTimersPedido(resComandas);
}
updateComanda(comanda: IComanda, estadoNuevo: number, observacionNueva: string) {
@@ -54,6 +66,7 @@ export class ComandaComponent implements OnInit {
.subscribe(res => { }, err => console.error(err)
);
}
+
if (estadoNuevo !== 2) comanda.detalles.forEach(d => d.seeDetalle = false);
this.comandaService.update(data)
@@ -61,6 +74,11 @@ export class ComandaComponent implements OnInit {
if (res.data) {
comanda.estado = estadoNuevo;
comanda.observacion = observacionNueva;
+ if (estadoNuevo == 2) {
+ this.startTimerElaboracion(comanda);
+ } else if (comanda.timerElaboracion) {
+ clearInterval(comanda.timerElaboracion)
+ }
}
}, e => console.error(e));
}
@@ -78,7 +96,23 @@ export class ComandaComponent implements OnInit {
}
hasTipo(componentes: IComponente[]) {
- return componentes.some(c => c.tipoArticulo == 6);
+ return componentes.some(c => c.tipoArticulo === 6);
}
+ //#region TIMERS
+ startTimersPedido(comandas) {
+ comandas.forEach((comanda: IComanda) => {
+ this.comandaService.startTimerComanda(comanda, 'Pedido');
+ if (comanda.estado === 2) {
+ this.startTimerElaboracion(comanda);
+ }
+ });
+ }
+
+ startTimerElaboracion(comanda: IComanda) {
+ this.spinnerService.show(comanda.id.toString());
+ this.comandaService.startTimerComanda(comanda, 'Elaboracion');
+ }
+ //#endregion
+
}
diff --git a/src/app/services/comanda/comanda.service.ts b/src/app/services/comanda/comanda.service.ts
index 99cde36..3386a50 100644
--- a/src/app/services/comanda/comanda.service.ts
+++ b/src/app/services/comanda/comanda.service.ts
@@ -1,12 +1,7 @@
import { Injectable } from '@angular/core';
-<<<<<<< HEAD
-import { HttpClient } from "@angular/common/http";
-import { APP_SETTINGS } from "src/etc/AppSettings";
-import { IComanda } from 'src/app/interfaces/IComanda';
-=======
import { HttpClient } from '@angular/common/http';
import { APP_SETTINGS } from 'src/etc/AppSettings';
->>>>>>> ef98cd0d724050b0dfc83575636af079b59235d8
+import { IComanda } from 'src/app/interfaces/IComanda';
@Injectable({
providedIn: 'root'
--
1.9.1