diff --git a/src/app/components/amb-imagenes/amb-imagenes.component.ts b/src/app/components/amb-imagenes/amb-imagenes.component.ts index fcaa6ea..49a418d 100644 --- a/src/app/components/amb-imagenes/amb-imagenes.component.ts +++ b/src/app/components/amb-imagenes/amb-imagenes.component.ts @@ -16,18 +16,17 @@ export class AmbImagenesComponent implements OnInit { articulos: Producto[] = []; private auxProductos: Producto[] = []; private searchTerm: string = ''; + private paginationData: any; constructor(private productoService: ProductoService, private http: HttpClient) { } ngOnInit() { - this.productoService.getAll().subscribe((productos: Producto[]) => { - this.articulos = productos; - this.filterItems(); - }); - } + this.productoService.getAllWithPaginator() + .subscribe((res) => { - this.articulos = productos; + this.articulos = res.data; + this.paginationData = res.pagination; this.filterItems(); }, error => console.error(error)); } @@ -60,7 +59,9 @@ export class AmbImagenesComponent implements OnInit { filterItems() { this.auxProductos = this.articulos.filter(x => { - return x.DET_LAR.toLowerCase().includes(this.searchTerm.toLowerCase()) + return x.DET_LAR.toLowerCase().includes(this.searchTerm.toLowerCase()) || + x.CodArt.toString().includes(this.searchTerm.toLowerCase()) || + x.CodSec.toString().includes(this.searchTerm.toLowerCase()); }); } @@ -104,4 +105,14 @@ export class AmbImagenesComponent implements OnInit { }, error => console.error(error)); } + pageChanged(event: any): void { + this.productoService.getAllWithPaginator(event.page) + .subscribe((res) => { + + this.articulos = res.data; + this.paginationData = res.pagination; + this.filterItems(); + }, error => console.error(error)); + } + }