mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-23 23:18:14 -05: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) {
|
||||
if (xhr.status === 403) {
|
||||
showMessage("Unauthorized – invalid API token");
|
||||
showMessage("Unauthorized - invalid API token");
|
||||
} else {
|
||||
showMessage("Failed to save device (" + xhr.status + ")");
|
||||
}
|
||||
|
||||
@@ -1000,7 +1000,8 @@ function isRandomMAC(mac)
|
||||
return input;
|
||||
}
|
||||
// Empty array
|
||||
if (input === '[]' || input === '') {
|
||||
// if (input === '[]' || input === '') {
|
||||
if (input === '[]') {
|
||||
return [];
|
||||
}
|
||||
// handle integer
|
||||
|
||||
@@ -1135,16 +1135,19 @@ function collectSetting(prefix, setCodeName, setType, settingsArray) {
|
||||
function generateFormHtml(settingsData, set, overrideValue, overrideOptions, originalSetKey) {
|
||||
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 setType = set['setType'];
|
||||
|
||||
// if (setKey == '') {
|
||||
// if (setKey == 'NEWDEV_devParentMAC') {
|
||||
|
||||
// console.log(setType);
|
||||
// console.log(setKey);
|
||||
// console.log(overrideValue);
|
||||
// console.log(inVal);
|
||||
// console.log("==== DEBUG OUTPUT BELOW 1 ====");
|
||||
// console.log(setType);
|
||||
// console.log(setKey);
|
||||
// console.log(overrideValue);
|
||||
// console.log(inVal);
|
||||
|
||||
// }
|
||||
|
||||
@@ -1186,15 +1189,16 @@ function generateFormHtml(settingsData, set, overrideValue, overrideOptions, ori
|
||||
// Override value
|
||||
let val = valRes;
|
||||
|
||||
// if (setKey == '') {
|
||||
// if (setKey == 'NEWDEV_devParentMAC') {
|
||||
|
||||
// console.log("==== DEBUG OUTPUT BELOW 2 ====");
|
||||
// console.log(setType);
|
||||
// console.log(setKey);
|
||||
// console.log(overrideValue);
|
||||
// console.log(inVal);
|
||||
// console.log(val);
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// Generate HTML based on elementType
|
||||
switch (elementType) {
|
||||
@@ -1340,7 +1344,7 @@ function generateFormHtml(settingsData, set, overrideValue, overrideOptions, ori
|
||||
|
||||
let j = 0;
|
||||
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];
|
||||
|
||||
if(columnOverrideValue == undefined)
|
||||
|
||||
@@ -590,6 +590,10 @@ class DeviceInstance:
|
||||
cur.execute(sql, values)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
mylog("debug", f"[DeviceInstance] setDeviceData SQL: {sql.strip()}")
|
||||
mylog("debug", f"[DeviceInstance] setDeviceData VALUES:{values}")
|
||||
|
||||
return {"success": True}
|
||||
except Exception as e:
|
||||
if conn:
|
||||
|
||||
Reference in New Issue
Block a user