From 60435ce48d70d14225e33f082d13f5f4a0698d5e Mon Sep 17 00:00:00 2001 From: Mazdak Gibran <141390141+mazdakgibran@users.noreply.github.com> Date: Thu, 29 Jan 2026 15:08:44 +0500 Subject: [PATCH] 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. --- src/app/logging/logging.component.html | 15 +++++++++++++++ src/app/logging/logging.component.ts | 16 +++++++++++++++- src/app/utils/app.constants.ts | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/app/logging/logging.component.html b/src/app/logging/logging.component.html index 5efba20..c9b5fe8 100644 --- a/src/app/logging/logging.component.html +++ b/src/app/logging/logging.component.html @@ -36,6 +36,11 @@ /> +
+ {{ 'fieldRequired' | translate }} +
+
@@ -51,6 +56,16 @@ />
+
+ {{ 'fieldRequired' | translate }} +
+
+ {{ 'toDateInvalidError' | translate }} +
diff --git a/src/app/logging/logging.component.ts b/src/app/logging/logging.component.ts index 67e2948..69b9cf1 100644 --- a/src/app/logging/logging.component.ts +++ b/src/app/logging/logging.component.ts @@ -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, ); } diff --git a/src/app/utils/app.constants.ts b/src/app/utils/app.constants.ts index b7bc250..3ed2633 100644 --- a/src/app/utils/app.constants.ts +++ b/src/app/utils/app.constants.ts @@ -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 }; }