Save configuration to preferences in NVS

This commit is contained in:
2026-02-02 18:43:39 +01:00
parent 59cbc64b08
commit 26dced7cee
9 changed files with 274 additions and 148 deletions

View File

@@ -198,7 +198,7 @@
checkers.checkPort=function(v,allValues,def){
let parsed=parseInt(v);
if (isNaN(parsed)) return "must be a number";
if (parsed <1 || parsed >= 65536) return "port must be in the range 1..65536";
if (parsed <1 || parsed >= 65535) return "port must be in the range 1..65535";
}
checkers.checkSystemName=function(v) {
//2...32 characters for ssid
@@ -293,6 +293,7 @@
let url = apiPrefix + "/api/setconfig"
let body = "_hash=" + encodeURIComponent(pass) + "&";
let allValues = getAllConfigs();
console.log(allValues);
if (!allValues) return;
for (let name in allValues) {
if (name == 'adminPassword') {
@@ -303,7 +304,6 @@
fetch(url, {
method: 'POST',
headers: {
//'Content-Type': 'application/octet-stream' //we must lie here
'Content-Type': 'application/x-www-form-urlencoded'
},
body: body
@@ -323,6 +323,7 @@
alert("unable to set config: " + status.status);
}
})
.catch(err => console.error(err));
})
.catch(function (e) { alert(e); })
}
@@ -633,6 +634,9 @@
el = addEl('input', clazz, frame);
if (configItem.readOnly) el.setAttribute('disabled', true);
el.setAttribute('name', configItem.name)
if (configItem.type === 'string') {
// TODO limit length
}
if (configItem.type === 'password') {
el.setAttribute('type', 'password');
let vis = addEl('span', 'icon-eye icon', frame);