Skip to content

Commit

Permalink
feat(HUDS): Agregar filtro de descargas pendientes
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-bravo authored and silviroa committed Dec 29, 2022
1 parent 49edc3e commit 90ad966
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
</plex-layout-sidebar>
<plex-layout-sidebar *ngIf="descargasPendientes" type="invert">
<descargas-pendientes>
<plex-button justify="end" icon="close" type="danger" tooltip="Cerrar" (click)="mostrarPendientes()">
<plex-button justify="end" icon="close" type="danger" tooltip="Cerrar" (click)="mostrarPendientes()" size="sm">
</plex-button>
</descargas-pendientes>
</plex-layout-sidebar>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
<plex-title titulo="Descargas pendientes">
<plex-button tooltip="Actualizar" type="success">
<plex-icon prefix="adi" name="reload" (click)="descargasPendientes()"></plex-icon>
<plex-title titulo="Descargas pendientes" size="sm">
<plex-button tooltip="Actualizar" type="success" size="sm">
<plex-icon prefix="adi" name="reload" (click)="descargasPendientes()" size="sm"></plex-icon>
</plex-button>
<ng-content></ng-content>
</plex-title>
<plex-wrapper>
<plex-datetime type="date" [(ngModel)]="fechaDesde" (change)="descargasPendientes()" name="fechaDesde"
label="Desde" class="fechas" [max]="fechaHasta" size="sm">
</plex-datetime>
<plex-datetime type="date" [(ngModel)]="fechaHasta" (change)="descargasPendientes()" name="fechaHasta"
label="Hasta" class="fechas" [min]="fechaDesde" size="sm">
</plex-datetime>
</plex-wrapper>
<plex-table *ngIf="!sinPendientes; else noPendientes">
<tr *ngFor="let pendiente of completed">
<td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@ export class DescargasPendientesComponent implements OnInit {
public pending = [];
public sinPendientes = false;
public busqueda$: Observable<any[]>;
public fechaDesde;
public fechaHasta;


constructor(
private exportHudsService: ExportHudsService,
private auth: Auth
) { }
) {
this.fechaDesde = moment().startOf('day').toDate();
this.fechaHasta = moment().endOf('day').toDate();
exportHudsService.$refrescarPendientes.subscribe(() => {
this.descargasPendientes();
});
}

ngOnInit(): void {
this.descargasPendientes();
Expand All @@ -39,7 +47,14 @@ export class DescargasPendientesComponent implements OnInit {
}

descargasPendientes() {
this.exportHudsService.pendientes({ id: this.auth.usuario.id }).subscribe((data) => {
const query: any = { id: this.auth.usuario.id };
if (this.fechaDesde) {
query.fechaDesde = moment(this.fechaDesde).startOf('day').toDate();
}
if (this.fechaHasta) {
query.fechaHasta = moment(this.fechaHasta).endOf('day').toDate();
}
this.exportHudsService.pendientes(query).subscribe((data) => {
this.exportHudsService.hud$.next(data);
});
this.busqueda$ = this.exportHudsService.pendiente$;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ export class ExportarHudsComponent implements OnInit {
}

descargasPendientes() {
this.exportHudsService.pendientes({ id: this.auth.usuario.id }).subscribe((data) => {
this.exportHudsService.hud$.next(data);
});
this.exportHudsService.refrescarPendientes();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Observable, BehaviorSubject, Subject } from 'rxjs';
import { Injectable } from '@angular/core';
import { EventEmitter, Injectable } from '@angular/core';
import { Server, saveAs } from '@andes/shared';

@Injectable()
Expand All @@ -9,10 +9,17 @@ export class ExportHudsService {
public pendiente$: Observable<any[]>;
public hud$ = new Subject<any[]>();

$refrescarPendientes = new EventEmitter();

constructor(private server: Server) {
this.pendiente$ = this.hud$;
}


refrescarPendientes() {
this.$refrescarPendientes.emit();
}

pendientes(params) {
return this.server.get(this.exportHudsUrl, { params });
}
Expand Down

0 comments on commit 90ad966

Please sign in to comment.