trying to fix pairing bug for first time setup

dev
Anton Franzluebbers 2022-08-18 17:21:50 -04:00
parent 330113b804
commit 1cb14d82df
1 changed files with 18 additions and 10 deletions

View File

@ -1,4 +1,4 @@
<html> <html lang="en">
<head> <head>
@ -38,6 +38,11 @@
user-select: auto; user-select: auto;
} }
#submit_pairing_code {
cursor: pointer;
user-select: unset;
}
.centered { .centered {
margin: auto; margin: auto;
} }
@ -54,7 +59,7 @@
<div class="card"> <div class="card">
<div class="card-image"> <div class="card-image">
<img src="/static/img/pair_code_screenshot.png" class="img-responsive"> <img src="/static/img/pair_code_screenshot.png" class="img-responsive" alt="Pairing code location">
</div> </div>
<div class="card-header"> <div class="card-header">
<div class="card-title h5">Enter Pairing Code</div> <div class="card-title h5">Enter Pairing Code</div>
@ -64,28 +69,31 @@
You can find the code in the bottom left of your menu tablet in conVRged. You can find the code in the bottom left of your menu tablet in conVRged.
</div> </div>
<div class="card-footer centered"> <div class="card-footer centered">
<input class="btn" type="text" id="pair_code" placeholder="0000"> <form onsubmit="submitCode()">
<button class="btn btn-primary" id="submit_pairing_code">Submit</button> <label for="pair_code"></label><input class="btn" type="text" id="pair_code" placeholder="0000">
<input class="btn btn-primary" id="submit_pairing_code" type="submit" value="Submit"/>
</form>
</div> </div>
</div> </div>
</div> </div>
<script> <script>
let submit_button = document.getElementById('submit_pairing_code'); const pair_code_input = document.getElementById('pair_code');
let pair_code_input = document.getElementById('pair_code');
submit_button.addEventListener('click', () => { function submitCode() {
httpGetAsync('/api/v2/get_device_by_pairing_code/' + pair_code_input.value, (resp) => { fetch('/api/v2/get_device_by_pairing_code/' + pair_code_input.value).then(resp => resp.json()).then(resp => {
console.log(resp); console.log(resp);
let respData = JSON.parse(resp); let respData = JSON.parse(resp);
if (respData['hw_id'] !== '') { if (respData['hw_id'] !== '') {
setCookie('hw_id', respData['hw_id'], 60); setCookie('hw_id', respData['hw_id'], 60);
window.location.href = "/"; window.location.href = "/";
} }
}, (status) => { }).catch(e => {
window.location.href = "/failure"; window.location.href = "/failure";
console.error(e);
}); });
}); }
</script> </script>
</body> </body>