reflow settings restoration and progressive saves
This commit is contained in:
parent
697f24703d
commit
f2672adcb7
2 changed files with 69 additions and 54 deletions
|
|
@ -571,8 +571,10 @@
|
||||||
if (!cp.hasOwnProperty(k)) continue;
|
if (!cp.hasOwnProperty(k)) continue;
|
||||||
np[k] = cp[k];
|
np[k] = cp[k];
|
||||||
}
|
}
|
||||||
s.cproc[API.mode.get()] = name;
|
s.cproc[mode] = name;
|
||||||
|
s.devproc[s.device.deviceName] = name;
|
||||||
API.conf.save();
|
API.conf.save();
|
||||||
|
API.conf.update();
|
||||||
API.event.settings();
|
API.event.settings();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -1933,27 +1935,6 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let current = settings(),
|
|
||||||
control = current.controller;
|
|
||||||
|
|
||||||
platform.deselect();
|
|
||||||
CATALOG.addFileListener(updateCatalog);
|
|
||||||
SPACE.view.setZoom(control.reverseZoom, control.zoomSpeed);
|
|
||||||
SPACE.platform.setZOff(0.2);
|
|
||||||
|
|
||||||
// restore UI state from settings
|
|
||||||
UI.showOrigin.checked = control.showOrigin;
|
|
||||||
UI.showRulers.checked = control.showRulers;
|
|
||||||
UI.showSpeeds.checked = control.showSpeeds;
|
|
||||||
UI.freeLayout.checked = control.freeLayout;
|
|
||||||
UI.autoLayout.checked = control.autoLayout;
|
|
||||||
UI.alignTop.checked = control.alignTop;
|
|
||||||
UI.reverseZoom.checked = control.reverseZoom;
|
|
||||||
UI.decimate.checked = control.decimate;
|
|
||||||
lineTypeSave();
|
|
||||||
detailSave();
|
|
||||||
updateFPS();
|
|
||||||
|
|
||||||
// load script extensions
|
// load script extensions
|
||||||
if (SETUP.s) SETUP.s.forEach(function(lib) {
|
if (SETUP.s) SETUP.s.forEach(function(lib) {
|
||||||
let scr = DOC.createElement('script');
|
let scr = DOC.createElement('script');
|
||||||
|
|
@ -1991,32 +1972,62 @@
|
||||||
console.log({octoprint:ohost});
|
console.log({octoprint:ohost});
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional set-and-lock mode (hides mode menu)
|
// bind this to UI so main can call it on settings import
|
||||||
let SETMODE = SETUP.mode ? SETUP.mode[0] : null;
|
UI.sync = function() {
|
||||||
|
const current = settings();
|
||||||
|
const control = current.controller;
|
||||||
|
const process = settings.process;
|
||||||
|
|
||||||
// optional set-and-lock device (hides device menu)
|
platform.deselect();
|
||||||
let DEVNAME = SETUP.dev ? SETUP.dev[0] : null;
|
CATALOG.addFileListener(updateCatalog);
|
||||||
|
SPACE.view.setZoom(control.reverseZoom, control.zoomSpeed);
|
||||||
|
SPACE.platform.setZOff(0.2);
|
||||||
|
|
||||||
// setup default mode and enable mode locking, if set
|
// restore UI state from settings
|
||||||
API.mode.set(SETMODE || STARTMODE || current.mode, SETMODE);
|
UI.showOrigin.checked = control.showOrigin;
|
||||||
|
UI.showRulers.checked = control.showRulers;
|
||||||
|
UI.showSpeeds.checked = control.showSpeeds;
|
||||||
|
UI.freeLayout.checked = control.freeLayout;
|
||||||
|
UI.autoLayout.checked = control.autoLayout;
|
||||||
|
UI.alignTop.checked = control.alignTop;
|
||||||
|
UI.reverseZoom.checked = control.reverseZoom;
|
||||||
|
UI.decimate.checked = control.decimate;
|
||||||
|
lineTypeSave();
|
||||||
|
detailSave();
|
||||||
|
updateFPS();
|
||||||
|
|
||||||
// update everything dependent on the platform size
|
// optional set-and-lock mode (hides mode menu)
|
||||||
platform.update_size();
|
let SETMODE = SETUP.mode ? SETUP.mode[0] : null;
|
||||||
|
|
||||||
// restore expert setting preference
|
// optional set-and-lock device (hides device menu)
|
||||||
API.mode.set_expert(control.expert);
|
let DEVNAME = SETUP.dev ? SETUP.dev[0] : null;
|
||||||
|
|
||||||
// setup tab visibility watcher
|
// setup default mode and enable mode locking, if set
|
||||||
// DOC.addEventListener('visibilitychange', function() { document.title = document.hidden });
|
API.mode.set(SETMODE || STARTMODE || current.mode, SETMODE);
|
||||||
|
|
||||||
// fill device list
|
// restore expert setting preference
|
||||||
updateDeviceList();
|
API.mode.set_expert(control.expert);
|
||||||
|
|
||||||
// ensure settings has gcode
|
// fill device list
|
||||||
selectDevice(DEVNAME || API.device.get(), DEVNAME);
|
updateDeviceList();
|
||||||
|
|
||||||
// ensure field data propagation
|
// ensure settings has gcode
|
||||||
API.conf.update();
|
selectDevice(DEVNAME || API.device.get(), DEVNAME);
|
||||||
|
|
||||||
|
// update ui fields from settings
|
||||||
|
API.view.update_fields();
|
||||||
|
|
||||||
|
// default to ARRANGE view mode
|
||||||
|
API.view.set(VIEWS.ARRANGE);
|
||||||
|
|
||||||
|
// add ability to override
|
||||||
|
API.show.controls(API.feature.controls);
|
||||||
|
|
||||||
|
// update everything dependent on the platform size
|
||||||
|
platform.update_size();
|
||||||
|
};
|
||||||
|
|
||||||
|
UI.sync();
|
||||||
|
|
||||||
// load settings provided in url hash
|
// load settings provided in url hash
|
||||||
loadSettingsFromServer();
|
loadSettingsFromServer();
|
||||||
|
|
@ -2029,12 +2040,6 @@
|
||||||
API.event.alerts(true);
|
API.event.alerts(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
// default to ARRANGE view mode
|
|
||||||
API.view.set(VIEWS.ARRANGE);
|
|
||||||
|
|
||||||
// add ability to override
|
|
||||||
API.show.controls(API.feature.controls);
|
|
||||||
|
|
||||||
// enable modal hiding
|
// enable modal hiding
|
||||||
$('mod-x').onclick = API.modal.hide;
|
$('mod-x').onclick = API.modal.hide;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@
|
||||||
VIEWS = CONF.VIEWS,
|
VIEWS = CONF.VIEWS,
|
||||||
clone = Object.clone,
|
clone = Object.clone,
|
||||||
settings = clone(CONF.template),
|
settings = clone(CONF.template),
|
||||||
// settingsDefault = clone(settings),
|
|
||||||
// ---------------
|
// ---------------
|
||||||
Widget = kiri.Widget,
|
Widget = kiri.Widget,
|
||||||
newWidget = kiri.newWidget,
|
newWidget = kiri.newWidget,
|
||||||
|
|
@ -1465,16 +1464,17 @@
|
||||||
updateSettingsFromFields(device.extruders[device.internal]);
|
updateSettingsFromFields(device.extruders[device.internal]);
|
||||||
}
|
}
|
||||||
API.conf.save();
|
API.conf.save();
|
||||||
// platform.update_stock();
|
|
||||||
$('mode-device').innerText = settings.device.deviceName;
|
$('mode-device').innerText = settings.device.deviceName;
|
||||||
$('mode-profile').innerText = settings.process.processName;
|
$('mode-profile').innerText = settings.process.processName;
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveSettings() {
|
function saveSettings() {
|
||||||
let view = SPACE.view.save();
|
const view = SPACE.view.save();
|
||||||
if (view.left || view.up) {
|
if (view.left || view.up) {
|
||||||
settings.controller.view = view;
|
settings.controller.view = view;
|
||||||
}
|
}
|
||||||
|
const mode = settings.mode, name = settings.process.processName;
|
||||||
|
settings.sproc[mode][name] = settings.process;
|
||||||
settings.device.bedRound = UI.deviceRound.checked;
|
settings.device.bedRound = UI.deviceRound.checked;
|
||||||
settings.device.originCenter = UI.deviceOrigin.checked;
|
settings.device.originCenter = UI.deviceOrigin.checked;
|
||||||
SDB.setItem('ws-settings', JSON.stringify(settings));
|
SDB.setItem('ws-settings', JSON.stringify(settings));
|
||||||
|
|
@ -1491,6 +1491,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (LOCAL) console.log('import',data);
|
||||||
let isSettings = (data.settings && data.version && data.time);
|
let isSettings = (data.settings && data.version && data.time);
|
||||||
let isDevice = (data.device && data.version && data.time);
|
let isDevice = (data.device && data.version && data.time);
|
||||||
if (!isSettings && !isDevice) {
|
if (!isSettings && !isDevice) {
|
||||||
|
|
@ -1501,8 +1502,12 @@
|
||||||
function doit() {
|
function doit() {
|
||||||
if (isSettings) {
|
if (isSettings) {
|
||||||
settings = CONF.normalize(data.settings);
|
settings = CONF.normalize(data.settings);
|
||||||
API.conf.save();
|
SDB.setItem('ws-settings', JSON.stringify(settings));
|
||||||
API.space.reload();
|
if (LOCAL) console.log('settings',Object.clone(settings));
|
||||||
|
restoreSettings();
|
||||||
|
restoreWorkspace(() => {
|
||||||
|
UI.sync();
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
if (isDevice) {
|
if (isDevice) {
|
||||||
if (settings.devices[data.device]) {
|
if (settings.devices[data.device]) {
|
||||||
|
|
@ -1657,7 +1662,12 @@
|
||||||
}
|
}
|
||||||
SPACE.scene.freeze(fz);
|
SPACE.scene.freeze(fz);
|
||||||
|
|
||||||
if (skip_widget_load) return;
|
if (skip_widget_load) {
|
||||||
|
if (ondone) {
|
||||||
|
ondone();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// remove any widgets from platform
|
// remove any widgets from platform
|
||||||
forAllWidgets(function(widget) {
|
forAllWidgets(function(widget) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue