Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): could not submit pin due to localization updates #2324

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions src_assets/common/assets/web/pin.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<h1 class="my-4">{{ $t('pin.pin_pairing') }}</h1>
<form action="" class="form d-flex flex-column align-items-center" id="form">
<div class="card flex-column d-flex p-4 mb-4">
<input type="text" pattern="\d*" placeholder="PIN" id="pin-input" class="form-control my-4" />
<input type="text" pattern="\d*" placeholder="PIN" id="pin-input" class="form-control my-4" />
<button class="btn btn-primary">{{ $t('pin.send') }}</button>
</div>
<div class="alert alert-warning">
Expand All @@ -23,7 +23,7 @@ <h1 class="my-4">{{ $t('pin.pin_pairing') }}</h1>
</body>

<script type="module">
import {createApp} from 'vue'
import { createApp } from 'vue'
import i18n from './locale.js'
import Navbar from './Navbar.vue'

Expand All @@ -37,26 +37,27 @@ <h1 class="my-4">{{ $t('pin.pin_pairing') }}</h1>
i18n().then(i18n => {
app.use(i18n);
app.mount('#app');
});

document.querySelector("#form").addEventListener("submit", (e) => {
e.preventDefault();
let pin = document.querySelector("#pin-input").value;
document.querySelector("#status").innerHTML = "";
let b = JSON.stringify({ pin: pin });
fetch("/api/pin", { method: "POST", body: b })
.then((response) => response.json())
.then((response) => {
if (response.status.toString().toLowerCase() === "true") {
document.querySelector(
"#status"
).innerHTML = `<div class="alert alert-success" role="alert">$t('pin.pair_success')</div>`;
document.querySelector("#pin-input").value = "";
} else {
document.querySelector(
"#status"
).innerHTML = `<div class="alert alert-danger" role="alert">$t('pin.pair_failure')</div>`;
}
});
// this must be after mounting the app
document.querySelector("#form").addEventListener("submit", (e) => {
e.preventDefault();
let pin = document.querySelector("#pin-input").value;
document.querySelector("#status").innerHTML = "";
let b = JSON.stringify({ pin: pin });
fetch("/api/pin", { method: "POST", body: b })
.then((response) => response.json())
.then((response) => {
if (response.status.toString().toLowerCase() === "true") {
document.querySelector(
"#status"
).innerHTML = `<div class="alert alert-success" role="alert">${i18n.global.t('pin.pair_success')}</div>`;
document.querySelector("#pin-input").value = "";
} else {
document.querySelector(
"#status"
).innerHTML = `<div class="alert alert-danger" role="alert">${i18n.global.t('pin.pair_failure')}</div>`;
}
});
});
});
</script>
Loading