Skip to content

Commit 135f13f

Browse files
fix(ui): properly handle boolean json responses
1 parent a995e57 commit 135f13f

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

src_assets/common/assets/web/apps.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ <h4>{{ $t('apps.env_vars_about') }}</h4>
441441
);
442442
if (resp) {
443443
fetch("./api/apps/" + id, { method: "DELETE" }).then((r) => {
444-
if (r.status == 200) document.location.reload();
444+
if (r.status === 200) document.location.reload();
445445
});
446446
}
447447
},
@@ -557,7 +557,7 @@ <h4>{{ $t('apps.env_vars_about') }}</h4>
557557
method: "POST",
558558
body: JSON.stringify(this.editForm),
559559
}).then((r) => {
560-
if (r.status == 200) document.location.reload();
560+
if (r.status === 200) document.location.reload();
561561
});
562562
},
563563
},

src_assets/common/assets/web/password.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ <h4>{{ $t('password.new_creds') }}</h4>
9494
method: "POST",
9595
body: JSON.stringify(this.passwordData),
9696
}).then((r) => {
97-
if (r.status == 200) {
97+
if (r.status === 200) {
9898
r.json().then((rj) => {
99-
if (rj.status.toString() === "true") {
100-
this.success = true;
99+
this.success = rj.status;
100+
if (this.success === true) {
101101
setTimeout(() => {
102102
document.location.reload();
103103
}, 5000);

src_assets/common/assets/web/pin.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ <h1 class="my-4 text-center">{{ $t('pin.pin_pairing') }}</h1>
4242
fetch("./api/pin", {method: "POST", body: b})
4343
.then((response) => response.json())
4444
.then((response) => {
45-
if (response.status.toString().toLowerCase() === "true") {
45+
if (response.status === true) {
4646
document.querySelector(
4747
"#status"
4848
).innerHTML = `<div class="alert alert-success" role="alert">${this.i18n.t('pin.pair_success')}</div>`;

src_assets/common/assets/web/troubleshooting.html

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,14 @@ <h2 id="unpair" class="text-center me-auto">{{ $t('troubleshooting.unpair_title'
120120
</div>
121121
<ul id="client-list" class="list-group list-group-flush list-group-item-light" v-if="clients && clients.length > 0">
122122
<div v-for="client in clients" class="list-group-item d-flex">
123-
<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>
123+
<div class="p-2 flex-grow-1">{{ client.name !== "" ? client.name : $t('troubleshooting.unpair_single_unknown') }}</div>
124+
<div class="me-2 ms-auto btn btn-danger" @click="unpairSingle(client.uuid)"><i class="fas fa-trash"></i></div>
124125
</div>
125126
</ul>
126127
<ul v-else class="list-group list-group-flush list-group-item-light">
127128
<div class="list-group-item p-3 text-center"><em>{{ $t('troubleshooting.unpair_single_no_devices') }}</em></div>
128129
</ul>
129-
130+
130131
</div>
131132
<!-- Logs -->
132133
<div class="card p-2 my-4">
@@ -176,7 +177,7 @@ <h2 id="logs">{{ $t('troubleshooting.logs') }}</h2>
176177
actualLogs() {
177178
if (!this.logFilter) return this.logs;
178179
let lines = this.logs.split("\n");
179-
lines = lines.filter(x => x.indexOf(this.logFilter) != -1);
180+
lines = lines.filter(x => x.indexOf(this.logFilter) !== -1);
180181
return lines.join("\n");
181182
}
182183
},
@@ -210,7 +211,7 @@ <h2 id="logs">{{ $t('troubleshooting.logs') }}</h2>
210211
.then((r) => r.json())
211212
.then((r) => {
212213
this.closeAppPressed = false;
213-
this.closeAppStatus = r.status.toString() === "true";
214+
this.closeAppStatus = r.status;
214215
setTimeout(() => {
215216
this.closeAppStatus = null;
216217
}, 5000);
@@ -222,7 +223,7 @@ <h2 id="logs">{{ $t('troubleshooting.logs') }}</h2>
222223
.then((r) => r.json())
223224
.then((r) => {
224225
this.unpairAllPressed = false;
225-
this.unpairAllStatus = r.status.toString() === "true";
226+
this.unpairAllStatus = r.status;
226227
setTimeout(() => {
227228
this.unpairAllStatus = null;
228229
}, 5000);
@@ -240,9 +241,9 @@ <h2 id="logs">{{ $t('troubleshooting.logs') }}</h2>
240241
.then((response) => response.json())
241242
.then((response) => {
242243
const clientList = document.querySelector("#client-list");
243-
if (response.status === 'true' && response.named_certs && response.named_certs.length) {
244+
if (response.status === true && response.named_certs && response.named_certs.length) {
244245
this.clients = response.named_certs.sort((a, b) => {
245-
return (a.name.toLowerCase() > b.name.toLowerCase() || a.name == "" ? 1 : -1)
246+
return (a.name.toLowerCase() > b.name.toLowerCase() || a.name === "" ? 1 : -1)
246247
});
247248
} else {
248249
this.clients = [];
@@ -270,7 +271,7 @@ <h2 id="logs">{{ $t('troubleshooting.logs') }}</h2>
270271
.then((r) => r.json())
271272
.then((r) => {
272273
this.ddResetPressed = false;
273-
this.ddResetStatus = r.status.toString() === "true";
274+
this.ddResetStatus = r.status;
274275
setTimeout(() => {
275276
this.ddResetStatus = null;
276277
}, 5000);

src_assets/common/assets/web/welcome.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ <h1 class="mb-0">
8181
body: JSON.stringify(this.passwordData),
8282
}).then((r) => {
8383
this.loading = false;
84-
if (r.status == 200) {
84+
if (r.status === 200) {
8585
r.json().then((rj) => {
86-
if (rj.status.toString() === "true") {
87-
this.success = true;
86+
this.success = rj.status;
87+
if (this.success === true) {
8888
setTimeout(() => {
8989
document.location.reload();
9090
}, 5000);

0 commit comments

Comments
 (0)