Skip to content

Commit

Permalink
adding toast messages for excel export functions (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
wkaspryk authored Mar 19, 2024
1 parent b2d44fb commit b659f93
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/dashboard/src/app/client/servers/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions src/dashboard/src/app/hsb/servers/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
35 changes: 35 additions & 0 deletions src/dashboard/src/components/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -375,14 +403,21 @@ export const Dashboard = () => {
}}
showExport
onExport={async (search) => {
const toastLoading = toast.loading("Generating Excel document...");

try {
await download({
tenantId: dashboardTenant?.id,
organizationId: dashboardOrganization?.id,
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);
Expand Down

0 comments on commit b659f93

Please sign in to comment.