Commit c089b935a9d791f599bcc9d94876503dd8a67dfb

Authored by Marcelo Puebla
1 parent 5a80b55c4c
Exists in master

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 { appSettings } from 'src/etc/AppSettings'; 2 import { appSettings } from 'src/etc/AppSettings';
3 import { ComandaService } from 'src/app/services/comanda.service'; 3 import { ComandaService } from 'src/app/services/comanda.service';
4 import { Comanda } from 'src/app/wrappers/comanda'; 4 import { Comanda } from 'src/app/wrappers/comanda';
5 import * as _ from 'lodash'; 5 import * as _ from 'lodash';
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 ) { } 19 ) { }
20 20
21 ngOnInit() { 21 ngOnInit() {
22 22
23 this.buscar(); 23 this.buscar();
24 this.ciclo(); 24 this.ciclo();
25 } 25 }
26 26
27 ngOnDestroy() { 27 ngOnDestroy() {
28 28
29 clearTimeout(this.cicloTime); 29 clearTimeout(this.cicloTime);
30 } 30 }
31 31
32 buscar() { 32 buscar() {
33 33
34 this.comandaService.getAll() 34 this.comandaService.getAll()
35 .subscribe((res: Comanda[]) => { 35 .subscribe((res: Comanda[]) => {
36 36
37 if (!_.isEqual(res, this.comandas)) { 37 if (!_.isEqual(res, this.comandas)) {
38 38
39 this.comandas = res; 39 this.comandas = res;
40 console.log(this.comandas); 40 console.log(this.comandas);
41 } 41 }
42 }, e => console.error(e)) 42 }, e => console.error(e))
43 } 43 }
44 44
45 ciclo() { 45 ciclo() {
46 46
47 this.cicloTime = setTimeout(() => { 47 this.cicloTime = setTimeout(() => {
48 48
49 this.buscar(); 49 this.buscar();
50 this.ciclo(); 50 this.ciclo();
51 }, 5000); 51 }, 5000);
52 } 52 }
53 53
54 updateComanda(comanda: Comanda, estadoNuevo: number, observacionNueva: string) { 54 updateComanda(comanda: Comanda, estadoNuevo: number, observacionNueva: string) {
55 55
56 this.comandaService.updateComanda(comanda.id, estadoNuevo, observacionNueva) 56 this.comandaService.updateComanda(comanda.id, estadoNuevo, observacionNueva)
57 .subscribe(res => { 57 .subscribe(res => {
58 58
59 if (res.data) { 59 if (res.data) {
60 comanda.estado = estadoNuevo; 60 comanda.estado = estadoNuevo;
61 comanda.observacion = observacionNueva; 61 comanda.observacion = observacionNueva;
62 } 62 }
63 }, e => console.error(e)) 63 }, e => console.error(e))
64 } 64 }
65 65
66 } 66 }
67 67