From b659f93db9371853dbbe11fb6848b0bd80b33f87 Mon Sep 17 00:00:00 2001 From: wkaspryk Date: Tue, 19 Mar 2024 11:10:46 -0700 Subject: [PATCH] adding toast messages for excel export functions (#120) --- src/dashboard/src/app/client/servers/page.tsx | 8 +++++ src/dashboard/src/app/hsb/servers/page.tsx | 8 +++++ .../src/components/dashboard/Dashboard.tsx | 35 +++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/src/dashboard/src/app/client/servers/page.tsx b/src/dashboard/src/app/client/servers/page.tsx index d80c18b8..e0758529 100644 --- a/src/dashboard/src/app/client/servers/page.tsx +++ b/src/dashboard/src/app/client/servers/page.tsx @@ -78,11 +78,19 @@ export default function Page() { }} showExport onExport={async (search) => { + const toastLoading = toast.loading("Generating Excel document..."); + try { await download({ search: search ? search : undefined, }); + + toast.dismiss(toastLoading); + toast.success('Excel document has been downloaded successfully.'); + } catch (ex) { + toast.dismiss(toastLoading); + const error = ex as Error; toast.error('Failed to download data. ' + error.message); console.error(error); diff --git a/src/dashboard/src/app/hsb/servers/page.tsx b/src/dashboard/src/app/hsb/servers/page.tsx index 84e80e50..d14dea5a 100644 --- a/src/dashboard/src/app/hsb/servers/page.tsx +++ b/src/dashboard/src/app/hsb/servers/page.tsx @@ -78,11 +78,19 @@ export default function Page() { }} showExport onExport={async (search) => { + const toastLoading = toast.loading("Generating Excel document..."); + try { await download({ search: search ? search : undefined, }); + + toast.dismiss(toastLoading); + toast.success('Excel document has been downloaded successfully.'); + } catch (ex) { + toast.dismiss(toastLoading); + const error = ex as Error; toast.error('Failed to download data. ' + error.message); console.error(error); diff --git a/src/dashboard/src/components/dashboard/Dashboard.tsx b/src/dashboard/src/components/dashboard/Dashboard.tsx index 0dd481d5..eebe21be 100644 --- a/src/dashboard/src/components/dashboard/Dashboard.tsx +++ b/src/dashboard/src/components/dashboard/Dashboard.tsx @@ -205,12 +205,19 @@ export const Dashboard = () => { }} showExport onExport={async () => { + const toastLoading = toast.loading("Generating Excel document..."); + try { await download({ tenantId: dashboardTenant?.id, organizationId: dashboardOrganization?.id, }); + toast.dismiss(toastLoading); + toast.success('Excel document has been downloaded successfully.'); + } catch (ex) { + toast.dismiss(toastLoading); + const error = ex as Error; toast.error('Failed to download data. ' + error.message); console.error(error); @@ -230,11 +237,18 @@ export const Dashboard = () => { loading={!isReadyOrganizations || !isReadyServerItems} showExport onExport={async () => { + const toastLoading = toast.loading("Generating Excel document..."); + try { await download({ tenantId: dashboardTenant?.id, }); + toast.dismiss(toastLoading); + toast.success('Excel document has been downloaded successfully.'); + } catch (ex) { + toast.dismiss(toastLoading); + const error = ex as Error; toast.error('Failed to download data. ' + error.message); console.error(error); @@ -246,6 +260,8 @@ export const Dashboard = () => { large={!!dashboardOrganization || !!dashboardOperatingSystemItem || !!dashboardServerItem} showExport onExport={async (startDate, endDate) => { + const toastLoading = toast.loading("Generating Excel document..."); + try { await downloadHistory({ tenantId: dashboardTenant?.id, @@ -255,7 +271,12 @@ export const Dashboard = () => { startDate: startDate, endDate: endDate, }); + toast.dismiss(toastLoading); + toast.success('Excel document has been downloaded successfully.'); + } catch (ex) { + toast.dismiss(toastLoading); + const error = ex as Error; toast.error('Failed to download data. ' + error.message); console.error(error); @@ -344,12 +365,19 @@ export const Dashboard = () => { } }} onExport={async (search) => { + const toastLoading = toast.loading("Generating Excel document..."); + try { await download({ tenantId: dashboardTenant?.id, organizationName: search ? search : undefined, }); + toast.dismiss(toastLoading); + toast.success('Excel document has been downloaded successfully.'); + } catch (ex) { + toast.dismiss(toastLoading); + const error = ex as Error; toast.error('Failed to download data. ' + error.message); console.error(error); @@ -375,6 +403,8 @@ export const Dashboard = () => { }} showExport onExport={async (search) => { + const toastLoading = toast.loading("Generating Excel document..."); + try { await download({ tenantId: dashboardTenant?.id, @@ -382,7 +412,12 @@ export const Dashboard = () => { operatingSystemItemId: dashboardOperatingSystemItem?.id, search: search ? search : undefined, }); + toast.dismiss(toastLoading); + toast.success('Excel document has been downloaded successfully.'); + } catch (ex) { + toast.dismiss(toastLoading); + const error = ex as Error; toast.error('Failed to download data. ' + error.message); console.error(error);