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:
jokob-sk
2025-12-23 09:27:11 +11:00
parent 4a9dc3a86f
commit 8ea63cdb56
4 changed files with 20 additions and 11 deletions

View File

@@ -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 + ")");
}

View File

@@ -1000,7 +1000,8 @@ function isRandomMAC(mac)
return input;
}
// Empty array
if (input === '[]' || input === '') {
// if (input === '[]' || input === '') {
if (input === '[]') {
return [];
}
// handle integer

View File

@@ -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)

View File

@@ -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: