Commit eac394b2dc868bb7fb66f055cba18c45d42a01b0

Authored by Marcelo Puebla
1 parent 2b7ae086c0
Exists in master

Agregado titulo.

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