mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Add startup config editor.
This commit is contained in:
@@ -1 +0,0 @@
|
||||
../config.txt
|
||||
+2
-1
@@ -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 "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user