Commit 82b65698787b08faf13ae8fbfc48729fa2f87cc1
1 parent
74fceda6d6
Exists in
master
Borrada variable.
Showing
1 changed file
with
7 additions
and
7 deletions
Show diff stats
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 apiImagenes = appSettings.apiImagenes; | ||
15 | private comandas: Comanda[] = []; | 14 | private comandas: Comanda[] = []; |
16 | private cicloTime; | 15 | private cicloTime; |
17 | 16 | ||
18 | constructor( | 17 | constructor( |
19 | private comandaService: ComandaService | 18 | private comandaService: ComandaService |
20 | ) { } | 19 | ) { } |
21 | 20 | ||
22 | ngOnInit() { | 21 | ngOnInit() { |
23 | 22 | ||
24 | this.buscar(); | 23 | this.buscar(); |
25 | this.ciclo(); | 24 | this.ciclo(); |
26 | |||
27 | } | 25 | } |
28 | 26 | ||
29 | ngOnDestroy() { | 27 | ngOnDestroy() { |
30 | 28 | ||
31 | clearTimeout(this.cicloTime); | 29 | clearTimeout(this.cicloTime); |
32 | } | 30 | } |
33 | 31 | ||
34 | buscar() { | 32 | buscar() { |
35 | 33 | ||
36 | this.comandaService.getAll() | 34 | this.comandaService.getAll() |
37 | .subscribe((res: Comanda[]) => { | 35 | .subscribe((res: Comanda[]) => { |
38 | 36 | ||
39 | if (!_.isEqual(res, this.comandas)) { | 37 | if (!_.isEqual(res, this.comandas)) { |
40 | 38 | ||
41 | this.comandas = res; | 39 | this.comandas = res; |
42 | } | 40 | console.log(this.comandas); |
43 | }, e => console.error(e)) | 41 | } |
42 | }, e => console.error(e)) | ||
44 | } | 43 | } |
45 | 44 | ||
46 | ciclo() { | 45 | ciclo() { |
47 | 46 | ||
48 | this.cicloTime = setTimeout(() => { | 47 | this.cicloTime = setTimeout(() => { |
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 |