From c560de266caad6db97e58757ca43e8558c103c01 Mon Sep 17 00:00:00 2001 From: Anson Bridges Date: Sat, 18 Nov 2023 06:18:23 -0500 Subject: csv import, manual visiting --- dashboard_website/static/js/controls.js | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 dashboard_website/static/js/controls.js (limited to 'dashboard_website/static/js/controls.js') diff --git a/dashboard_website/static/js/controls.js b/dashboard_website/static/js/controls.js new file mode 100644 index 0000000..3d81032 --- /dev/null +++ b/dashboard_website/static/js/controls.js @@ -0,0 +1,42 @@ +// uses functions in utils.js +var host = window.location.protocol + "//" + window.location.host; + +function downloadCurrent(){ + call("downloadSave"); +} + +// load and append dirty file +function loadDirty(){ + call("loadDirty", "dirty"); +} + +// load save file (clean) +function loadSave(){ + call("loadSave", "clean"); +} + +function call(command, formid=""){ + var formData; + if (formid == "") { + formData = new FormData(); + }else { + formData = new FormData(document.getElementById(formid)); + } + + formData.append("command", command); + console.log(formData); + + fetch(host+'/controls', { + method: "POST", + body: formData + }).then( res => res.blob() ) + .then( blob => { + var file = window.URL.createObjectURL(blob); + window.location.assign(file);}); + //.then((response) => response.json()) + //.then((json) => handleCallResponse(json)); +} + +function handleLatestInfo(json){ + if(json['status'] != "OK")alert("Error."); +} \ No newline at end of file -- cgit v1.2.3