Commit 2b7ae086c003261eaf509c0a733daa0c9d8d9cad
1 parent
cff39ffa42
Exists in
master
Cambiado titulo de la pestaña.
Showing
1 changed file
with
1 additions
and
0 deletions
Show diff stats
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 | 4 | ||
4 | @Component({ | 5 | @Component({ |
5 | selector: 'app-pedidos-salientes', | 6 | selector: 'app-pedidos-salientes', |
6 | templateUrl: './pedidos-salientes.component.html', | 7 | templateUrl: './pedidos-salientes.component.html', |
7 | styleUrls: ['./pedidos-salientes.component.scss'] | 8 | styleUrls: ['./pedidos-salientes.component.scss'] |
8 | }) | 9 | }) |
9 | export class PedidosSalientesComponent implements OnInit { | 10 | export class PedidosSalientesComponent implements OnInit { |
10 | 11 | ||
11 | private pedidosRecientes = []; | 12 | private pedidosRecientes = []; |
12 | private cicloTime; | 13 | private cicloTime; |
13 | 14 | ||
14 | constructor(private comandaService: ComandaService) { } | 15 | constructor(private comandaService: ComandaService) { } |
15 | 16 | ||
16 | ngOnInit() { | 17 | ngOnInit() { |
17 | 18 | ||
18 | this.buscar(); | 19 | this.buscar(); |
19 | this.ciclo(); | 20 | this.ciclo(); |
20 | } | 21 | } |
21 | 22 | ||
22 | ngOnDestroy() { | 23 | ngOnDestroy() { |
23 | 24 | ||
24 | clearTimeout(this.cicloTime); | 25 | clearTimeout(this.cicloTime); |
25 | } | 26 | } |
26 | 27 | ||
27 | ciclo() { | 28 | ciclo() { |
28 | 29 | ||
29 | this.cicloTime = setTimeout(() => { | 30 | this.cicloTime = setTimeout(() => { |
30 | 31 | ||
31 | this.buscar(); | 32 | this.buscar(); |
32 | this.ciclo(); | 33 | this.ciclo(); |
33 | }, 5000) | 34 | }, 5000) |
34 | } | 35 | } |
35 | 36 | ||
36 | buscar() { | 37 | buscar() { |
37 | this.comandaService | 38 | this.comandaService |
38 | .getPendientesEntrega() | 39 | .getPendientesEntrega() |
39 | .subscribe((pedidos: []) => { | 40 | .subscribe((pedidos: []) => { |
40 | 41 | ||
41 | this.pedidosRecientes = pedidos; | 42 | this.pedidosRecientes = pedidos; |
42 | }, console.log); | 43 | }, console.log); |
43 | } | 44 | } |
44 | 45 | ||
45 | rellenar(relleno, longitud) { | 46 | rellenar(relleno, longitud) { |
46 | relleno = '' + relleno; | 47 | relleno = '' + relleno; |
47 | while (relleno.length < longitud) { | 48 | while (relleno.length < longitud) { |
48 | relleno = '0' + relleno; | 49 | relleno = '0' + relleno; |
49 | } | 50 | } |
50 | return relleno; | 51 | return relleno; |
51 | } | 52 | } |
52 | } | 53 | } |
53 | 54 |