Commit 5cb91c754535b3ff4af141792a9b2b5ded99e2b3

Authored by Marcelo Puebla

Merge branch 'master' into 'develop'

Master(benjamin)

See merge request !9
src/app/app-routing.module.ts
... ... @@ -43,6 +43,10 @@ const routes: Routes = [
43 43 path: 'mensaje-final',
44 44 loadChildren: () => import('./modules/mensaje-final/mensaje-final.module').then(m => m.MensajeFinalModule)
45 45 },
  46 + {
  47 + path: 'pedidos-salientes',
  48 + loadChildren: () => import('./modules/pedidos-salientes/pedidos-salientes.module').then(m => m.PedidosSalientesModule)
  49 + },
46 50 { path: '**', redirectTo: '', pathMatch: 'full' },
47 51 ];
48 52  
src/app/modules/pedidos-salientes/pedidos-salientes-routing.module.ts
... ... @@ -0,0 +1,14 @@
  1 +import { NgModule } from '@angular/core';
  2 +import { Routes, RouterModule } from '@angular/router';
  3 +import { PedidosSalientesComponent } from './pedidos-salientes.component';
  4 +
  5 +
  6 +const routes: Routes = [
  7 + { path: '', component: PedidosSalientesComponent }
  8 +];
  9 +
  10 +@NgModule({
  11 + imports: [RouterModule.forChild(routes)],
  12 + exports: [RouterModule]
  13 +})
  14 +export class PedidosSalientesRoutingModule { }
src/app/modules/pedidos-salientes/pedidos-salientes.component.html
... ... @@ -0,0 +1,31 @@
  1 +<div class="row justify-content-center h-15">
  2 + <div class="col-3 col-lg-2 mt-1">
  3 + <img src="../../../assets/img/logo-spot.svg" class="w-60 h-auto d-block mx-auto">
  4 + </div>
  5 +</div>
  6 +<div class="row mt-n5 justify-content-around h-75">
  7 + <div class="col-5 col-md-3 h-100">
  8 + <div class="p-3 bg-white text-center shadow-lg rounded h-100">
  9 + <h5 class="pt-3">ESTAMOS</h5>
  10 + <h3 class="font-weight-bold text-secondary">preparando</h3>
  11 + <h5>TU PEDIDO</h5>
  12 + <div
  13 + *ngFor="let pedido of pedidosPendientes; let i = index"
  14 + [hidden]="i == 0 || i > 4"
  15 + class="font-weight-bold mb-2 text-muted">
  16 + <h1 class="display-4">{{rellenar(pedido.id.toString().slice(1), 2)}}</h1>
  17 + </div>
  18 + </div>
  19 + </div>
  20 + <div class="col-5 col-md-3 h-100">
  21 + <div class="p-3 bg-white shadow-lg rounded text-center h-100">
  22 + <h5 class="pt-3">LISTO PARA</h5>
  23 + <h3 class="font-weight-bold text-primary">retirar</h3>
  24 + <div *ngIf="pedidoFinalizado.length">
  25 + <h1 class="display-1 mt-4 text-primary mb-0">{{rellenar(pedidoFinalizado[0].id.toString().slice(1), 2)}}</h1>
  26 + <hr class="line mt-0">
  27 + </div>
  28 + <h3 class="font-weight-bold text-info mt-4">¡Que lo disfrutes!</h3>
  29 + </div>
  30 + </div>
  31 +</div>
src/app/modules/pedidos-salientes/pedidos-salientes.component.scss
... ... @@ -0,0 +1,5 @@
  1 +hr.line {
  2 + height: 10px;
  3 + border-radius: 15px;
  4 + box-shadow: 0 15px 13px -16px #8b8c8c inset;
  5 +}
src/app/modules/pedidos-salientes/pedidos-salientes.component.spec.ts
... ... @@ -0,0 +1,25 @@
  1 +import { async, ComponentFixture, TestBed } from '@angular/core/testing';
  2 +
  3 +import { PedidosSalientesComponent } from './pedidos-salientes.component';
  4 +
  5 +describe('PedidosSalientesComponent', () => {
  6 + let component: PedidosSalientesComponent;
  7 + let fixture: ComponentFixture<PedidosSalientesComponent>;
  8 +
  9 + beforeEach(async(() => {
  10 + TestBed.configureTestingModule({
  11 + declarations: [ PedidosSalientesComponent ]
  12 + })
  13 + .compileComponents();
  14 + }));
  15 +
  16 + beforeEach(() => {
  17 + fixture = TestBed.createComponent(PedidosSalientesComponent);
  18 + component = fixture.componentInstance;
  19 + fixture.detectChanges();
  20 + });
  21 +
  22 + it('should create', () => {
  23 + expect(component).toBeTruthy();
  24 + });
  25 +});
