From 2a0b44f12a35c675bd802e0dd8b0609ca8195a24 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Mon, 24 Jun 2024 08:28:52 +0000 Subject: [PATCH] fix(nc-gui): display audit logs in modal for user how have only base creator access --- .../nc-gui/components/dlg/ProjectAudit.vue | 5 +- .../nc-gui/components/workspace/AuditLogs.vue | 466 ++++++++++-------- packages/nc-gui/components/workspace/View.vue | 4 +- packages/nc-gui/lib/acl.ts | 1 + 4 files changed, 255 insertions(+), 221 deletions(-) diff --git a/packages/nc-gui/components/dlg/ProjectAudit.vue b/packages/nc-gui/components/dlg/ProjectAudit.vue index daea9f04e5..4e98cf9a82 100644 --- a/packages/nc-gui/components/dlg/ProjectAudit.vue +++ b/packages/nc-gui/components/dlg/ProjectAudit.vue @@ -1,5 +1,6 @@ - + Audit logs are currently disabled by administrators. - + + - Audit Logs - + + Audit Logs + : {{ bases.get(baseId)?.title }} + + - Track and monitor any changes made to any base in your workspace. + Track and monitor any changes made to any base in your workspace. - + { { Range: - + {{ auditLogsQuery.dateRange ? auditLogsQuery.dateRangeLabel : 'All Time' }} @@ -673,254 +696,261 @@ onMounted(async () => { - - - - - - - - User - + + + + + + + + + User - + - - - - Time stamp - + + + Time stamp + - + - - Base - Type - Sub-type - Description - IP - - - - - - - Loading... + Base + Type + Sub-type + Description + IP - - - - - - - - - - {{ - collaboratorsMap.get(audit.user)?.display_name || - collaboratorsMap - .get(audit.user) - ?.email?.slice(0, collaboratorsMap.get(audit.user)?.email.indexOf('@')) - }} + + + + + + + + + + + {{ + collaboratorsMap.get(audit.user)?.display_name || + collaboratorsMap + .get(audit.user) + ?.email?.slice(0, collaboratorsMap.get(audit.user)?.email.indexOf('@')) + }} + + + + {{ collaboratorsMap.get(audit.user)?.email }} - - {{ collaboratorsMap.get(audit.user)?.email }} - + {{ audit.user }} - {{ audit.user }} - - - - {{ parseStringDateTime(audit.created_at, 'D MMMM YYYY HH:mm') }} + + + {{ parseStringDateTime(audit.created_at, 'D MMMM YYYY HH:mm') }} - {{ timeAgo(audit.created_at) }} - - - - - - {{ bases.get(audit.base_id)?.title }} + {{ timeAgo(audit.created_at) }} + + + + + + {{ bases.get(audit.base_id)?.title }} + + ID: {{ audit.base_id }} - ID: {{ audit.base_id }} + + {{ audit.base_id }} + - - {{ audit.base_id }} - - - - - - {{ auditOperationTypeLabels[audit.op_type] }} + + + + {{ auditOperationTypeLabels[audit.op_type] }} - {{ auditOperationTypeLabels[audit.op_type] }} - + {{ auditOperationTypeLabels[audit.op_type] }} + + - - - - - {{ auditOperationSubTypeLabels[audit.op_sub_type] }} + + + + {{ auditOperationSubTypeLabels[audit.op_sub_type] }} - {{ auditOperationSubTypeLabels[audit.op_sub_type] }} - + {{ auditOperationSubTypeLabels[audit.op_sub_type] }} + + - - - - {{ audit.description }} + + + {{ audit.description }} + - - - - {{ audit.ip }} + + + {{ audit.ip }} + - + - - - + + + - - - - - - - - {{ totalRows }} {{ totalRows === 1 ? 'record' : 'records' }} + + + + Loading... + - - - - - - Audit Details - - Time stamp - - - {{ parseStringDateTime(selectedAudit.created_at, 'D MMMM YYYY HH:mm') }} - - {{ timeAgo(selectedAudit.created_at) }} - + + + + + + + {{ totalRows }} {{ totalRows === 1 ? 'record' : 'records' }} - - - - - Performed by - - - - - - {{ - collaboratorsMap.get(selectedAudit.user)?.display_name || - collaboratorsMap - .get(selectedAudit.user) - ?.email?.slice(0, collaboratorsMap.get(selectedAudit.user)?.email.indexOf('@')) - }} + + + + + Audit Details + + Time stamp + + + {{ parseStringDateTime(selectedAudit.created_at, 'D MMMM YYYY HH:mm') }} + + {{ timeAgo(selectedAudit.created_at) }} + + + + + + + + Performed by + + + + + + {{ + collaboratorsMap.get(selectedAudit.user)?.display_name || + collaboratorsMap + .get(selectedAudit.user) + ?.email?.slice(0, collaboratorsMap.get(selectedAudit.user)?.email.indexOf('@')) + }} + + + + {{ collaboratorsMap.get(selectedAudit.user)?.email }} - - {{ collaboratorsMap.get(selectedAudit.user)?.email }} - - - {{ selectedAudit?.user }} - - - IP Address - {{ selectedAudit?.ip }} - - - - - Base - - - - - - {{ bases.get(selectedAudit?.base_id)?.title }} - {{ selectedAudit?.base_id }} - + {{ selectedAudit?.user }} + + + IP Address + {{ selectedAudit?.ip }} - - {{ selectedAudit.base_id }} - - - - Type - - {{ auditOperationTypeLabels[selectedAudit?.op_type] }} + + + Base + + + + + + {{ bases.get(selectedAudit?.base_id)?.title }} + {{ selectedAudit?.base_id }} + + + {{ selectedAudit.base_id }} + - - Sub-type - - {{ auditOperationSubTypeLabels[selectedAudit?.op_sub_type] }} + + + Type + + {{ auditOperationTypeLabels[selectedAudit?.op_type] }} + + + + Sub-type + + {{ auditOperationSubTypeLabels[selectedAudit?.op_sub_type] }} + + + {{ $t('labels.description') }} + {{ selectedAudit?.description }} + - - {{ $t('labels.description') }} - {{ selectedAudit?.description }} - - - + + diff --git a/packages/nc-gui/components/workspace/View.vue b/packages/nc-gui/components/workspace/View.vue index c5c89e8401..c1b5b268d7 100644 --- a/packages/nc-gui/components/workspace/View.vue +++ b/packages/nc-gui/components/workspace/View.vue @@ -128,7 +128,9 @@ onMounted(() => { Audit Logs - + + + diff --git a/packages/nc-gui/lib/acl.ts b/packages/nc-gui/lib/acl.ts index 6755e87024..95c47a1e67 100644 --- a/packages/nc-gui/lib/acl.ts +++ b/packages/nc-gui/lib/acl.ts @@ -84,6 +84,7 @@ const rolePermissions = { baseRename: true, baseDuplicate: true, sourceCreate: true, + baseAuditList: true, }, }, [ProjectRoles.EDITOR]: {