From d3109c4a1c945c837dacb36026916ca16a73bdbd 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 custom date range filter support --- .../nc-gui/components/workspace/AuditLogs.vue | 118 ++++++++++++++++-- 1 file changed, 110 insertions(+), 8 deletions(-) diff --git a/packages/nc-gui/components/workspace/AuditLogs.vue b/packages/nc-gui/components/workspace/AuditLogs.vue index a11f5fd374..b46c1b9b89 100644 --- a/packages/nc-gui/components/workspace/AuditLogs.vue +++ b/packages/nc-gui/components/workspace/AuditLogs.vue @@ -198,6 +198,46 @@ const handleUpdateDateRange = (range?: AuditLogsDateRange, label?: string) => { loadAudits() } +const isEditEnabled = computed(() => true) + +// provide the following to override the default behavior and enable input fields like in form +provide(ActiveCellInj, ref(true)) +provide(EditModeInj, readonly(isEditEnabled)) + +provide(IsFormInj, ref(true)) + +const handleCustomDateRangeClick = () => { + if (auditLogsQuery.value.dateRange === AuditLogsDateRange.Custom) { + auditLogsQuery.value.dateRange = undefined + auditLogsQuery.value.dateRangeLabel = undefined + auditDropdowns.value.dateRange = false + } else { + auditLogsQuery.value.dateRange = AuditLogsDateRange.Custom + auditLogsQuery.value.dateRangeLabel = 'Custom Date Range' + } + + auditLogsQuery.value.startDate = undefined + auditLogsQuery.value.endDate = undefined + + loadAudits() +} + +const handleUpdateCustomDateRange = (value: string | null, field: 'startDate' | 'endDate') => { + if (field === 'startDate') { + auditLogsQuery.value[field] = value || undefined + } else if (value) { + const currentTime = dayjs() + + const now = dayjs(value, 'YYYY-MM-DD').hour(currentTime.hour()).minute(currentTime.minute()) + + auditLogsQuery.value[field] = now.utc().format('YYYY-MM-DD HH:mm:ssZ') + } else { + auditLogsQuery.value[field] = undefined + } + + loadAudits() +} + onMounted(async () => { if (audits.value === null) { await loadAudits(currentPage.value, currentLimit.value) @@ -221,7 +261,7 @@ onMounted(async () => {
Track and monitor any changes made to any base in your workspace.
-
+
{
+ { + + +
+
+ + Custom Date Range +
+ +
+
+
+
+ + +
+
+ + +
+
@@ -629,7 +715,7 @@ onMounted(async () => {
-
+
@@ -694,9 +780,12 @@ onMounted(async () => {
Audit Details
Time stamp - {{ - parseStringDateTime(selectedAudit.created_at, 'D MMMM YYYY HH:mm') - }} + + + + + {{ timeAgo(selectedAudit.created_at) }} +
@@ -756,7 +845,7 @@ onMounted(async () => {
Type
-
+
{{ auditOperationTypeLabels[selectedAudit?.op_type] }}
@@ -857,5 +946,18 @@ onMounted(async () => { } :deep(.ant-menu.nc-menu) { @apply !pt-0; + &.nc-audit-date-range-menu { + @apply !pb-0; + } +} +.nc-audit-custom-date-range-input { + @apply border-1 border-gray-200 rounded-lg pr-2 py-1 transition-all duration-0.3s shadow-default focus-within:(border-brand-500 shadow-selected); + &:hover:not(:focus-within) { + @apply shadow-hover; + } + + :deep(.ant-picker-input > input) { + @apply !px-2; + } }