Skip to content

Commit

Permalink
fix(ui)properly handle boolean json responses
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Feb 2, 2025
1 parent a995e57 commit 172904d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src_assets/common/assets/web/apps.html
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ <h4>{{ $t('apps.env_vars_about') }}</h4>
);
if (resp) {
fetch("./api/apps/" + id, { method: "DELETE" }).then((r) => {
if (r.status == 200) document.location.reload();
if (r.status === 200) document.location.reload();
});
}
},
Expand Down Expand Up @@ -557,7 +557,7 @@ <h4>{{ $t('apps.env_vars_about') }}</h4>
method: "POST",
body: JSON.stringify(this.editForm),
}).then((r) => {
if (r.status == 200) document.location.reload();
if (r.status === 200) document.location.reload();
});
},
},
Expand Down
6 changes: 3 additions & 3 deletions src_assets/common/assets/web/password.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ <h4>{{ $t('password.new_creds') }}</h4>
method: "POST",
body: JSON.stringify(this.passwordData),
}).then((r) => {
if (r.status == 200) {
if (r.status === 200) {
r.json().then((rj) => {
if (rj.status.toString() === "true") {
this.success = true;
this.success = rj.status;
if (this.success === true) {
setTimeout(() => {
document.location.reload();
}, 5000);
Expand Down
2 changes: 1 addition & 1 deletion src_assets/common/assets/web/pin.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h1 class="my-4 text-center">{{ $t('pin.pin_pairing') }}</h1>
fetch("./api/pin", {method: "POST", body: b})
.then((response) => response.json())
.then((response) => {
if (response.status.toString().toLowerCase() === "true") {
if (response.status === true) {
document.querySelector(
"#status"
).innerHTML = `<div class="alert alert-success" role="alert">${this.i18n.t('pin.pair_success')}</div>`;
Expand Down
17 changes: 9 additions & 8 deletions src_assets/common/assets/web/troubleshooting.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,14 @@ <h2 id="unpair" class="text-center me-auto">{{ $t('troubleshooting.unpair_title'
</div>
<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 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>
</ul>
<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>
</ul>

</div>
<!-- Logs -->
<div class="card p-2 my-4">
Expand Down Expand Up @@ -176,7 +177,7 @@ <h2 id="logs">{{ $t('troubleshooting.logs') }}</h2>
actualLogs() {
if (!this.logFilter) return this.logs;
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");
}
},
Expand Down Expand Up @@ -210,7 +211,7 @@ <h2 id="logs">{{ $t('troubleshooting.logs') }}</h2>
.then((r) => r.json())
.then((r) => {
this.closeAppPressed = false;
this.closeAppStatus = r.status.toString() === "true";
this.closeAppStatus = r.status;
setTimeout(() => {
this.closeAppStatus = null;
}, 5000);
Expand All @@ -222,7 +223,7 @@ <h2 id="logs">{{ $t('troubleshooting.logs') }}</h2>
.then((r) => r.json())
.then((r) => {
this.unpairAllPressed = false;
this.unpairAllStatus = r.status.toString() === "true";
this.unpairAllStatus = r.status;
setTimeout(() => {
this.unpairAllStatus = null;
}, 5000);
Expand All @@ -240,9 +241,9 @@ <h2 id="logs">{{ $t('troubleshooting.logs') }}</h2>
.then((response) => response.json())
.then((response) => {
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) => {
return (a.name.toLowerCase() > b.name.toLowerCase() || a.name == "" ? 1 : -1)
return (a.name.toLowerCase() > b.name.toLowerCase() || a.name === "" ? 1 : -1)
});
} else {
this.clients = [];
Expand Down Expand Up @@ -270,7 +271,7 @@ <h2 id="logs">{{ $t('troubleshooting.logs') }}</h2>
.then((r) => r.json())
.then((r) => {
this.ddResetPressed = false;
this.ddResetStatus = r.status.toString() === "true";
this.ddResetStatus = r.status;
setTimeout(() => {
this.ddResetStatus = null;
}, 5000);
Expand Down
6 changes: 3 additions & 3 deletions src_assets/common/assets/web/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ <h1 class="mb-0">
body: JSON.stringify(this.passwordData),
}).then((r) => {
this.loading = false;
if (r.status == 200) {
if (r.status === 200) {
r.json().then((rj) => {
if (rj.status.toString() === "true") {
this.success = true;
this.success = rj.status;
if (this.success === true) {
setTimeout(() => {
document.location.reload();
}, 5000);
Expand Down

0 comments on commit 172904d

Please sign in to comment.