From e9be54b1ad524950e63b4e22c3cc180c848d51a6 Mon Sep 17 00:00:00 2001 From: Brandon Longuet <37945524+AmazingBrandonL@users.noreply.github.com> Date: Tue, 9 Apr 2024 12:03:19 -0500 Subject: [PATCH] Fixed download --- src/webPages/mechanisms.tsx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/webPages/mechanisms.tsx b/src/webPages/mechanisms.tsx index 36118f0d..cd6afe93 100644 --- a/src/webPages/mechanisms.tsx +++ b/src/webPages/mechanisms.tsx @@ -26,6 +26,7 @@ import TaskSharpIcon from '@mui/icons-material/TaskSharp'; import "./mechanisms.css"; import { createMechanism } from '../API/API_CreateMethods'; import { useRef } from 'react'; +import { downloadOA } from '../API/API_DeleteMethods'; const MechanismPage = () => { @@ -62,7 +63,22 @@ const MechanismPage = () => { setCreateMechanismOpen(false); } + const handleDownlaodClick = async () => { + const link = document.createElement("a"); + const body = await downloadOA(tagMechanismUuid as string); + const blob = new Blob([body], { type: 'application/json' }); + + const blobUrl = window.URL.createObjectURL(blob); + + link.download = 'openAtmos.json'; + link.href = blobUrl; + + link.click(); + + window.URL.revokeObjectURL(blobUrl); + }; + var listName = "Options for "; if(tagMechanismUuid){ listName += getTagMechanism(tagMechanismUuid as string); @@ -205,6 +221,15 @@ const MechanismPage = () => { + + + + + + + + +