add device favorite filtering

This commit is contained in:
Stewart Allen 2019-04-12 09:45:52 -04:00
commit 0b451c7b01
4 changed files with 46 additions and 5 deletions

View file

@ -418,6 +418,9 @@ self.kiri.license = exports.LICENSE;
// custom devices by name // custom devices by name
devices:{ devices:{
}, },
// favorite devices
favorites:{
},
// map of device to last process setting (name) // map of device to last process setting (name)
devproc: { devproc: {
}, },
@ -519,7 +522,8 @@ self.kiri.license = exports.LICENSE;
local = SETUP.local, local = SETUP.local,
mouseMoved = false, mouseMoved = false,
camStock = null, camStock = null,
camTopZ = 0; camTopZ = 0,
showFavorites = SDB['dev-favorites'] === 'true';
DBUG.enable(); DBUG.enable();
@ -2297,6 +2301,8 @@ self.kiri.license = exports.LICENSE;
deviceSave: $('device-save'), deviceSave: $('device-save'),
deviceClose: $('device-close'), deviceClose: $('device-close'),
deviceSelect: $('device-select'), deviceSelect: $('device-select'),
deviceFavorites: $('device-favorites'),
deviceAll: $('device-all'),
device: UC.newGroup("device", $('device')), device: UC.newGroup("device", $('device')),
deviceName: UC.newInput(LANG.dev_name, {size:20}), deviceName: UC.newInput(LANG.dev_name, {size:20}),
@ -2984,6 +2990,10 @@ self.kiri.license = exports.LICENSE;
// return localFilters.contains(devicename); // return localFilters.contains(devicename);
} }
function isFavoriteDevice(devicename) {
return settings.favorites[devicename] ? true : false;
}
function getSelectedDevice() { function getSelectedDevice() {
return UI.deviceSelect.options[UI.deviceSelect.selectedIndex].text; return UI.deviceSelect.options[UI.deviceSelect.selectedIndex].text;
} }
@ -3209,12 +3219,37 @@ self.kiri.license = exports.LICENSE;
showDevices(); showDevices();
}; };
UI.deviceAll.onclick = function() {
showFavorites = SDB['dev-favorites'] = false;
showDevices();
};
UI.deviceFavorites.onclick = function() {
showFavorites = SDB['dev-favorites'] = true;
showDevices();
};
UI.deviceSelect.innerHTML = ''; UI.deviceSelect.innerHTML = '';
devices.forEach(function(device, index) { devices.forEach(function(device, index) {
var opt = DOC.createElement('option'); var opt = DOC.createElement('option'),
fav = isFavoriteDevice(device),
loc = isLocalDevice(device);
if (showFavorites && !(fav || loc)) {
return;
}
opt.appendChild(DOC.createTextNode(device)); opt.appendChild(DOC.createTextNode(device));
opt.onclick = function() { selectDevice(device) }; opt.onclick = function() { selectDevice(device) };
if (isLocalDevice(device)) opt.setAttribute("local", 1); opt.ondblclick = function() {
if (settings.favorites[device]) {
delete settings.favorites[device];
} else {
settings.favorites[device] = true;
}
showDevices();
};
if (!showFavorites) {
if (fav) opt.setAttribute("favorite", 1);
if (loc) opt.setAttribute("local", 1);
}
UI.deviceSelect.appendChild(opt); UI.deviceSelect.appendChild(opt);
if (device === selected) selectedIndex = index; if (device === selected) selectedIndex = index;
}); });

View file

@ -1,7 +1,7 @@
var exports = { var exports = {
COPYRIGHT:"Copyright (C) 2014-2019 Stewart Allen <sa@grid.space> - All Rights Reserved", COPYRIGHT:"Copyright (C) 2014-2019 Stewart Allen <sa@grid.space> - All Rights Reserved",
LICENSE:"See the license.md file included with the source distribution", LICENSE:"See the license.md file included with the source distribution",
VERSION:"1.3.1" VERSION:"1.3.2"
}; };
if (!module) var module = {}; if (!module) var module = {};
module.exports = exports; module.exports = exports;

View file

@ -87,6 +87,9 @@
<button id="device-add">+</button> <button id="device-add">+</button>
<button id="device-del">-</button> <button id="device-del">-</button>
<span id="device-spacer"></span> <span id="device-spacer"></span>
<button id="device-favorites">favorites</button>
<button id="device-all">all</button>
<span id="device-spacer"></span>
<button id="device-save">save</button> <button id="device-save">save</button>
<button id="device-close">close</button> <button id="device-close">close</button>
</div> </div>

View file

@ -441,7 +441,10 @@ button.selected {
display: none; display: none;
} }
#device-list option[local="1"] { #device-list option[local="1"] {
color: #55f; color: #55d;
}
#device-list option[favorite="1"] {
font-weight: bold;
} }
#device label { #device label {
white-space: nowrap; white-space: nowrap;