From dbea0b381954b2b99d57dc532c67e89387a5ef2c Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Tue, 30 Jul 2024 14:30:02 +0200 Subject: [PATCH] Create Download component --- .../Offline/components/Download/Download.jsx | 33 +++++++++++++++++++ .../Offline/components/Download/index.js | 1 + 2 files changed, 34 insertions(+) create mode 100644 dashboard/src/states/Dashboard/pages/Info/components/Offline/components/Download/Download.jsx create mode 100644 dashboard/src/states/Dashboard/pages/Info/components/Offline/components/Download/index.js diff --git a/dashboard/src/states/Dashboard/pages/Info/components/Offline/components/Download/Download.jsx b/dashboard/src/states/Dashboard/pages/Info/components/Offline/components/Download/Download.jsx new file mode 100644 index 0000000..2f9e779 --- /dev/null +++ b/dashboard/src/states/Dashboard/pages/Info/components/Offline/components/Download/Download.jsx @@ -0,0 +1,33 @@ +import {Button, Stack, Typography} from "@mui/material"; +import {ProjectContext} from "@/states/Dashboard/contexts/Project"; +import {useContext} from "react"; +import {getRequest} from "@/common/utils/RequestUtil.js"; + +export const Download = () => { + + const {currentProject} = useContext(ProjectContext); + + const download = async () => { + getRequest(`/project/${currentProject.id}/public-key`).then(response => { + const element = document.createElement("a"); + const file = new Blob([response.key], {type: 'text/plain'}); + element.href = URL.createObjectURL(file); + element.download = currentProject.name + "_key.pem"; + document.body.appendChild(element); + element.click(); + }); + } + + return ( + + + Download public key + + Download the public key to use for offline license generation. + + + + + ) +} \ No newline at end of file diff --git a/dashboard/src/states/Dashboard/pages/Info/components/Offline/components/Download/index.js b/dashboard/src/states/Dashboard/pages/Info/components/Offline/components/Download/index.js new file mode 100644 index 0000000..fad6b57 --- /dev/null +++ b/dashboard/src/states/Dashboard/pages/Info/components/Offline/components/Download/index.js @@ -0,0 +1 @@ +export {Download as default} from "./Download.jsx"; \ No newline at end of file