fix(ui): properly handle boolean json responses (#3626)

This commit is contained in:
ReenigneArcher
2025-02-02 12:34:02 -05:00
committed by GitHub
parent a995e578fa
commit 6efc687036
5 changed files with 18 additions and 17 deletions
+2 -2
View File
@@ -441,7 +441,7 @@
); );
if (resp) { if (resp) {
fetch("./api/apps/" + id, { method: "DELETE" }).then((r) => { fetch("./api/apps/" + id, { method: "DELETE" }).then((r) => {
if (r.status == 200) document.location.reload(); if (r.status === 200) document.location.reload();
}); });
} }
}, },
@@ -557,7 +557,7 @@
method: "POST", method: "POST",
body: JSON.stringify(this.editForm), body: JSON.stringify(this.editForm),
}).then((r) => { }).then((r) => {
if (r.status == 200) document.location.reload(); if (r.status === 200) document.location.reload();
}); });
}, },
}, },
+3 -3
View File
@@ -94,10 +94,10 @@
method: "POST", method: "POST",
body: JSON.stringify(this.passwordData), body: JSON.stringify(this.passwordData),
}).then((r) => { }).then((r) => {
if (r.status == 200) { if (r.status === 200) {
r.json().then((rj) => { r.json().then((rj) => {
if (rj.status.toString() === "true") { this.success = rj.status;
this.success = true; if (this.success === true) {
setTimeout(() => { setTimeout(() => {
document.location.reload(); document.location.reload();
}, 5000); }, 5000);
+1 -1
View File
@@ -42,7 +42,7 @@
fetch("./api/pin", {method: "POST", body: b}) fetch("./api/pin", {method: "POST", body: b})
.then((response) => response.json()) .then((response) => response.json())
.then((response) => { .then((response) => {
if (response.status.toString().toLowerCase() === "true") { if (response.status === true) {
document.querySelector( document.querySelector(
"#status" "#status"
).innerHTML = `<div class="alert alert-success" role="alert">${this.i18n.t('pin.pair_success')}</div>`; ).innerHTML = `<div class="alert alert-success" role="alert">${this.i18n.t('pin.pair_success')}</div>`;
@@ -120,13 +120,14 @@
</div> </div>
<ul id="client-list" class="list-group list-group-flush list-group-item-light" v-if="clients && clients.length > 0"> <ul id="client-list" class="list-group list-group-flush list-group-item-light" v-if="clients && clients.length > 0">
<div v-for="client in clients" class="list-group-item d-flex"> <div v-for="client in clients" class="list-group-item d-flex">
<div class="p-2 flex-grow-1">{{client.name != "" ? client.name : $t('troubleshooting.unpair_single_unknown')}}</div><div class="me-2 ms-auto btn btn-danger" @click="unpairSingle(client.uuid)"><i class="fas fa-trash"></i></div> <div class="p-2 flex-grow-1">{{ client.name !== "" ? client.name : $t('troubleshooting.unpair_single_unknown') }}</div>
<div class="me-2 ms-auto btn btn-danger" @click="unpairSingle(client.uuid)"><i class="fas fa-trash"></i></div>
</div> </div>
</ul> </ul>
<ul v-else class="list-group list-group-flush list-group-item-light"> <ul v-else class="list-group list-group-flush list-group-item-light">
<div class="list-group-item p-3 text-center"><em>{{ $t('troubleshooting.unpair_single_no_devices') }}</em></div> <div class="list-group-item p-3 text-center"><em>{{ $t('troubleshooting.unpair_single_no_devices') }}</em></div>
</ul> </ul>
</div> </div>
<!-- Logs --> <!-- Logs -->
<div class="card p-2 my-4"> <div class="card p-2 my-4">
@@ -176,7 +177,7 @@
actualLogs() { actualLogs() {
if (!this.logFilter) return this.logs; if (!this.logFilter) return this.logs;
let lines = this.logs.split("\n"); let lines = this.logs.split("\n");
lines = lines.filter(x => x.indexOf(this.logFilter) != -1); lines = lines.filter(x => x.indexOf(this.logFilter) !== -1);
return lines.join("\n"); return lines.join("\n");
} }
}, },
@@ -210,7 +211,7 @@
.then((r) => r.json()) .then((r) => r.json())
.then((r) => { .then((r) => {
this.closeAppPressed = false; this.closeAppPressed = false;
this.closeAppStatus = r.status.toString() === "true"; this.closeAppStatus = r.status;
setTimeout(() => { setTimeout(() => {
this.closeAppStatus = null; this.closeAppStatus = null;
}, 5000); }, 5000);
@@ -222,7 +223,7 @@
.then((r) => r.json()) .then((r) => r.json())
.then((r) => { .then((r) => {
this.unpairAllPressed = false; this.unpairAllPressed = false;
this.unpairAllStatus = r.status.toString() === "true"; this.unpairAllStatus = r.status;
setTimeout(() => { setTimeout(() => {
this.unpairAllStatus = null; this.unpairAllStatus = null;
}, 5000); }, 5000);
@@ -240,9 +241,9 @@
.then((response) => response.json()) .then((response) => response.json())
.then((response) => { .then((response) => {
const clientList = document.querySelector("#client-list"); const clientList = document.querySelector("#client-list");
if (response.status === 'true' && response.named_certs && response.named_certs.length) { if (response.status === true && response.named_certs && response.named_certs.length) {
this.clients = response.named_certs.sort((a, b) => { this.clients = response.named_certs.sort((a, b) => {
return (a.name.toLowerCase() > b.name.toLowerCase() || a.name == "" ? 1 : -1) return (a.name.toLowerCase() > b.name.toLowerCase() || a.name === "" ? 1 : -1)
}); });
} else { } else {
this.clients = []; this.clients = [];
@@ -270,7 +271,7 @@
.then((r) => r.json()) .then((r) => r.json())
.then((r) => { .then((r) => {
this.ddResetPressed = false; this.ddResetPressed = false;
this.ddResetStatus = r.status.toString() === "true"; this.ddResetStatus = r.status;
setTimeout(() => { setTimeout(() => {
this.ddResetStatus = null; this.ddResetStatus = null;
}, 5000); }, 5000);
+3 -3
View File
@@ -81,10 +81,10 @@
body: JSON.stringify(this.passwordData), body: JSON.stringify(this.passwordData),
}).then((r) => { }).then((r) => {
this.loading = false; this.loading = false;
if (r.status == 200) { if (r.status === 200) {
r.json().then((rj) => { r.json().then((rj) => {
if (rj.status.toString() === "true") { this.success = rj.status;
this.success = true; if (this.success === true) {
setTimeout(() => { setTimeout(() => {
document.location.reload(); document.location.reload();
}, 5000); }, 5000);