Commit cff39ffa423d1cf67378802a8ae2fb84f9d1c5fa
1 parent
0f8d7279c5
Exists in
master
and in
1 other branch
Cambiado titulo de la pestaña.
Showing
1 changed file
with
1 additions
and
0 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 { 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 | 6 | ||
6 | @Component({ | 7 | @Component({ |
7 | selector: 'app-comanda', | 8 | selector: 'app-comanda', |
8 | templateUrl: './comanda.component.html', | 9 | templateUrl: './comanda.component.html', |
9 | styleUrls: ['./comanda.component.scss'] | 10 | styleUrls: ['./comanda.component.scss'] |
10 | }) | 11 | }) |
11 | export class ComandaComponent implements OnInit { | 12 | export class ComandaComponent implements OnInit { |
12 | 13 | ||
13 | private comandas: Comanda[] = []; | 14 | private comandas: Comanda[] = []; |
14 | private cicloTime; | 15 | private cicloTime; |
15 | 16 | ||
16 | constructor( | 17 | constructor( |
17 | private comandaService: ComandaService | 18 | private comandaService: ComandaService |
18 | ) { } | 19 | ) { } |
19 | 20 | ||
20 | ngOnInit() { | 21 | ngOnInit() { |
21 | 22 | ||
22 | this.buscar(); | 23 | this.buscar(); |
23 | this.ciclo(); | 24 | this.ciclo(); |
24 | } | 25 | } |
25 | 26 | ||
26 | ngOnDestroy() { | 27 | ngOnDestroy() { |
27 | 28 | ||
28 | clearTimeout(this.cicloTime); | 29 | clearTimeout(this.cicloTime); |
29 | } | 30 | } |
30 | 31 | ||
31 | buscar() { | 32 | buscar() { |
32 | 33 | ||
33 | this.comandaService.getAll() | 34 | this.comandaService.getAll() |
34 | .subscribe((res: Comanda[]) => { | 35 | .subscribe((res: Comanda[]) => { |
35 | 36 | ||
36 | if (!_.isEqual(res, this.comandas)) { | 37 | if (!_.isEqual(res, this.comandas)) { |
37 | 38 | ||
38 | this.comandas = res; | 39 | this.comandas = res; |
39 | console.log(this.comandas); | 40 | console.log(this.comandas); |
40 | } | 41 | } |
41 | }, e => console.error(e)) | 42 | }, e => console.error(e)) |
42 | } | 43 | } |
43 | 44 | ||
44 | ciclo() { | 45 | ciclo() { |
45 | 46 | ||
46 | this.cicloTime = setTimeout(() => { | 47 | this.cicloTime = setTimeout(() => { |
47 | 48 | ||
48 | this.buscar(); | 49 | this.buscar(); |
49 | this.ciclo(); | 50 | this.ciclo(); |
50 | }, 5000); | 51 | }, 5000); |
51 | } | 52 | } |
52 | 53 | ||
53 | updateComanda(comanda: Comanda, estadoNuevo: number, observacionNueva: string) { | 54 | updateComanda(comanda: Comanda, estadoNuevo: number, observacionNueva: string) { |
54 | 55 | ||
55 | this.comandaService.updateComanda(comanda.id, estadoNuevo, observacionNueva) | 56 | this.comandaService.updateComanda(comanda.id, estadoNuevo, observacionNueva) |
56 | .subscribe(res => { | 57 | .subscribe(res => { |
57 | 58 | ||
58 | if (res.data) { | 59 | if (res.data) { |
59 | comanda.estado = estadoNuevo; | 60 | comanda.estado = estadoNuevo; |
60 | comanda.observacion = observacionNueva; | 61 | comanda.observacion = observacionNueva; |
61 | } | 62 | } |
62 | }, e => console.error(e)) | 63 | }, e => console.error(e)) |
63 | } | 64 | } |
64 | 65 | ||
65 | } | 66 | } |
66 | 67 |