fix process follows device and process changes are auto-saved
This commit is contained in:
parent
1c2b1c2220
commit
903fd2eff7
2 changed files with 32 additions and 5 deletions
|
|
@ -723,9 +723,8 @@
|
||||||
let mode = API.mode.get(),
|
let mode = API.mode.get(),
|
||||||
current = settings(),
|
current = settings(),
|
||||||
local = isLocalDevice(devicename),
|
local = isLocalDevice(devicename),
|
||||||
dproc = current.devproc[devicename],
|
|
||||||
dev = current.device = CONF.device_from_code(code,mode),
|
dev = current.device = CONF.device_from_code(code,mode),
|
||||||
proc = current.process,
|
dproc = current.devproc[devicename], // last process name for this device
|
||||||
newdev = dproc === undefined, // first time device is selected
|
newdev = dproc === undefined, // first time device is selected
|
||||||
predev = current.filter[mode], // previous device selection
|
predev = current.filter[mode], // previous device selection
|
||||||
chgdev = predev !== devicename; // device is changing
|
chgdev = predev !== devicename; // device is changing
|
||||||
|
|
@ -734,10 +733,12 @@
|
||||||
if (code.profiles) {
|
if (code.profiles) {
|
||||||
for (let profile of code.profiles) {
|
for (let profile of code.profiles) {
|
||||||
let profname = profile.processName;
|
let profname = profile.processName;
|
||||||
|
// if no saved profile by that name for this mode...
|
||||||
if (!current.sproc[mode][profname]) {
|
if (!current.sproc[mode][profname]) {
|
||||||
console.log('adding profile', profname, 'to', mode);
|
console.log('adding profile', profname, 'to', mode);
|
||||||
current.sproc[mode][profname] = profile;
|
current.sproc[mode][profname] = profile;
|
||||||
}
|
}
|
||||||
|
// if it's a new device, seed the new profile name as last profile
|
||||||
if (newdev && !current.devproc[devicename]) {
|
if (newdev && !current.devproc[devicename]) {
|
||||||
console.log('setting default profile for new device', devicename, 'to', profname);
|
console.log('setting default profile for new device', devicename, 'to', profname);
|
||||||
current.devproc[devicename] = dproc = profname;
|
current.devproc[devicename] = dproc = profname;
|
||||||
|
|
@ -836,7 +837,9 @@
|
||||||
API.view.update_fields();
|
API.view.update_fields();
|
||||||
platform.update_size();
|
platform.update_size();
|
||||||
|
|
||||||
|
// store current device name for this mode
|
||||||
current.filter[mode] = devicename;
|
current.filter[mode] = devicename;
|
||||||
|
// cache device record for this mode (restored in setMode)
|
||||||
current.cdev[mode] = currentDevice = dev;
|
current.cdev[mode] = currentDevice = dev;
|
||||||
|
|
||||||
if (dproc) {
|
if (dproc) {
|
||||||
|
|
@ -994,6 +997,7 @@
|
||||||
let exp = btoa(JSON.stringify({
|
let exp = btoa(JSON.stringify({
|
||||||
version: KIRI.version,
|
version: KIRI.version,
|
||||||
device: selected,
|
device: selected,
|
||||||
|
process: API.process.code(),
|
||||||
code: devs[selected],
|
code: devs[selected],
|
||||||
time: Date.now()
|
time: Date.now()
|
||||||
}));
|
}));
|
||||||
|
|
|
||||||
|
|
@ -257,6 +257,7 @@
|
||||||
layer_max: 0
|
layer_max: 0
|
||||||
},
|
},
|
||||||
device: {
|
device: {
|
||||||
|
code: currentDeviceCode,
|
||||||
get: currentDeviceName,
|
get: currentDeviceName,
|
||||||
set: noop, // set during init
|
set: noop, // set during init
|
||||||
clone: noop // set during init
|
clone: noop // set during init
|
||||||
|
|
@ -311,6 +312,10 @@
|
||||||
grid : function() { return false },
|
grid : function() { return false },
|
||||||
local : function() { return false }
|
local : function() { return false }
|
||||||
},
|
},
|
||||||
|
process: {
|
||||||
|
code: currentProcessCode,
|
||||||
|
get: currentProcessName
|
||||||
|
},
|
||||||
platform,
|
platform,
|
||||||
selection,
|
selection,
|
||||||
show: {
|
show: {
|
||||||
|
|
@ -2185,6 +2190,11 @@
|
||||||
if (val === '' && tval == null) {
|
if (val === '' && tval == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (Array.isArray(tval) && Array.isArray(val)) {
|
||||||
|
if (JSON.stringify(tval) == JSON.stringify(val)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (tval != val) {
|
if (tval != val) {
|
||||||
// console.log(key, 'expected', val, 'got', tval);
|
// console.log(key, 'expected', val, 'got', tval);
|
||||||
same = false;
|
same = false;
|
||||||
|
|
@ -2551,13 +2561,14 @@
|
||||||
|
|
||||||
function loadSettings(e, named) {
|
function loadSettings(e, named) {
|
||||||
let mode = getMode(),
|
let mode = getMode(),
|
||||||
name = e ? e.target.getAttribute("load") : named || "default",
|
name = e ? e.target.getAttribute("load") : named || currentProcessName() || "default",
|
||||||
load = settings.sproc[mode][name];
|
load = settings.sproc[mode][name];
|
||||||
|
|
||||||
if (!load) return;
|
if (!load) return;
|
||||||
|
|
||||||
// clone loaded process into settings
|
// cloning loaded process into settings requires user to save
|
||||||
settings.process = clone(load);
|
// process before switching devices or risk losing any changes
|
||||||
|
settings.process = load;//clone(load);
|
||||||
// update process name
|
// update process name
|
||||||
settings.process.processName = name;
|
settings.process.processName = name;
|
||||||
// save named process with the current device
|
// save named process with the current device
|
||||||
|
|
@ -2815,6 +2826,18 @@
|
||||||
return settings.filter[getMode()];
|
return settings.filter[getMode()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function currentDeviceCode() {
|
||||||
|
return settings.devices[currentDeviceName()];
|
||||||
|
}
|
||||||
|
|
||||||
|
function currentProcessName() {
|
||||||
|
return settings.cproc[getMode()];
|
||||||
|
}
|
||||||
|
|
||||||
|
function currentProcessCode() {
|
||||||
|
return settings.sproc[getMode()][currentProcessName()];
|
||||||
|
}
|
||||||
|
|
||||||
function setControlsVisible(show) {
|
function setControlsVisible(show) {
|
||||||
$('mid-lcol').style.display = show ? 'flex' : 'none';
|
$('mid-lcol').style.display = show ? 'flex' : 'none';
|
||||||
$('mid-rcol').style.display = show ? 'flex' : 'none';
|
$('mid-rcol').style.display = show ? 'flex' : 'none';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue