Add startup config editor.

This commit is contained in:
chriz
2026-01-26 20:40:30 +01:00
parent 17b428a603
commit b5c249995f
5 changed files with 74 additions and 28 deletions
-1
View File
@@ -1 +0,0 @@
../config.txt
+2 -1
View File
@@ -49,7 +49,8 @@ async function fetchCmdLog() {
console.log("CMD-Log: ", response);
const t = await response.text();
return t;
} catch(error) {
} catch(err) {
console.error("Error: ", err);
return "";
}
}
+5
View File
@@ -24,6 +24,11 @@
<br/><br/>
When updating the above settings, remember to point your browser to the new IP afterwards:<br/>
<input style="width:40%;" class="action" id="ip_sub" onclick="ipSub();" type="button" value="Update Settings"><br/>
<br/>
<div class="lcol"> <label for="ip">Startup configuration:</label></div>
<textarea id="config_display" rows="8" cols="60"></textarea>
<br/>
<input style="width:40%;" class="action" id="clear_config" onclick="clearConfig();" type="button" value="Clear Config">
<br/><br/>
Save all current settings to Flash:<br/>
<input style="width:40%;" class="action" id="flash_sub" onclick="flashSave();" type="button" value="Save Settings to Flash">
+32 -10
View File
@@ -43,16 +43,27 @@ async function sendConfig(c) {
}
async function flashSave() {
fetchConfig().then((s) => {
parseConf(s);
fetchCmdLog().then((s) => {
parseConf(s);
var body = "";
for (const x of configuration) { body = body + x + "\n"; }
console.log("CONFIGURATION to save: ", body);
sendConfig(body);
});
});
var configContent = document.getElementById("config_display").value;
console.log("CONFIGURATION to save: ", configContent);
sendConfig(configContent);
}
function clearConfig() {
document.getElementById("config_display").value = "";
// Validate and populate with current IP settings
for (let i=0; i<3; i++) {
if (!checkIp(document.getElementById(ips[i]).value))
return;
}
var configLines = "";
for (let i=0; i<3; i++){
var cmd = ips[i]+' '+document.getElementById(ips[i]).value;
configLines += cmd + "\n";
}
document.getElementById("config_display").value = configLines;
}
function fetchIP() {
@@ -65,6 +76,17 @@ function fetchIP() {
document.getElementById("netmask").value=s.ip_netmask;
document.getElementById("gw").value=s.ip_gateway;
clearInterval(systemInterval);
// Fetch and populate the config textbox
fetchConfig().then((configText) => {
let fullConfig = configText;
// Fetch and append cmd_log
return fetchCmdLog().then((cmdLogText) => {
if (cmdLogText) {
fullConfig = fullConfig + cmdLogText;
}
document.getElementById("config_display").value = fullConfig;
});
});
}
}
xhttp.open("GET", `/information.json`, true);