diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 7fa1567..6394967 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -5,17 +5,19 @@ 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';
const routes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'home', component: HomeComponent },
+ { path: 'abm-imagenes', component: AmbImagenesComponent },
{
path: '',
component: MasterComponent,
children: [
{ path: 'inicio', component: InicioComponent },
{ path: 'busqueda-productos', component: BusquedaProductosComponent },
- { path: 'confirmacion-carrito', component: ConfirmacionCarritoComponent },
+ { path: 'confirmacion-carrito', component: ConfirmacionCarritoComponent }
]
},
{ path: '**', redirectTo: '/home', pathMatch: 'full' },
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index c24db42..1fadc63 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -19,6 +19,7 @@ import { BusquedaProductosComponent } from './components/busqueda-productos/busq
import { ConfirmacionCarritoComponent } from './components/confirmacion-carrito/confirmacion-carrito.component';
import { MasterComponent } from './components/master/master.component';
import { PopoverComponent } from './components/popover/popover.component';
+import { AmbImagenesComponent } from './components/amb-imagenes/amb-imagenes.component';
//#endregion
@NgModule({
@@ -32,7 +33,8 @@ import { PopoverComponent } from './components/popover/popover.component';
BusquedaProductosComponent,
ConfirmacionCarritoComponent,
MasterComponent,
- PopoverComponent
+ PopoverComponent,
+ AmbImagenesComponent
],
imports: [
BrowserModule,
diff --git a/src/app/components/amb-imagenes/amb-imagenes.component.html b/src/app/components/amb-imagenes/amb-imagenes.component.html
new file mode 100644
index 0000000..b3c956a
--- /dev/null
+++ b/src/app/components/amb-imagenes/amb-imagenes.component.html
@@ -0,0 +1,36 @@
+
+
+
Configuración imágenes
+
+
+
+
+
diff --git a/src/app/components/amb-imagenes/amb-imagenes.component.scss b/src/app/components/amb-imagenes/amb-imagenes.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/components/amb-imagenes/amb-imagenes.component.spec.ts b/src/app/components/amb-imagenes/amb-imagenes.component.spec.ts
new file mode 100644
index 0000000..8b67411
--- /dev/null
+++ b/src/app/components/amb-imagenes/amb-imagenes.component.spec.ts
@@ -0,0 +1,25 @@
+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
new file mode 100644
index 0000000..32b5646
--- /dev/null
+++ b/src/app/components/amb-imagenes/amb-imagenes.component.ts
@@ -0,0 +1,79 @@
+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.apiUrl;
+ articulos: Producto[] = [];
+ private auxProductos: Producto[] = [];
+ private searchTerm: string = '';
+
+ constructor(private productoService: ProductoService, private http: HttpClient) {}
+
+ ngOnInit() {
+
+ this.productoService.getAll().subscribe((productos: Producto[]) => {
+ this.articulos = productos;
+ this.filterItems();
+ });
+ }
+
+ onFileSelected(event, articulo) {
+
+ let file: File = event.target.files[0];
+
+ this.onLoad(file)
+ .then(result => {
+
+ document.getElementById(articulo.CodSec + articulo.CodArt)['src'] = result;
+
+ this.saveInBase({
+ name: file.name,
+ base64: result,
+ codigo: articulo.CodArt,
+ sector: articulo.CodSec
+ });
+ });
+ }
+
+ filterItems() {
+
+ this.auxProductos = this.articulos.filter(x => {
+ return x.DetArt.toLowerCase().includes(this.searchTerm.toLowerCase())
+ });
+ }
+
+
+ saveInBase(img) {
+
+ this.http.post(`${appSettings.apiUrl}/imagenes/guardar`, img)
+ .subscribe(data => {
+ console.log(data);
+ });
+ }
+
+ onLoad(file) {
+
+ return new Promise((resolve, reject) => {
+
+ var fr = new FileReader();
+
+ fr.onload = function() {
+
+ resolve(fr.result);
+ };
+
+ fr.readAsDataURL(file);
+ });
+
+ }
+}
diff --git a/src/app/components/confirmacion-carrito/confirmacion-carrito.component.html b/src/app/components/confirmacion-carrito/confirmacion-carrito.component.html
index f40f92b..23b64f0 100644
--- a/src/app/components/confirmacion-carrito/confirmacion-carrito.component.html
+++ b/src/app/components/confirmacion-carrito/confirmacion-carrito.component.html
@@ -21,7 +21,7 @@