New apporach: Make startup config independent.

This commit is contained in:
chriz
2026-02-12 14:17:22 +01:00
parent 670e0f02ec
commit ea37126e87
4 changed files with 45 additions and 14 deletions
-1
View File
@@ -1043,7 +1043,6 @@ void execute_config(void) __banked
config_done: config_done:
// Start saving commands to cmd_history // Start saving commands to cmd_history
save_cmd = 1; save_cmd = 1;
clear_command_history();
} }
void clear_command_history(void) __banked void clear_command_history(void) __banked
+12 -6
View File
@@ -21,18 +21,24 @@
<div class="lcol"> <label for="gw">Gateway:</label></div> <div class="lcol"> <label for="gw">Gateway:</label></div>
<div class="rcol"><input id="gw" class="ip" type="text" minlength="7" maxlength="15" size="15"/></div> <div class="rcol"><input id="gw" class="ip" type="text" minlength="7" maxlength="15" size="15"/></div>
</div> </div>
<br/><br/> <br/>
When updating the above settings, remember to point your browser to the new IP afterwards:<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/> <input style="width:40%;" class="action" id="ip_sub" onclick="ipSub();" type="button" value="Update Settings"><br/>
<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">
<br/><br/>
<hr style="width:50%;margin-left:0;"/>
<h1>Advanced Settings</h1>
<div class="lcol"> <label for="ip">Startup configuration:</label></div> <div class="lcol"> <label for="ip">Startup configuration:</label></div>
<textarea id="config_display" rows="8" cols="60"></textarea> <textarea id="config_display" rows="8" cols="60"></textarea>
<br/> <br/>
<input style="width:40%;" class="action" id="clear_config" onclick="clearConfig();" type="button" value="Clear Config"> <input style="width:40%;" class="action" id="clear_config" onclick="clearConfig();" type="button" value="Clear Startup Config">
<br/><br/> <br/>
Save all current settings to Flash:<br/> <input style="width:40%;" class="action" id="flash_startup_sub" onclick="flashStartupSave();" type="button" value="Save Startup Settings to Flash">
<input style="width:40%;" class="action" id="flash_sub" onclick="flashSave();" type="button" value="Save Settings to Flash"> <br/>
<input style="width:40%;" class="action" id="switch_reset" onclick="resetSwitch();" type="button" value="Reset Switch">
</div> </div>
<script src="/config.js"></script> <script src="/config.js"></script>
<script src="/system.js"></script> <script src="/system.js"></script>
+30 -7
View File
@@ -42,7 +42,21 @@ async function sendConfig(c) {
} }
} }
async function flashSave() { 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);
});
});
}
async function flashStartupSave() {
var configContent = document.getElementById("config_display").value; var configContent = document.getElementById("config_display").value;
console.log("CONFIGURATION to save: ", configContent); console.log("CONFIGURATION to save: ", configContent);
sendConfig(configContent); sendConfig(configContent);
@@ -86,19 +100,28 @@ function fetchIP() {
fetchConfig().then((configText) => { fetchConfig().then((configText) => {
let fullConfig = configText; let fullConfig = configText;
// Fetch and append cmd_log // Fetch and append cmd_log
return fetchCmdLog().then((cmdLogText) => { //return fetchCmdLog().then((cmdLogText) => {
if (cmdLogText) { // if (cmdLogText) {
fullConfig = fullConfig + cmdLogText; // fullConfig = fullConfig + cmdLogText;
} // }
document.getElementById("config_display").value = fullConfig; document.getElementById("config_display").value = fullConfig;
}); });
}); };
} }
}
xhttp.open("GET", `/information.json`, true); xhttp.open("GET", `/information.json`, true);
xhttp.send(); xhttp.send();
} }
function resetSwitch() {
if (!confirm('Are you sure you want to reset the switch?')) {
return;
}
fetch('/reset', { method: 'GET' }).catch(() => {});
setTimeout(() => {
alert('Switch is resetting. Please wait and refresh the page.');
}, 3000);
}
window.addEventListener("load", function() { window.addEventListener("load", function() {
systemInterval = setInterval(fetchIP, 1000); systemInterval = setInterval(fetchIP, 1000);
}); });
+3
View File
@@ -601,6 +601,9 @@ void httpd_appcall(void)
} else if (is_word(q, "/cmd_log_clear")) { } else if (is_word(q, "/cmd_log_clear")) {
clear_command_history(); clear_command_history();
send_mtu(); // dummy response send_mtu(); // dummy response
} else if (is_word(q, "/reset")) {
uip_close();
reset_chip();
} else { } else {
send_not_found(); send_not_found();
} }