add remote workspace load (cors req'd)

This commit is contained in:
Stewart Allen 2022-02-20 00:56:08 -05:00
commit 70f9146a96
2 changed files with 15 additions and 0 deletions

View file

@ -2507,6 +2507,11 @@
console.log({octoprint:ohost});
}
// load workspace from url
if (SETUP.wrk) {
api.settings.import_url(`${proto}//${SETUP.wrk[0]}`, true);
}
// bind this to UI so main can call it on settings import
ui.sync = function() {
const current = settings();

View file

@ -575,6 +575,15 @@ function settingsImport(data, ask) {
}
}
function settingsImportUrl(url, ask) {
fetch(url).then(r => r.arrayBuffer()).then(a => {
settingsImport(a, ask);
}).catch(error => {
console.log({workspace_url: url, error: error.message || error});
api.show.alert('workspace load failed');
});
}
function settingsImportZip(data, ask) {
let alert = api.show.alert("Importing Workspace");
JSZip.loadAsync(data).then(zip => {
@ -679,6 +688,7 @@ api.settings = {
get: getSettings,
import: settingsImport,
import_zip: settingsImportZip,
import_url: settingsImportUrl,
import_prusa: settingsPrusaConvert,
dev() { return settings.device },
proc() { return settings.process },