Commit bca2afcd49264b4b7e701d8136277732659ff6c0
1 parent
b5902203d3
Exists in
develop
Agregada publicidades
Showing
6 changed files
with
92 additions
and
28 deletions
Show diff stats
src/app/interfaces/IPublicidad.ts
... | ... | @@ -0,0 +1,29 @@ |
1 | +export interface IPublicidad { | |
2 | + imagen?: string; | |
3 | + relaciona_producto?: boolean; | |
4 | + CodSec?: number; | |
5 | + CodArt?: number; | |
6 | + DET_LAR?: string; | |
7 | + id?: number; | |
8 | + base64?: any; | |
9 | +} | |
10 | + | |
11 | +export class Publicidad { | |
12 | + imagen?: string; | |
13 | + relaciona_producto?: boolean; | |
14 | + CodSec?: number; | |
15 | + CodArt?: number; | |
16 | + DET_LAR?: string; | |
17 | + id?: number; | |
18 | + base64?: any; | |
19 | + | |
20 | + constructor(publicidad?: Partial<Publicidad>) { | |
21 | + if (publicidad) { | |
22 | + Object.assign(this, publicidad); | |
23 | + return; | |
24 | + } | |
25 | + this.imagen = ''; | |
26 | + this.DET_LAR = ''; | |
27 | + this.relaciona_producto = false; | |
28 | + } | |
29 | +} |
src/app/modules/seleccion-articulos/seleccion-articulos.component.ts
... | ... | @@ -34,7 +34,7 @@ export class SeleccionArticulosComponent implements OnInit { |
34 | 34 | public articuloService: ArticuloService, |
35 | 35 | private categoriaService: CategoriaService, |
36 | 36 | private modalService: BsModalService, |
37 | - private promocionService: PromocionService | |
37 | + private promocionService: PromocionService, | |
38 | 38 | ) { } |
39 | 39 | |
40 | 40 | ngOnInit() { |
src/app/services/publicidad/publicidad.service.spec.ts
... | ... | @@ -0,0 +1,12 @@ |
1 | +import { TestBed } from '@angular/core/testing'; | |
2 | + | |
3 | +import { PublicidadService } from './publicidad.service'; | |
4 | + | |
5 | +describe('PublicidadService', () => { | |
6 | + beforeEach(() => TestBed.configureTestingModule({})); | |
7 | + | |
8 | + it('should be created', () => { | |
9 | + const service: PublicidadService = TestBed.get(PublicidadService); | |
10 | + expect(service).toBeTruthy(); | |
11 | + }); | |
12 | +}); |
src/app/services/publicidad/publicidad.service.ts
... | ... | @@ -0,0 +1,34 @@ |
1 | +import { Injectable } from '@angular/core'; | |
2 | +import { HttpClient } from '@angular/common/http'; | |
3 | +import { APP_SETTINGS } from 'src/etc/AppSettings'; | |
4 | +import { IPublicidad } from 'src/wrappers/publicidad'; | |
5 | + | |
6 | +@Injectable({ | |
7 | + providedIn: 'root' | |
8 | +}) | |
9 | +export class PublicidadService { | |
10 | + urlDeboSuite = APP_SETTINGS.apiDeboSuite; | |
11 | + imagenes: any[] = []; | |
12 | + | |
13 | + constructor( | |
14 | + private http: HttpClient, | |
15 | + ) { } | |
16 | + | |
17 | + getAll() { | |
18 | + return this.http.get(`${this.urlDeboSuite}/publicidad`); | |
19 | + } | |
20 | + | |
21 | + update(publicidad: IPublicidad) { | |
22 | + delete publicidad.DET_LAR; | |
23 | + return this.http.put(`${this.urlDeboSuite}/publicidad`, publicidad); | |
24 | + } | |
25 | + | |
26 | + create(publicidad: IPublicidad) { | |
27 | + delete publicidad.DET_LAR; | |
28 | + return this.http.post(`${this.urlDeboSuite}/publicidad`, publicidad); | |
29 | + } | |
30 | + | |
31 | + delete(id: any) { | |
32 | + return this.http.delete(`${this.urlDeboSuite}/publicidad/${id}`); | |
33 | + } | |
34 | +} | |
0 | 35 | \ No newline at end of file |
src/app/shared/header-publicidad/header-publicidad.component.html
... | ... | @@ -2,37 +2,13 @@ |
2 | 2 | <div class="col-12 p-3 h-100"> |
3 | 3 | <div class="h-100"> |
4 | 4 | <carousel [showIndicators]="false" [interval]="4000"> |
5 | - <slide> | |
5 | + <slide *ngFor="let p of publicidades"> | |
6 | 6 | <img |
7 | 7 | class="d-block h-100 w-auto mx-auto" |
8 | 8 | draggable="false" |
9 | 9 | ondragstart="return false;" |
10 | 10 | (contextmenu)="false" |
11 | - src="{{urlImagenes}}spot-promos-combos-02.png"> | |
12 | - </slide> | |
13 | - <slide> | |
14 | - <img | |
15 | - class="d-block h-100 w-auto mx-auto" | |
16 | - draggable="false" | |
17 | - ondragstart="return false;" | |
18 | - (contextmenu)="false" | |
19 | - src="{{urlImagenes}}spot-promos-combos-03.png"> | |
20 | - </slide> | |
21 | - <slide> | |
22 | - <img | |
23 | - class="d-block h-100 w-auto mx-auto" | |
24 | - draggable="false" | |
25 | - ondragstart="return false;" | |
26 | - (contextmenu)="false" | |
27 | - src="{{urlImagenes}}spot-promos-combos-04.png"> | |
28 | - </slide> | |
29 | - <slide> | |
30 | - <img | |
31 | - class="d-block h-100 w-auto mx-auto" | |
32 | - draggable="false" | |
33 | - ondragstart="return false;" | |
34 | - (contextmenu)="false" | |
35 | - src="{{urlImagenes}}spot-promos-combos-05.png"> | |
11 | + src="{{urlImagenes}}{{p.imagen}}"> | |
36 | 12 | </slide> |
37 | 13 | </carousel> |
38 | 14 | </div> |
src/app/shared/header-publicidad/header-publicidad.component.ts
1 | 1 | import { Component, OnInit } from '@angular/core'; |
2 | 2 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
3 | +import { IPublicidad } from 'src/app/interfaces/IPublicidad'; | |
4 | +import { PublicidadService } from 'src/app/services/publicidad/publicidad.service'; | |
3 | 5 | |
4 | 6 | @Component({ |
5 | 7 | selector: 'app-header-publicidad', |
... | ... | @@ -8,10 +10,21 @@ import { APP_SETTINGS } from 'src/etc/AppSettings'; |
8 | 10 | }) |
9 | 11 | export class HeaderPublicidadComponent implements OnInit { |
10 | 12 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; |
13 | + publicidades: IPublicidad[] = []; | |
11 | 14 | |
12 | - constructor() { } | |
15 | + constructor( | |
16 | + private publicidadService: PublicidadService, | |
17 | + ) { } | |
13 | 18 | |
14 | 19 | ngOnInit() { |
20 | + this.getPublicidades(); | |
21 | + } | |
22 | + | |
23 | + getPublicidades() { | |
24 | + this.publicidadService.getAll() | |
25 | + .subscribe((res: IPublicidad[]) => { | |
26 | + this.publicidades = res; | |
27 | + }, err => console.error(err)); | |
15 | 28 | } |
16 | 29 | |
17 | 30 | } |