added ttl log to console

This commit is contained in:
Russel Yasol
2024-05-10 18:12:26 +08:00
parent faae115732
commit 30937e20ba
3 changed files with 84 additions and 49 deletions

View File

@@ -6,9 +6,9 @@
<title>Simple Admin</title>
<link rel="stylesheet" href="css/styles.css" />
<link rel="stylesheet" href="css/bootstrap.min.css" />
<!-- Logo -->
<link rel="simpleadmin-logo" href="favicon.ico">
<link rel="simpleadmin-logo" href="favicon.ico" />
<!-- Import BootStrap Javascript -->
<script src="js/bootstrap.bundle.min.js"></script>
@@ -101,7 +101,7 @@
placeholder="ATI"
aria-describedby="atCommandInput"
x-model="atcmd"
@keydown.enter = "sendATCommand()"
@keydown.enter="sendATCommand()"
/>
<div id="atCommandInputHelper" class="form-text">
Seperate multiple commands with comma (,).
@@ -554,21 +554,24 @@
case "LTE":
this.atcmd = "AT+QSCAN=1,1";
this.scanStart = true;
this.atCommandResponse = "Scanning all available LTE networks... This might take a while."
this.atCommandResponse =
"Scanning all available LTE networks... This might take a while.";
this.sendATCommand();
this.scanStart = false;
break;
case "NR5G":
this.atcmd = "AT+QSCAN=2,1";
this.scanStart = true;
this.atCommandResponse = "Scanning all available NR5G-SA networks... This might take a while."
this.atCommandResponse =
"Scanning all available NR5G-SA networks... This might take a while.";
this.sendATCommand();
this.scanStart = false;
break;
case "ALL":
this.atcmd = "AT+QSCAN=3,1";
this.scanStart = true;
this.atCommandResponse = "Scanning all available networks... This might take a while."
this.atCommandResponse =
"Scanning all available networks... This might take a while.";
this.sendATCommand();
this.scanStart = false;
break;
@@ -643,29 +646,41 @@
setTTL() {
this.isLoading = true; // Set loading state while updating TTL
const ttlval = this.newTTL;
fetch(
"/cgi-bin/set_ttl?" +
new URLSearchParams({
ttlvalue: this.newTTL,
})
"/cgi-bin/set_ttl?" + new URLSearchParams({ ttlvalue: ttlval })
)
.then((res) => res.json())
.then((res) => res.text())
.then((data) => {
// Once TTL is updated, fetch the updated TTL data
this.fetchTTL();
this.isLoading = false; // Set loading state back to false
// Split the response into JSON and non-JSON parts
const parts = data.trim().split("\n\n");
const nonJsonPart = parts[0];
const jsonPart = parts[1];
// Log the non-JSON part
console.log("Non-JSON response:", nonJsonPart);
// Parse the JSON part
try {
const jsonData = JSON.parse(jsonPart);
console.log("JSON response:", jsonData);
// Handle the JSON data as needed
// ...
// Once TTL is updated, fetch the updated TTL data
this.fetchTTL();
this.isLoading = false; // Set loading state back to false
} catch (error) {
console.error("Error parsing JSON:", error);
this.isLoading = false; // Ensure loading state is properly handled in case of error
}
})
.catch((error) => {
console.error("Error updating TTL: ", error);
this.isLoading = false; // Ensure loading state is properly handled in case of error
});
},
init() {
this.fetchTTL();
this.fetchCurrentSettings();
},
};
}
</script>