From 15b8e4172c3b9aca2813b79e2326b6d801744bf3 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Mon, 24 Jun 2024 08:28:51 +0000 Subject: [PATCH] feat(nc-gui): add sort audit logs support --- .../nc-gui/components/workspace/AuditLogs.vue | 89 ++++++++++++++++--- 1 file changed, 78 insertions(+), 11 deletions(-) diff --git a/packages/nc-gui/components/workspace/AuditLogs.vue b/packages/nc-gui/components/workspace/AuditLogs.vue index 7d639a8ef0..a16113d210 100644 --- a/packages/nc-gui/components/workspace/AuditLogs.vue +++ b/packages/nc-gui/components/workspace/AuditLogs.vue @@ -2,17 +2,19 @@ import { Empty } from 'ant-design-vue' import type { AuditType, WorkspaceUserType } from 'nocodb-sdk' import { - timeAgo, - AuditOperationTypes, AuditOperationSubTypes, - auditOperationTypeLabels, + AuditOperationTypes, auditOperationSubTypeLabels, + auditOperationTypeLabels, + timeAgo, } from 'nocodb-sdk' interface Props { workspaceId?: string } +const props = defineProps() + const allowedAuditOperationTypes = [AuditOperationTypes.DATA, AuditOperationTypes.TABLE, AuditOperationTypes.TABLE_COLUMN] const allowedAuditOperationSubTypes = [ @@ -23,8 +25,6 @@ const allowedAuditOperationSubTypes = [ AuditOperationSubTypes.LINK_RECORD, AuditOperationSubTypes.UNLINK_RECORD, ] -const props = defineProps() - const workspaceStore = useWorkspace() const { loadAudits: _loadAudits } = workspaceStore @@ -126,6 +126,29 @@ const handleSearchAuditLogs = useDebounceFn(() => { loadAudits() }, 500) +const toggleOrderBy = (orderBy: 'created_at' | 'user') => { + if (orderBy === 'created_at') { + auditLogsQuery.value.orderBy = { + ...auditLogsQuery.value.orderBy, + created_at: + auditLogsQuery.value.orderBy?.created_at === 'asc' + ? 'desc' + : auditLogsQuery.value.orderBy?.created_at === 'desc' + ? undefined + : 'asc', + } + } + if (orderBy === 'user') { + auditLogsQuery.value.orderBy = { + ...auditLogsQuery.value.orderBy, + user: + auditLogsQuery.value.orderBy?.user === 'asc' ? 'desc' : auditLogsQuery.value.orderBy?.user === 'desc' ? undefined : 'asc', + } + } + + loadAudits() +} + onMounted(async () => { if (audits.value === null) { await loadAudits(currentPage.value, currentLimit.value) @@ -415,8 +438,48 @@ onMounted(async () => {
-
User
-
Time stamp
+
+
+
User
+ +
+
+
+
+
Time stamp
+ +
+
Base
Type
Sub-type
@@ -438,10 +501,10 @@ onMounted(async () => { -
+
Performed by
@@ -610,11 +673,15 @@ onMounted(async () => {
Type
-
{{ selectedAudit?.op_type }}
+
+ {{ auditOperationTypeLabels[selectedAudit?.op_type] }} +
Sub-type
-
{{ selectedAudit?.op_sub_type }}
+
+ {{ auditOperationSubTypeLabels[selectedAudit?.op_sub_type] }} +