Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOSTSD-315 - adding toast messages for excel export functions #120

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading