From c3031ecc9e7372bf96184fe0f98c08d2dc71c625 Mon Sep 17 00:00:00 2001 From: mpuebla Date: Tue, 3 Sep 2019 11:30:19 -0300 Subject: [PATCH] Borrado componente abm imagenes y los servicios que consumia. --- src/app/app-routing.module.ts | 2 - src/app/app.module.ts | 2 - .../amb-imagenes/amb-imagenes.component.html | 104 ----------------- .../amb-imagenes/amb-imagenes.component.scss | 18 --- .../amb-imagenes/amb-imagenes.component.spec.ts | 25 ----- .../amb-imagenes/amb-imagenes.component.ts | 124 --------------------- src/app/services/producto.service.ts | 10 +- 7 files changed, 1 insertion(+), 284 deletions(-) delete mode 100644 src/app/components/amb-imagenes/amb-imagenes.component.html delete mode 100644 src/app/components/amb-imagenes/amb-imagenes.component.scss delete mode 100644 src/app/components/amb-imagenes/amb-imagenes.component.spec.ts delete mode 100644 src/app/components/amb-imagenes/amb-imagenes.component.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index ecc8ae4..f37ce3f 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -5,7 +5,6 @@ import { InicioComponent } from './components/inicio/inicio.component'; import { BusquedaProductosComponent } from './components/busqueda-productos/busqueda-productos.component'; import { ConfirmacionCarritoComponent } from './components/confirmacion-carrito/confirmacion-carrito.component'; import { MasterComponent } from './components/master/master.component'; -import { AmbImagenesComponent } from './components/amb-imagenes/amb-imagenes.component'; import { PagoComponent } from './components/pago/pago.component'; import { CancelarCompraComponent } from './components/cancelar-compra/cancelar-compra.component'; import { MensajeFinalComponent } from './components/mensaje-final/mensaje-final.component'; @@ -14,7 +13,6 @@ import { ComandaComponent } from './components/comanda/comanda.component'; const routes: Routes = [ { path: '', component: HomeComponent }, { path: 'home', component: HomeComponent }, - { path: 'abm-imagenes', component: AmbImagenesComponent }, { path: 'confirmacion-carrito', component: ConfirmacionCarritoComponent }, { path: 'pago', component: PagoComponent }, { path: 'cancelar-compra', component: CancelarCompraComponent }, diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 0183ac1..d5985cc 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -27,7 +27,6 @@ import { ConfirmacionCarritoComponent } from './components/confirmacion-carrito/ import { MasterComponent } from './components/master/master.component'; import { PopoverPromosComponent } from './components/popover-promos/popover-promos.component'; import { PopoverSinonimosComponent } from './components/popover-sinonimos/popover-sinonimos.component'; -import { AmbImagenesComponent } from './components/amb-imagenes/amb-imagenes.component'; import { PagoComponent } from './components/pago/pago.component'; import { CancelarCompraComponent } from './components/cancelar-compra/cancelar-compra.component'; import { MensajeFinalComponent } from './components/mensaje-final/mensaje-final.component'; @@ -46,7 +45,6 @@ import { ComandaComponent } from './components/comanda/comanda.component'; MasterComponent, PopoverPromosComponent, PopoverSinonimosComponent, - AmbImagenesComponent, PagoComponent, CancelarCompraComponent, MensajeFinalComponent, diff --git a/src/app/components/amb-imagenes/amb-imagenes.component.html b/src/app/components/amb-imagenes/amb-imagenes.component.html deleted file mode 100644 index f272e32..0000000 --- a/src/app/components/amb-imagenes/amb-imagenes.component.html +++ /dev/null @@ -1,104 +0,0 @@ - - -
-
-
-

Configuración de imágenes

-
-
- - - -
-
-
Productos
- - - - - - - - - - - - - - -
NombreImagen
-

{{articulo.DET_LAR}}

-

Descripción: {{articulo.DET_LAR}}

-

Sector: {{articulo.CodSec}}

-

Código: {{articulo.CodArt}}

-
- - - - - - - - - -
- - -
-
-
-
- -
-
- -
-
- -
diff --git a/src/app/components/amb-imagenes/amb-imagenes.component.scss b/src/app/components/amb-imagenes/amb-imagenes.component.scss deleted file mode 100644 index ccad32a..0000000 --- a/src/app/components/amb-imagenes/amb-imagenes.component.scss +++ /dev/null @@ -1,18 +0,0 @@ -.search .form-control-search { - position: absolute; - z-index: 2; - display: block; - text-align: center; - pointer-events: none; - color: #aaa; - line-height: inherit; -} - -.custom-file-input:lang(es) ~ .custom-file-label::after { - content: "Elegir"; -} - -.btn-delete-image { - top: 0; - left: 95%; -} diff --git a/src/app/components/amb-imagenes/amb-imagenes.component.spec.ts b/src/app/components/amb-imagenes/amb-imagenes.component.spec.ts deleted file mode 100644 index 8b67411..0000000 --- a/src/app/components/amb-imagenes/amb-imagenes.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { AmbImagenesComponent } from './amb-imagenes.component'; - -describe('AmbImagenesComponent', () => { - let component: AmbImagenesComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ AmbImagenesComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(AmbImagenesComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/components/amb-imagenes/amb-imagenes.component.ts b/src/app/components/amb-imagenes/amb-imagenes.component.ts deleted file mode 100644 index b8b4209..0000000 --- a/src/app/components/amb-imagenes/amb-imagenes.component.ts +++ /dev/null @@ -1,124 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { appSettings } from 'src/etc/AppSettings'; -import { ProductoService } from 'src/app/services/producto.service'; -import { Producto } from 'src/app/wrappers/producto'; -import { HttpClient } from '@angular/common/http'; - -@Component({ - selector: 'app-amb-imagenes', - templateUrl: './amb-imagenes.component.html', - styleUrls: ['./amb-imagenes.component.scss'] -}) - -export class AmbImagenesComponent implements OnInit { - - apiUrl = appSettings.apiImagenes; - articulos: Producto[] = []; - private auxProductos: Producto[] = []; - private searchTerm: string = ''; - private paginationData: any; - private disabledPaginador: boolean = false; - - constructor(private productoService: ProductoService, private http: HttpClient) { } - - ngOnInit() { - - this.productoService.getAllWithPaginator() - .subscribe((res) => { - - this.articulos = res.data; - this.paginationData = res.pagination; - this.filterItems(); - }, error => console.error(error)); - } - - onFileSelected(event, articulo: Producto) { - - let auxFiles: FileList = event.target.files; - Array.from(auxFiles).forEach(file => { - - this.onLoad(file) - .then(result => { - // articulo.imagenes.push({ - // name: file.name + articulo.CodArt + articulo.CodSec, - // fromGallery: true, - // imagen: result, - // id_articulo: articulo.id - // }); - let imagenAguardar = { - imagen: { - name: `${articulo.CodSec}${articulo.CodArt}${file.name}`, - base64: result, - codigo: articulo.CodArt, - sector: articulo.CodSec, - id_articulo: articulo.id - }, - articulo: articulo - }; - this.saveInBase(imagenAguardar); - }); - }) - } - - filterItems() { - - this.auxProductos = this.articulos.filter(x => { - return x.DET_LAR.toLowerCase().includes(this.searchTerm.toLowerCase()) || - x.CodArt.toString().includes(this.searchTerm.toLowerCase()) || - x.CodSec.toString().includes(this.searchTerm.toLowerCase()); - }); - } - - saveInBase(imagenAguardar) { - - this.productoService.saveInBase(imagenAguardar.imagen) - .subscribe(res => { - imagenAguardar.imagen['id'] = res[0]; - imagenAguardar.imagen['fromGallery'] = true; - imagenAguardar.articulo.imagenes.push(imagenAguardar.imagen); - }, error => console.error(error)); - } - - onLoad(file) { - - return new Promise((resolve, reject) => { - - var fr = new FileReader(); - - fr.onload = function () { - - resolve(fr.result); - }; - - fr.readAsDataURL(file); - }); - - } - - deleteImage(imagenes, index: number) { - - if (!imagenes[index].name) { - imagenes[index].name = imagenes[index].imagen; - } - - this.productoService.deleteImage(imagenes[index]) - .subscribe(res => { - - if (res) { - imagenes.splice(index, 1); - } - }, error => console.error(error)); - } - - pageChanged(event: any): void { - this.disabledPaginador = true; - this.productoService.getAllWithPaginator(event.page) - .subscribe((res) => { - this.disabledPaginador = false; - this.articulos = res.data; - this.paginationData = res.pagination; - this.filterItems(); - }, error => console.error(error)); - } - -} diff --git a/src/app/services/producto.service.ts b/src/app/services/producto.service.ts index 31c9710..ef9f3d8 100644 --- a/src/app/services/producto.service.ts +++ b/src/app/services/producto.service.ts @@ -21,7 +21,7 @@ export class ProductoService { return this.http.get(`${appSettings.apiUrl}/articulos/${id}`); } - getAll(page: number = 1): Observable { + getAll(): Observable { return this.http.get(`${appSettings.apiUrl}/articulos/`); } @@ -74,14 +74,6 @@ export class ProductoService { return this.http.get(url); } - saveInBase(body): Observable { - return this.http.post(`${appSettings.apiUrl}/imagenes/guardar`, body); - } - - deleteImage(body): Observable { - return this.http.post(`${appSettings.apiUrl}/imagen/borrar`, body); - } - getCategorias() { return this.http.get(`${appSettings.apiUrl}/categorias`); } -- 1.9.1