mirror of
https://github.com/WGDashboard/WGDashboard.git
synced 2026-08-03 22:42:59 +00:00
0c0bce9755
Adding Vue.js to handle frontend changes, leaving the server only need to response json data. Ditching flask template and hope it can reduce the memory and cpu usage :)
65 lines
2.4 KiB
HTML
65 lines
2.4 KiB
HTML
<html>
|
|
{% with title="Sign In"%}
|
|
{% include "header.html"%}
|
|
{% endwith %}
|
|
<style>
|
|
.login-container-fluid{
|
|
display: flex;
|
|
height: calc( 100% - 240px );
|
|
align-items: center;
|
|
}
|
|
</style>
|
|
<body>
|
|
{% include "navbar.html" %}
|
|
<div id="login"></div>
|
|
<small class="text-muted" style="position: fixed; bottom: 0; width: 100%; text-align: center; margin-bottom: 2rem">Version: {{ version }}</small>
|
|
</body>
|
|
{% include "footer.html" %}
|
|
<script>
|
|
let loginButton = $('button[type="submit"]');
|
|
loginButton.on("click", function(e){
|
|
e.preventDefault();
|
|
let $password = $("#password");
|
|
let $username = $("#username");
|
|
let req = [$password, $username];
|
|
let check = true
|
|
for (let i = 0; i < req.length; i++){
|
|
if ($(req[i]).val().length === 0){
|
|
loginButton.html("Sign In");
|
|
check = false;
|
|
$(req[i]).addClass("is-invalid");
|
|
break;
|
|
}
|
|
}
|
|
if (check){
|
|
$(this).html("Signing In...").attr("disabled", "disabled");
|
|
$.ajax({
|
|
url: "/auth",
|
|
method: "POST",
|
|
headers:{"Content-Type": "application/json"},
|
|
data: JSON.stringify({
|
|
"username": $("#username").val(),
|
|
"password": $("#password").val()
|
|
})
|
|
}).done(function(res){
|
|
if (res.status === true){
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
if (urlParams.get("redirect")){
|
|
if (document.URL.substring(0, 5) == "http:"){
|
|
window.location.replace(`http://${urlParams.get("redirect")}`)
|
|
}else if (document.URL.substring(0, 5) == "https"){
|
|
window.location.replace(`https://${urlParams.get("redirect")}`)
|
|
}
|
|
}else{
|
|
window.location.replace("/");
|
|
}
|
|
}else{
|
|
$(".alert").html(res.msg).removeClass("d-none").fadeIn();
|
|
loginButton.html("Sign In").removeAttr("disabled");
|
|
$("input[required]").addClass("is-invalid");
|
|
}
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
</html> |