Commit 0f8d7279c5fcad14c9608dbc3f22e8ae43359938

Authored by Marcelo Puebla
1 parent c089b935a9
Exists in master and in 1 other branch validar_pve

Borrado import.

src/app/components/comanda/comanda.component.ts
1 import { Component, OnInit } from '@angular/core'; 1 import { Component, OnInit } from '@angular/core';
2 import { appSettings } from 'src/etc/AppSettings';
3 import { ComandaService } from 'src/app/services/comanda.service'; 2 import { ComandaService } from 'src/app/services/comanda.service';
4 import { Comanda } from 'src/app/wrappers/comanda'; 3 import { Comanda } from 'src/app/wrappers/comanda';
5 import * as _ from 'lodash'; 4 import * as _ from 'lodash';
6 5
7 @Component({ 6 @Component({
8 selector: 'app-comanda', 7 selector: 'app-comanda',
9 templateUrl: './comanda.component.html', 8 templateUrl: './comanda.component.html',
10 styleUrls: ['./comanda.component.scss'] 9 styleUrls: ['./comanda.component.scss']
11 }) 10 })
12 export class ComandaComponent implements OnInit { 11 export class ComandaComponent implements OnInit {
13 12
14 private comandas: Comanda[] = []; 13 private comandas: Comanda[] = [];
15 private cicloTime; 14 private cicloTime;
16 15
17 constructor( 16 constructor(
18 private comandaService: ComandaService 17 private comandaService: ComandaService
19 ) { } 18 ) { }
20 19
21 ngOnInit() { 20 ngOnInit() {
22 21
23 this.buscar(); 22 this.buscar();
24 this.ciclo(); 23 this.ciclo();
25 } 24 }
26 25
27 ngOnDestroy() { 26 ngOnDestroy() {
28 27
29 clearTimeout(this.cicloTime); 28 clearTimeout(this.cicloTime);
30 } 29 }
31 30
32 buscar() { 31 buscar() {
33 32
34 this.comandaService.getAll() 33 this.comandaService.getAll()
35 .subscribe((res: Comanda[]) => { 34 .subscribe((res: Comanda[]) => {
36 35
37 if (!_.isEqual(res, this.comandas)) { 36 if (!_.isEqual(res, this.comandas)) {
38 37
39 this.comandas = res; 38 this.comandas = res;
40 console.log(this.comandas); 39 console.log(this.comandas);
41 } 40 }
42 }, e => console.error(e)) 41 }, e => console.error(e))
43 } 42 }
44 43
45 ciclo() { 44 ciclo() {
46 45
47 this.cicloTime = setTimeout(() => { 46 this.cicloTime = setTimeout(() => {
48 47
49 this.buscar(); 48 this.buscar();
50 this.ciclo(); 49 this.ciclo();
51 }, 5000); 50 }, 5000);
52 } 51 }
53 52
54 updateComanda(comanda: Comanda, estadoNuevo: number, observacionNueva: string) { 53 updateComanda(comanda: Comanda, estadoNuevo: number, observacionNueva: string) {
55 54
56 this.comandaService.updateComanda(comanda.id, estadoNuevo, observacionNueva) 55 this.comandaService.updateComanda(comanda.id, estadoNuevo, observacionNueva)
57 .subscribe(res => { 56 .subscribe(res => {
58 57
59 if (res.data) { 58 if (res.data) {
60 comanda.estado = estadoNuevo; 59 comanda.estado = estadoNuevo;
61 comanda.observacion = observacionNueva; 60 comanda.observacion = observacionNueva;
62 } 61 }
63 }, e => console.error(e)) 62 }, e => console.error(e))
64 } 63 }
65 64
66 } 65 }
67 66