Formatting was done.
This commit is contained in:
1 parent
e9e509ab04
commit
11212c7371
3 files changed
+31
-31
No files matched your search
@@ -9,7 +9,7 @@ const CreateMonitorHeader = ({ isAdmin, label, isLoading = true, path, bulkPath
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const [exportMonitors, isExporting] = useExportMonitors()
|
const [exportMonitors, isExporting] = useExportMonitors();
|
||||||
|
|
||||||
// Use the provided label or fall back to the translated default
|
// Use the provided label or fall back to the translated default
|
||||||
|
|
||||||
|
|||||||
@@ -454,36 +454,36 @@ const useCreateBulkMonitors = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const useExportMonitors = () => {
|
const useExportMonitors = () => {
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const exportMonitors = async () => {
|
const exportMonitors = async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const blob = await networkService.exportMonitors();
|
const blob = await networkService.exportMonitors();
|
||||||
|
|
||||||
// Create a download link
|
// Create a download link
|
||||||
const url = window.URL.createObjectURL(blob);
|
const url = window.URL.createObjectURL(blob);
|
||||||
const link = document.createElement('a');
|
const link = document.createElement("a");
|
||||||
link.href = url;
|
link.href = url;
|
||||||
link.setAttribute('download', 'monitors.csv');
|
link.setAttribute("download", "monitors.csv");
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
link.remove();
|
link.remove();
|
||||||
window.URL.revokeObjectURL(url);
|
window.URL.revokeObjectURL(url);
|
||||||
|
|
||||||
createToast({ body: t('export.success') });
|
createToast({ body: t("export.success") });
|
||||||
return [true, null];
|
return [true, null];
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const errorMessage = err?.response?.data?.msg || err.message;
|
const errorMessage = err?.response?.data?.msg || err.message;
|
||||||
createToast({ body: errorMessage || t('export.failed') });
|
createToast({ body: errorMessage || t("export.failed") });
|
||||||
return [false, errorMessage];
|
return [false, errorMessage];
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return [exportMonitors, isLoading];
|
return [exportMonitors, isLoading];
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
|||||||
@@ -741,8 +741,8 @@
|
|||||||
"port": "Enter the URL or IP of the server, the port number and a clear display name that appears on the dashboard."
|
"port": "Enter the URL or IP of the server, the port number and a clear display name that appears on the dashboard."
|
||||||
},
|
},
|
||||||
"export": {
|
"export": {
|
||||||
"title": "Export Monitors",
|
"title": "Export Monitors",
|
||||||
"success": "Monitors exported successfully!",
|
"success": "Monitors exported successfully!",
|
||||||
"failed": "Failed to export monitors"
|
"failed": "Failed to export monitors"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user