mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Add filtering logic for configuration commands
This commit is contained in:
+21
-8
@@ -1,5 +1,5 @@
|
||||
var systemInterval = Number();
|
||||
const ips = ["ip", "nm", "gw"];
|
||||
const ips = ["ip", "netmask", "gw"];
|
||||
|
||||
function checkIp(ip) {
|
||||
const ipv4 = /^(\d{1,3}\.){3}\d{1,3}$/;
|
||||
@@ -27,14 +27,14 @@ async function ipSub() {
|
||||
}
|
||||
}
|
||||
|
||||
async function flashSave() {
|
||||
fetchConfig();
|
||||
fetchCmdLog();
|
||||
return;
|
||||
async function sendConfig(c) {
|
||||
const form = new FormData();
|
||||
form.append("MAX_FILE_SIZE", "4096");
|
||||
form.append("configuration", new Blob([c], {type: "application/octet-stream"}));
|
||||
try {
|
||||
const response = await fetch('/save', {
|
||||
const response = await fetch('/config', {
|
||||
method: 'POST',
|
||||
body: cmd
|
||||
body: form
|
||||
});
|
||||
console.log('Completed!', response);
|
||||
} catch(err) {
|
||||
@@ -42,6 +42,19 @@ 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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function fetchIP() {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function() {
|
||||
@@ -49,7 +62,7 @@ function fetchIP() {
|
||||
const s = JSON.parse(xhttp.responseText);
|
||||
console.log("IP: ", s);
|
||||
document.getElementById("ip").value=s.ip_address;
|
||||
document.getElementById("nm").value=s.ip_netmask;
|
||||
document.getElementById("netmask").value=s.ip_netmask;
|
||||
document.getElementById("gw").value=s.ip_gateway;
|
||||
clearInterval(systemInterval);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user