diff --git a/changelog.md b/changelog.md index a5add76..daf142c 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,10 @@ - New color slider with reset buttons - Fixed blinking modals issues - Added lazyloading to URL and Servapp pages images + - Added a button in the config page to easily download the docker backup + - Improve display or icons [fixes #121] + - Refactored Mongo connection code [fixes #111] + - Forward simultaneously TCP and UDP [fixes #122] ## Version 0.11.3 - Fix missing even subscriber on export diff --git a/client/src/api/config.ts b/client/src/api/config.ts index eba10d9..cea6cfd 100644 --- a/client/src/api/config.ts +++ b/client/src/api/config.ts @@ -83,6 +83,15 @@ async function addRoute(newRoute: Route): Promise { return rawUpdateRoute("", 'add', newRoute); } +function getBackup() { + return wrap(fetch('/cosmos/api/get-backup', { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + }, + })) +} + export { get, set, @@ -94,4 +103,5 @@ export { deleteRoute, addRoute, canSendEmail, + getBackup, }; \ No newline at end of file diff --git a/client/src/api/downloadButton.jsx b/client/src/api/downloadButton.jsx index 814e6a7..1468aba 100644 --- a/client/src/api/downloadButton.jsx +++ b/client/src/api/downloadButton.jsx @@ -1,28 +1,41 @@ import { Button } from "@mui/material"; -export const DownloadFile = ({ filename, content, label }) => { - const downloadFile = () => { - // Create a blob with the content - const blob = new Blob([content], { type: "text/plain;charset=utf-8" }); +export const DownloadFile = ({ filename, content, contentGetter, label }) => { + const downloadFile = async () => { + // Get the content + if (contentGetter) { + try { + content = await contentGetter(); + if(typeof content !== "string") { + content = JSON.stringify(content, null, 2); + } + } catch (e) { + console.error(e); + return; + } + } - // Create a link element - const link = document.createElement("a"); - link.href = URL.createObjectURL(blob); - link.download = filename; + // Create a blob with the content + const blob = new Blob([content], { type: "text/plain;charset=utf-8" }); - // Append the link to the document (needed for Firefox) - document.body.appendChild(link); + // Create a link element + const link = document.createElement("a"); + link.href = URL.createObjectURL(blob); + link.download = filename; - // Simulate a click to start the download - link.click(); + // Append the link to the document (needed for Firefox) + document.body.appendChild(link); - // Cleanup the DOM by removing the link element - document.body.removeChild(link); - } + // Simulate a click to start the download + link.click(); - return ( - - ); + // Cleanup the DOM by removing the link element + document.body.removeChild(link); + } + + return ( + + ); } \ No newline at end of file diff --git a/client/src/pages/config/users/configman.jsx b/client/src/pages/config/users/configman.jsx index 43951b8..0a333f3 100644 --- a/client/src/pages/config/users/configman.jsx +++ b/client/src/pages/config/users/configman.jsx @@ -33,6 +33,7 @@ import { SliderPicker import {SetPrimaryColor, SetSecondaryColor} from '../../../App'; import { useClientInfos } from '../../../utils/hooks'; import ConfirmModal from '../../../components/confirmModal'; +import { DownloadFile } from '../../../api/downloadButton'; const ConfigManagement = () => { const [config, setConfig] = React.useState(null); @@ -77,6 +78,13 @@ const ConfigManagement = () => { }} label={'Purge Metrics Dashboard'} content={'Are you sure you want to purge all the metrics data from the dashboards?'} /> + + + {config && <> diff --git a/client/src/pages/dashboard/components/mini-plot.jsx b/client/src/pages/dashboard/components/mini-plot.jsx index 519b38e..b1e3006 100644 --- a/client/src/pages/dashboard/components/mini-plot.jsx +++ b/client/src/pages/dashboard/components/mini-plot.jsx @@ -167,11 +167,12 @@ const _MiniPlotComponent = ({metrics, labels}) => { -
{formaters[di](dataMetric.Values[dataMetric.Values.length - 1].Value)}
+ }
- Monitoring -
+ Monitoring +