From 2e5470aaff517fab794e0ad61e65668c001c6bbb Mon Sep 17 00:00:00 2001 From: ACX <8075870+acx10@users.noreply.github.com> Date: Thu, 26 Feb 2026 09:40:38 -0700 Subject: [PATCH] use app-tag component with operation-based colors for audit log actions (#3029) --- .../audit-logs/audit-logs.component.html | 6 ++-- .../audit-logs/audit-logs.component.scss | 29 ---------------- .../audit-logs/audit-logs.component.ts | 33 +++++++++++++++---- 3 files changed, 30 insertions(+), 38 deletions(-) diff --git a/booklore-ui/src/app/features/settings/audit-logs/audit-logs.component.html b/booklore-ui/src/app/features/settings/audit-logs/audit-logs.component.html index 970620f1e..f344b0a13 100644 --- a/booklore-ui/src/app/features/settings/audit-logs/audit-logs.component.html +++ b/booklore-ui/src/app/features/settings/audit-logs/audit-logs.component.html @@ -78,7 +78,7 @@ {{ t('columns.timestamp') }} {{ t('columns.user') }} - {{ t('columns.action') }} + {{ t('columns.action') }} {{ t('columns.description') }} {{ t('columns.ip') }} @@ -91,9 +91,9 @@ {{ log.username }} - + {{ formatAction(log.action) }} - + ( + ACTION_COLOR_GROUPS.flatMap(([color, actions]) => actions.map(a => [a, color])) +); interface ActionOption { label: string; @@ -22,7 +40,7 @@ interface UsernameOption { @Component({ selector: 'app-audit-logs', standalone: true, - imports: [CommonModule, TableModule, Select, DatePicker, FormsModule, TranslocoDirective], + imports: [CommonModule, TableModule, Select, DatePicker, FormsModule, TranslocoDirective, TagComponent], templateUrl: './audit-logs.component.html', styleUrl: './audit-logs.component.scss' }) @@ -77,6 +95,12 @@ export class AuditLogsComponent implements OnInit, OnDestroy { {label: 'OPDS User Deleted', value: 'OPDS_USER_DELETED'}, {label: 'OPDS User Updated', value: 'OPDS_USER_UPDATED'}, {label: 'Naming Pattern Changed', value: 'NAMING_PATTERN_CHANGED'}, + {label: 'Login Rate Limited', value: 'LOGIN_RATE_LIMITED'}, + {label: 'Refresh Rate Limited', value: 'REFRESH_RATE_LIMITED'}, + {label: 'Duplicate Books Merged', value: 'DUPLICATE_BOOKS_MERGED'}, + {label: 'Book File Detached', value: 'BOOK_FILE_DETACHED'}, + {label: 'Author Metadata Updated', value: 'AUTHOR_METADATA_UPDATED'}, + {label: 'Author Deleted', value: 'AUTHOR_DELETED'}, ]; currentPage = 0; @@ -199,11 +223,8 @@ export class AuditLogsComponent implements OnInit, OnDestroy { return action.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase()).replace(/\B\w+/g, c => c.toLowerCase()); } - getActionClass(action: string): string { - if (action.includes('FAILED') || action.includes('DELETED')) return 'action-danger'; - if (action.includes('CREATED') || action.includes('SUCCESS') || action.includes('UPLOADED')) return 'action-success'; - if (action.includes('OIDC') || action.includes('PERMISSIONS')) return 'action-warning'; - return 'action-info'; + getActionColor(action: string): TagColor { + return ACTION_COLOR_MAP.get(action) ?? 'gray'; } private restoreFromQueryParams(): void {