Improve log form validation and mask passwords in export

Added validation error messages for required date fields and invalid date ranges in the logging search form. Updated the export to Excel functionality to mask passwords in request bodies. Adjusted date validator to only flag errors when fromDate is strictly after toDate.
mazdak/UX-2366
Mazdak Gibran 6 days ago
parent 91ed9032d5
commit 60435ce48d

@ -36,6 +36,11 @@
/>
<i class="fas fa-calendar calendar-icon"></i>
</div>
<div class="text-danger"
*ngIf="logsSearchForm.get('fromDate')?.touched && logsSearchForm.get('fromDate')?.invalid">
{{ 'fieldRequired' | translate }}
</div>
</div>
<div class="col-md-6">
@ -51,6 +56,16 @@
/>
<i class="fas fa-calendar calendar-icon"></i>
</div>
<div class="text-danger"
*ngIf="logsSearchForm.get('toDate')?.touched && logsSearchForm.get('toDate')?.invalid">
{{ 'fieldRequired' | translate }}
</div>
<div class="text-danger" *ngIf="
logsSearchForm.touched &&
logsSearchForm.errors?.['fromDateGreaterThanOrEqualToToDate']
">
{{ 'toDateInvalidError' | translate }}
</div>
</div>
</div>

@ -162,8 +162,22 @@ export class LoggingComponent implements OnInit {
}
exportDataInExcel(): void {
const sanitizedData = this.filteredItems.map(item => {
if (item.requestBody) {
try {
const body = JSON.parse(item.requestBody);
if (body.password) {
body.password = '******';
}
return { ...item, requestBody: JSON.stringify(body) };
} catch {
return item;
}
}
return item;
});
this.excelExportService.exportExcel(
this.filteredItems,
sanitizedData,
LOGGING_DETAILS_FILE_NAME,
);
}

@ -30,7 +30,7 @@ export const toDateAfterFromDateValidator: ValidatorFn = (
today.setHours(0, 0, 0, 0);
// Rule 1: fromDate must be < toDate
if (fromDate >= toDate) {
if (fromDate > toDate) {
return { fromDateGreaterThanOrEqualToToDate: true };
}

Loading…
Cancel
Save