changed at scripts to use atcmd instead

This commit is contained in:
Russel Yasol
2024-07-14 13:01:42 +08:00
parent dfce6c2b4f
commit 0e3497b8f4
3 changed files with 55 additions and 14 deletions

View File

@@ -104,7 +104,7 @@
placeholder="ATI"
aria-describedby="atCommandInput"
x-model="atcmd"
@keydown.enter="sendATCommand()"
@keydown.enter="sendUserATCommand()"
/>
<div id="atCommandInputHelper" class="form-text">
Seperate multiple commands with comma (,).
@@ -116,7 +116,7 @@
<button
class="btn btn-primary me-md-2"
type="button"
@click="sendATCommand()"
@click="sendUserATCommand()"
:disabled="isLoading"
>
Submit
@@ -443,6 +443,30 @@
});
},
sendUserATCommand() {
this.isLoading = true;
const encodedATCmd = encodeURIComponent(this.atcmd);
const url = `/cgi-bin/user_atcommand?atcmd=${encodedATCmd}`;
fetch(url)
.then((res) => {
if (!res.ok) {
throw new Error(`HTTP error! status: ${res.status}`);
}
return res.text();
})
.then((data) => {
this.atCommandResponse = data;
this.isLoading = false;
this.isClean = false;
})
.catch((error) => {
console.error("Error: ", error);
this.showError = true;
this.isLoading = false;
});
},
clearResponses() {
this.atCommandResponse = "";
this.isClean = true;