Commit 8a9b7ef5c282c57e6df5790e84594cb15fb19501

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

Borrado console.log

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);
45 } 44 }
46 }, e => console.error(e)) 45 }, e => console.error(e))
47 } 46 }
48 47
49 ciclo() { 48 ciclo() {
50 49
51 this.cicloTime = setTimeout(() => { 50 this.cicloTime = setTimeout(() => {
52 51
53 this.buscar(); 52 this.buscar();
54 this.ciclo(); 53 this.ciclo();
55 }, 5000); 54 }, 5000);
56 } 55 }
57 56
58 updateComanda(comanda: Comanda, estadoNuevo: number, observacionNueva: string) { 57 updateComanda(comanda: Comanda, estadoNuevo: number, observacionNueva: string) {
59 58
60 this.comandaService.updateComanda(comanda.id, estadoNuevo, observacionNueva) 59 this.comandaService.updateComanda(comanda.id, estadoNuevo, observacionNueva)
61 .subscribe(res => { 60 .subscribe(res => {
62 61
63 if (res.data) { 62 if (res.data) {
64 comanda.estado = estadoNuevo; 63 comanda.estado = estadoNuevo;
65 comanda.observacion = observacionNueva; 64 comanda.observacion = observacionNueva;
66 } 65 }
67 }, e => console.error(e)) 66 }, e => console.error(e))
68 } 67 }
69 68
70 } 69 }
71 70