refs #2049 enhance date filtering in task logs with max date constraint and validation
testing/ogGui-multibranch/pipeline/head There was a failure building this commit Details

pull/24/head
Lucas Lara García 2025-05-20 14:29:11 +02:00
parent c824953b1e
commit b55f15f16b
2 changed files with 22 additions and 9 deletions

View File

@ -50,8 +50,8 @@
<mat-form-field appearance="fill" class="search-date">
<mat-label>Desde</mat-label>
<input matInput [matDatepicker]="fromPicker" [(ngModel)]="filters['startDate']" (dateChange)="onDateFilterChange()"
placeholder="Fecha inicio">
<input matInput [matDatepicker]="fromPicker" [(ngModel)]="filters['startDate']"
(dateChange)="onDateFilterChange()" [max]="today">
<mat-datepicker-toggle matSuffix [for]="fromPicker"></mat-datepicker-toggle>
<mat-datepicker #fromPicker></mat-datepicker>
</mat-form-field>
@ -59,10 +59,11 @@
<mat-form-field appearance="fill" class="search-date">
<mat-label>Hasta</mat-label>
<input matInput [matDatepicker]="toPicker" [(ngModel)]="filters['endDate']" (dateChange)="onDateFilterChange()"
placeholder="Fecha fin">
[max]="today">
<mat-datepicker-toggle matSuffix [for]="toPicker"></mat-datepicker-toggle>
<mat-datepicker #toPicker></mat-datepicker>
</mat-form-field>
</div>
<app-loading [isLoading]="loading"></app-loading>

View File

@ -35,6 +35,7 @@ export class ClientTaskLogsComponent implements OnInit {
mode: ProgressBarMode = 'buffer';
progress = 0;
bufferValue = 0;
today = new Date();
filteredCommands2 = Object.keys(COMMAND_TYPES).map(key => ({
name: key,
@ -144,12 +145,15 @@ export class ClientTaskLogsComponent implements OnInit {
}
onDateFilterChange(): void {
if (this.filters['startDate'] && this.filters['endDate'] && this.filters['startDate'] > this.filters['endDate']) {
this.toastService.warning('La fecha de inicio no puede ser mayor que la fecha de fin');
return;
const start = this.filters['startDate'];
const end = this.filters['endDate'];
if (start && end && start > end) {
this.toastService.warning('La fecha de inicio no puede ser mayor que la fecha de fin');
return;
}
this.loadTraces();
}
this.loadTraces();
}
openInputModal(inputData: any): void {
this.dialog.open(InputDialogComponent, {
@ -196,9 +200,17 @@ export class ClientTaskLogsComponent implements OnInit {
'client.id': clientId,
page: this.page + 1,
itemsPerPage: this.itemsPerPage,
...this.filters
...this.filters
};
if (params['startDate']) {
params['executed_at[after]'] = this.datePipe.transform(params['startDate'], 'yyyy-MM-dd');
delete params['startDate'];
}
if (params['endDate']) {
params['executed_at[before]'] = this.datePipe.transform(params['endDate'], 'yyyy-MM-dd');
delete params['endDate'];
}
console.log('🌐 GET', `${this.baseUrl}/traces`, params);
const url = `${this.baseUrl}/traces`;