Commit d164045dd0748259896662233292f16c4133f161

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

Borrado espacio.

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