From b1bd8993a65a22d6713f8e0d573348301c44b902 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 11 Apr 2024 08:57:34 +0100 Subject: [PATCH] Add date range picker and update backups and audit logs to use it --- .../components/common/DateRangePicker.svelte | 89 +++++++++++++++++++ .../settings/backups/index.svelte | 36 +++----- .../portal/account/auditLogs/index.svelte | 40 +++------ 3 files changed, 113 insertions(+), 52 deletions(-) create mode 100644 packages/builder/src/components/common/DateRangePicker.svelte diff --git a/packages/builder/src/components/common/DateRangePicker.svelte b/packages/builder/src/components/common/DateRangePicker.svelte new file mode 100644 index 0000000000..d7323bbdb1 --- /dev/null +++ b/packages/builder/src/components/common/DateRangePicker.svelte @@ -0,0 +1,89 @@ + + +
+ + +
+ + diff --git a/packages/builder/src/pages/builder/app/[application]/settings/backups/index.svelte b/packages/builder/src/pages/builder/app/[application]/settings/backups/index.svelte index 18d76480f4..39d61ffc31 100644 --- a/packages/builder/src/pages/builder/app/[application]/settings/backups/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/settings/backups/index.svelte @@ -1,7 +1,6 @@ @@ -208,7 +206,7 @@ View plans - {:else if !backupData?.length && !loading && !filterOpt && !startDate} + {:else if !backupData?.length && !loading && !filterOpt && !dateRange?.length}
BackupsDefault @@ -237,21 +235,9 @@ bind:value={filterOpt} />
- { - startDate = e.detail - }} - /> - { - endDate = e.detail - }} + (dateRange = e.detail)} />
diff --git a/packages/builder/src/pages/builder/portal/account/auditLogs/index.svelte b/packages/builder/src/pages/builder/portal/account/auditLogs/index.svelte index 70bcc9809c..bb829b94e4 100644 --- a/packages/builder/src/pages/builder/portal/account/auditLogs/index.svelte +++ b/packages/builder/src/pages/builder/portal/account/auditLogs/index.svelte @@ -27,6 +27,7 @@ import TimeRenderer from "./_components/TimeRenderer.svelte" import AppColumnRenderer from "./_components/AppColumnRenderer.svelte" import { cloneDeep } from "lodash" + import DateRangePicker from "components/common/DateRangePicker.svelte" import dayjs from "dayjs" const schema = { @@ -70,15 +71,13 @@ let sidePanelVisible = false let wideSidePanel = false let timer - let endDate = dayjs() - let startDate = endDate.subtract(30, "days") + let dateRange = [dayjs().subtract(30, "days"), dayjs()] $: fetchUsers(userPage, userSearchTerm) $: fetchLogs({ logsPage, logSearchTerm, - startDate, - endDate, + dateRange, selectedUsers, selectedApps, selectedEvents, @@ -136,8 +135,7 @@ const fetchLogs = async ({ logsPage, logSearchTerm, - startDate, - endDate, + dateRange, selectedUsers, selectedApps, selectedEvents, @@ -155,8 +153,8 @@ logsPageInfo.loading() await auditLogs.search({ bookmark: logsPage, - startDate: startDate ? dayjs(startDate).startOf("day") : null, - endDate: endDate ? dayjs(endDate).endOf("day") : null, + startDate: dateRange[0], + endDate: dateRange[1], fullSearch: logSearchTerm, userIds: selectedUsers, appIds: selectedApps, @@ -214,8 +212,8 @@ const downloadLogs = async () => { try { window.location = auditLogs.getDownloadUrl({ - startDate, - endDate, + startDate: dateRange[0], + endDate: dateRange[1], fullSearch: logSearchTerm, userIds: selectedUsers, appIds: selectedApps, @@ -302,21 +300,9 @@
- { - startDate = e.detail - }} - /> - { - endDate = e.detail - }} + (dateRange = e.detail)} />
@@ -506,9 +492,9 @@ min-width: 100px; display: flex; flex-direction: row; - gap: var(--spacing-l); } - .date-picker :global(> *) { + .date-picker :global(.date-range-picker), + .date-picker :global(.spectrum-Form-item) { flex: 1 1 auto; width: 0; }