src/app/modules/pedidos-salientes/pedidos-salientes.component.ts
... ... @@ -0,0 +1,58 @@
  1 +import { Component, OnInit } from '@angular/core';
  2 +import { ComandaService } from 'src/app/services/comanda/comanda.service';
  3 +
  4 +@Component({
  5 + selector: 'app-pedidos-salientes',
  6 + templateUrl: './pedidos-salientes.component.html',
  7 + styleUrls: ['./pedidos-salientes.component.scss']
  8 +})
  9 +export class PedidosSalientesComponent implements OnInit {
  10 + pedidoFinalizado = [];
  11 + cicloTime;
  12 + pedidosPendientes = [];
  13 +
  14 + constructor(
  15 + private comandaServices: ComandaService
  16 + ) { }
  17 +
  18 + ngOnInit() {
  19 + this.buscarPedidosFinalizados();
  20 + this.buscarPedidosPendientes();
  21 + this.ciclo();
  22 + }
  23 +
  24 + ngOnDestroy() {
  25 + clearTimeout(this.cicloTime);
  26 + }
  27 +
  28 + buscarPedidosFinalizados() {
  29 + this.comandaServices.getPendientesEntrega()
  30 + .subscribe((pedidos: []) => {
  31 + this.pedidoFinalizado = pedidos;
  32 + });
  33 + }
  34 +
  35 + buscarPedidosPendientes() {
  36 + this.comandaServices.getAll()
  37 + .subscribe((resComandas: []) => {
  38 + this.pedidosPendientes = resComandas;
  39 + }, e => console.error(e));
  40 + }
  41 +
  42 + ciclo() {
  43 + this.cicloTime = setTimeout(() => {
  44 + this.buscarPedidosFinalizados();
  45 + this.buscarPedidosPendientes();
  46 + this.ciclo();
  47 + }, 5000);
  48 + }
  49 +
  50 + rellenar(relleno, longitud) {
  51 + relleno = '' + relleno;
  52 + while (relleno.length < longitud) {
  53 + relleno = '0' + relleno;
  54 + }
  55 + return relleno;
  56 + }
  57 +
  58 +}
src/app/modules/pedidos-salientes/pedidos-salientes.module.ts
... ... @@ -0,0 +1,15 @@
  1 +import { NgModule } from '@angular/core';
  2 +import { CommonModule } from '@angular/common';
  3 +
  4 +import { PedidosSalientesRoutingModule } from './pedidos-salientes-routing.module';
  5 +import { PedidosSalientesComponent } from './pedidos-salientes.component';
  6 +
  7 +
  8 +@NgModule({
  9 + declarations: [PedidosSalientesComponent],
  10 + imports: [
  11 + CommonModule,
  12 + PedidosSalientesRoutingModule
  13 + ]
  14 +})
  15 +export class PedidosSalientesModule { }
src/app/services/comanda/comanda.service.spec.ts
... ... @@ -0,0 +1,12 @@
  1 +import { TestBed } from '@angular/core/testing';
  2 +
  3 +import { ComandaService } from './comanda.service';
  4 +
  5 +describe('ComandaService', () => {
  6 + beforeEach(() => TestBed.configureTestingModule({}));
  7 +
  8 + it('should be created', () => {
  9 + const service: ComandaService = TestBed.get(ComandaService);
  10 + expect(service).toBeTruthy();
  11 + });
  12 +});
src/app/services/comanda/comanda.service.ts
... ... @@ -0,0 +1,23 @@
  1 +import { Injectable } from '@angular/core';
  2 +import { HttpClient } from "@angular/common/http";
  3 +import { APP_SETTINGS } from "src/etc/AppSettings";
  4 +
  5 +@Injectable({
  6 + providedIn: 'root'
  7 +})
  8 +export class ComandaService {
  9 + urlDeboSuite = APP_SETTINGS.apiDeboSuite;
  10 +
  11 + constructor(
  12 + private http: HttpClient,
  13 + ) { }
  14 +
  15 + getPendientesEntrega() {
  16 + return this.http.get(`${this.urlDeboSuite}/comandas/pendientes-entrega`);
  17 + }
  18 +
  19 + getAll() {
  20 + return this.http.get(`${this.urlDeboSuite}/comandas`);
  21 + }
  22 +
  23 +}