mirror of
https://github.com/stagehacks/Cue-View.git
synced 2026-08-14 02:03:39 +00:00
save field values with other save data
This commit is contained in:
+7
-6
@@ -49,7 +49,7 @@ function registerDevice(newDevice) {
|
||||
port: newDevice.port,
|
||||
addresses: newDevice.addresses,
|
||||
data: {},
|
||||
fields: {},
|
||||
fields: newDevice.fields || {},
|
||||
pinIndex: false,
|
||||
lastDrawn: 0,
|
||||
lastHeartbeat: 0,
|
||||
@@ -68,13 +68,15 @@ function registerDevice(newDevice) {
|
||||
|
||||
devices[id].plugin = PLUGINS.all[newDevice.type];
|
||||
|
||||
if(PLUGINS.all[newDevice.type].config.fields){
|
||||
PLUGINS.all[newDevice.type].config.fields.forEach(field => {
|
||||
if (
|
||||
Object.keys(devices[id].fields).length == 0 &&
|
||||
PLUGINS.all[newDevice.type].config.fields
|
||||
) {
|
||||
PLUGINS.all[newDevice.type].config.fields.forEach((field) => {
|
||||
devices[id].fields[field.key] = field.value;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
VIEW.addDeviceToList(devices[id]);
|
||||
initDeviceConnection(id);
|
||||
return true;
|
||||
@@ -86,7 +88,7 @@ function initDeviceConnection(id) {
|
||||
|
||||
infoUpdate(device, 'status', 'new');
|
||||
|
||||
if(device.port === undefined){
|
||||
if (device.port === undefined) {
|
||||
device.port = device.plugin.config.defaultPort;
|
||||
}
|
||||
|
||||
@@ -138,7 +140,6 @@ function initDeviceConnection(id) {
|
||||
device.send = (address, args) => {
|
||||
device.connection.send({ address, args });
|
||||
};
|
||||
|
||||
} else if (plugins[type].config.connectionType === 'TCPsocket') {
|
||||
device.connection = new net.Socket();
|
||||
|
||||
|
||||
+3
-1
@@ -60,6 +60,7 @@ module.exports.loadDevices = function loadDevices() {
|
||||
port: savedDevices[i].port,
|
||||
addresses: savedDevices[i].addresses,
|
||||
id: savedDevices[i].id,
|
||||
fields: savedDevices[i].fields
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -74,7 +75,7 @@ module.exports.saveAll = function saveAll() {
|
||||
savedSlots[activeSlot][i] = {
|
||||
addresses: currentPins[i].addresses,
|
||||
type: currentPins[i].type,
|
||||
id: currentPins[i].id,
|
||||
id: currentPins[i].id
|
||||
};
|
||||
}
|
||||
localStorage.setItem('savedSlots', JSON.stringify(savedSlots));
|
||||
@@ -93,6 +94,7 @@ module.exports.saveAll = function saveAll() {
|
||||
defaultName: device.defaultName,
|
||||
port: device.port,
|
||||
id: device.id,
|
||||
fields: device.fields
|
||||
};
|
||||
i++;
|
||||
});
|
||||
|
||||
+3
-1
@@ -1,6 +1,7 @@
|
||||
const { ipcRenderer } = require('electron');
|
||||
const DEVICE = require('./device.js');
|
||||
const PLUGINS = require('./plugins.js');
|
||||
const { saveAll } = require('./saveSlots.js');
|
||||
// const _ = require('lodash/function');
|
||||
|
||||
const pinnedDevices = [];
|
||||
@@ -216,6 +217,7 @@ function switchDevice(id) {
|
||||
$elem.onchange = function(e){
|
||||
activeDevice.fields[field.key] = $elem.value;
|
||||
field.action(activeDevice);
|
||||
saveAll();
|
||||
}
|
||||
|
||||
if(field.type=="textinput"){
|
||||
@@ -328,7 +330,7 @@ module.exports.selectNextDevice = function selectNextDevice() {
|
||||
|
||||
function populatePluginLists() {
|
||||
let typeSelect = '';
|
||||
let addSelect = '<option value="" disabled selected hidden>+</option>';
|
||||
let addSelect = '<option value="" disabled selected hidden> + </option>';
|
||||
|
||||
Object.keys(PLUGINS.all).forEach((pluginType) => {
|
||||
const plugin = PLUGINS.all[pluginType];
|
||||
|
||||
Reference in New Issue
Block a user