diff options
Diffstat (limited to 'dashboard_website/static/js/controls.js')
| -rw-r--r-- | dashboard_website/static/js/controls.js | 42 |
1 files changed, 42 insertions, 0 deletions
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 |
