diff --git a/frontend/src/app/components/audit/audit-data-source.ts b/frontend/src/app/components/audit/audit-data-source.ts index 0ef494a76..da18a1804 100644 --- a/frontend/src/app/components/audit/audit-data-source.ts +++ b/frontend/src/app/components/audit/audit-data-source.ts @@ -27,6 +27,7 @@ export class AuditDataSource implements DataSource { public loading$ = this.loadingSubject.asObservable(); public paginator: MatPaginator; + public usersList: any[] = []; constructor(private _connections: ConnectionsService) {} @@ -68,15 +69,34 @@ export class AuditDataSource implements DataSource { rowReceived: 'received row', rowsReceived: 'received rows' } + const statuses = { + successfully: 'successfully', + unsuccessfully: 'failed', + unknown: 'unknown' + } const formattedLogs = res.logs.map(log => { const date = new Date(log.createdAt); - const formattedDate = format(date, "P p") + const formattedDateOnly = format(date, "d MMM yyyy") + const formattedTimeOnly = format(date, "h:mm a") + const user = this.usersList.find(u => u.email === log.email); + const isViewAction = log.operationType === 'rowReceived' || log.operationType === 'rowsReceived'; + const isEditAction = log.operationType === 'updateRow'; + const isDeleteAction = log.operationType === 'deleteRow'; + const isAddAction = log.operationType === 'addRow'; return { ['Table']: log.table_name, ['User']: log.email, + ['UserName']: user?.name || null, + ['UserEmail']: log.email, ['Action']: actions[log.operationType], - ['Date']: formattedDate, - ['Status']: log.operationStatusResult, + ['IsViewAction']: isViewAction, + ['IsEditAction']: isEditAction, + ['IsDeleteAction']: isDeleteAction, + ['IsAddAction']: isAddAction, + ['Date']: formattedDateOnly, + ['DateOnly']: formattedDateOnly, + ['TimeOnly']: formattedTimeOnly, + ['Status']: statuses[log.operationStatusResult] || log.operationStatusResult, operationType: log.operationType, createdAt: log.createdAt, prevValue: log.old_data, diff --git a/frontend/src/app/components/audit/audit.component.css b/frontend/src/app/components/audit/audit.component.css index 4e5bf39de..a28ce70c7 100644 --- a/frontend/src/app/components/audit/audit.component.css +++ b/frontend/src/app/components/audit/audit.component.css @@ -110,4 +110,62 @@ th.mat-header-cell, td.mat-cell { .hidden { display: none; +} + +.status-badge { + display: inline-block; + padding: 4px 12px; + border-radius: 4px; +} + +.status-succeed { + background-color: #EBF9EB; + color: #1A5E20; +} + +.status-failed { + background-color: #FDDBD2; +} + +.user-info { + display: flex; + flex-direction: column; + gap: 2px; +} + +.user-name { + font-size: 14px; + font-weight: 500; + line-height: 1.2; +} + +.user-email { + font-size: 12px; + color: rgba(0, 0, 0, 0.6); + line-height: 1.2; +} + +@media (prefers-color-scheme: dark) { + .user-email { + color: rgba(255, 255, 255, 0.6); + } +} + +.action-with-icon { + display: flex; + align-items: center; + gap: 6px; +} + +.action-icon { + font-size: 16px; + width: 16px; + height: 16px; + color: rgba(0, 0, 0, 0.5); +} + +@media (prefers-color-scheme: dark) { + .action-icon { + color: rgba(255, 255, 255, 0.5); + } } \ No newline at end of file diff --git a/frontend/src/app/components/audit/audit.component.html b/frontend/src/app/components/audit/audit.component.html index 37b4601e2..f70e3907f 100644 --- a/frontend/src/app/components/audit/audit.component.html +++ b/frontend/src/app/components/audit/audit.component.html @@ -73,13 +73,43 @@

Rocketadmin can not find any tables

{{ column }}
- {{element[column] || '—'}} + + {{element[column]}} + + + +
+ visibility + {{element[column]}} +
+
+ add + {{element[column]}} +
+
+ create + {{element[column]}} +
+
+ delete + {{element[column]}} +
+ + {{element[column] || '—'}} +
- - Details + + Changes