Commit 85c5e3d70b5341ec4e542e3f67403f9d01d601e2
1 parent
2910dc012a
Exists in
master
and in
1 other branch
pedidos salientes
Showing
3 changed files
with
49 additions
and
5 deletions
Show diff stats
src/app/components/pedidos-salientes/pedidos-salientes.component.html
1 | -<div class="bg-primary-gradient"> | |
2 | - <div class="row"> | |
3 | - <div class="mx-auto my-5"> | |
4 | - <h1>Su pedido ya esta listo.</h1> | |
1 | +<div class="bg-primary-gradient vh-100"> | |
2 | + <div class="d-flex justify-content-center"> | |
3 | + <div class="row my-5 text-white text-center"> | |
4 | + <h1 class="col-12">Su pedido ya esta listo.</h1> | |
5 | + <h2 class="col-12 mt-3">Nº de Pedido</h2> | |
6 | + | |
7 | + <h1 *ngIf="pedidosRecientes.length" class="col-12 border rounded"> | |
8 | + {{rellenar(pedidosRecientes[0].id, 2)}} | |
9 | + </h1> | |
10 | + | |
11 | + <h2 *ngFor="let pedido of pedidosRecientes; let i = index" [hidden]="i == 0" class="col-4 border rounded mx-1"> | |
12 | + {{rellenar(pedido.id, 2)}} | |
13 | + </h2> | |
5 | 14 | </div> |
6 | 15 | </div> |
7 | 16 | </div> |
src/app/components/pedidos-salientes/pedidos-salientes.component.ts
1 | 1 | import { Component, OnInit } from '@angular/core'; |
2 | +import { ComandaService } from 'src/app/services/comanda.service'; | |
2 | 3 | |
3 | 4 | @Component({ |
4 | 5 | selector: 'app-pedidos-salientes', |
... | ... | @@ -7,9 +8,39 @@ import { Component, OnInit } from '@angular/core'; |
7 | 8 | }) |
8 | 9 | export class PedidosSalientesComponent implements OnInit { |
9 | 10 | |
10 | - constructor() { } | |
11 | + private pedidosRecientes = []; | |
12 | + private ciclo; | |
13 | + | |
14 | + constructor(private comandaService: ComandaService) { } | |
11 | 15 | |
12 | 16 | ngOnInit() { |
17 | + this.buscar(); | |
18 | + | |
19 | + this.ciclo = setTimeout(() => { | |
20 | + this.buscar(); | |
21 | + }, 5000) | |
22 | + } | |
23 | + | |
24 | + ngOnDestroy() { | |
25 | + | |
26 | + clearTimeout(this.ciclo); | |
13 | 27 | } |
14 | 28 | |
29 | + buscar() { | |
30 | + | |
31 | + this.comandaService | |
32 | + .getPendientesEntrega() | |
33 | + .subscribe((pedidos: []) => { | |
34 | + | |
35 | + this.pedidosRecientes = pedidos; | |
36 | + }, console.log); | |
37 | + } | |
38 | + | |
39 | + rellenar(relleno, longitud) { | |
40 | + relleno = '' + relleno; | |
41 | + while (relleno.length < longitud) { | |
42 | + relleno = '0' + relleno; | |
43 | + } | |
44 | + return relleno; | |
45 | + } | |
15 | 46 | } |
src/app/services/comanda.service.ts