mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-04 01:01:35 -07:00
FE+BE: allow ❌None as a value in DeviceEdit for fields with other default NEWDEV values
Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
@@ -388,7 +388,7 @@
|
|||||||
},
|
},
|
||||||
error: function (xhr) {
|
error: function (xhr) {
|
||||||
if (xhr.status === 403) {
|
if (xhr.status === 403) {
|
||||||
showMessage("Unauthorized – invalid API token");
|
showMessage("Unauthorized - invalid API token");
|
||||||
} else {
|
} else {
|
||||||
showMessage("Failed to save device (" + xhr.status + ")");
|
showMessage("Failed to save device (" + xhr.status + ")");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1000,7 +1000,8 @@ function isRandomMAC(mac)
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
// Empty array
|
// Empty array
|
||||||
if (input === '[]' || input === '') {
|
// if (input === '[]' || input === '') {
|
||||||
|
if (input === '[]') {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
// handle integer
|
// handle integer
|
||||||
|
|||||||
@@ -1135,16 +1135,19 @@ function collectSetting(prefix, setCodeName, setType, settingsArray) {
|
|||||||
function generateFormHtml(settingsData, set, overrideValue, overrideOptions, originalSetKey) {
|
function generateFormHtml(settingsData, set, overrideValue, overrideOptions, originalSetKey) {
|
||||||
let inputHtml = '';
|
let inputHtml = '';
|
||||||
|
|
||||||
isEmpty(overrideValue) ? inVal = set['setValue'] : inVal = overrideValue;
|
|
||||||
|
// if override value is considered empty initialize from setting defaults
|
||||||
|
overrideValue == null || overrideValue == undefined ? inVal = set['setValue'] : inVal = overrideValue
|
||||||
const setKey = set['setKey'];
|
const setKey = set['setKey'];
|
||||||
const setType = set['setType'];
|
const setType = set['setType'];
|
||||||
|
|
||||||
// if (setKey == '') {
|
// if (setKey == 'NEWDEV_devParentMAC') {
|
||||||
|
|
||||||
// console.log(setType);
|
// console.log("==== DEBUG OUTPUT BELOW 1 ====");
|
||||||
// console.log(setKey);
|
// console.log(setType);
|
||||||
// console.log(overrideValue);
|
// console.log(setKey);
|
||||||
// console.log(inVal);
|
// console.log(overrideValue);
|
||||||
|
// console.log(inVal);
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@@ -1186,15 +1189,16 @@ function generateFormHtml(settingsData, set, overrideValue, overrideOptions, ori
|
|||||||
// Override value
|
// Override value
|
||||||
let val = valRes;
|
let val = valRes;
|
||||||
|
|
||||||
// if (setKey == '') {
|
// if (setKey == 'NEWDEV_devParentMAC') {
|
||||||
|
|
||||||
|
// console.log("==== DEBUG OUTPUT BELOW 2 ====");
|
||||||
// console.log(setType);
|
// console.log(setType);
|
||||||
// console.log(setKey);
|
// console.log(setKey);
|
||||||
// console.log(overrideValue);
|
// console.log(overrideValue);
|
||||||
// console.log(inVal);
|
// console.log(inVal);
|
||||||
// console.log(val);
|
// console.log(val);
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Generate HTML based on elementType
|
// Generate HTML based on elementType
|
||||||
switch (elementType) {
|
switch (elementType) {
|
||||||
@@ -1340,7 +1344,7 @@ function generateFormHtml(settingsData, set, overrideValue, overrideOptions, ori
|
|||||||
|
|
||||||
let j = 0;
|
let j = 0;
|
||||||
columnSettings.forEach(set => {
|
columnSettings.forEach(set => {
|
||||||
// Extract the value for the current column based on the new structure
|
// Extract the value for the current column
|
||||||
let columnOverrideValue = rowData[j] && Object.values(rowData[j])[0];
|
let columnOverrideValue = rowData[j] && Object.values(rowData[j])[0];
|
||||||
|
|
||||||
if(columnOverrideValue == undefined)
|
if(columnOverrideValue == undefined)
|
||||||
|
|||||||
@@ -590,6 +590,10 @@ class DeviceInstance:
|
|||||||
cur.execute(sql, values)
|
cur.execute(sql, values)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
mylog("debug", f"[DeviceInstance] setDeviceData SQL: {sql.strip()}")
|
||||||
|
mylog("debug", f"[DeviceInstance] setDeviceData VALUES:{values}")
|
||||||
|
|
||||||
return {"success": True}
|
return {"success": True}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if conn:
|
if conn:
|
||||||
|
|||||||
Reference in New Issue
Block a user