Skip to content

Commit

Permalink
feat: add styled error message and input handlers to login form
Browse files Browse the repository at this point in the history
  • Loading branch information
thebracket committed Feb 26, 2025
1 parent ce0a0fc commit 05a3ed0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/rust/lqosd/src/node_manager/js_build/src/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,27 @@ $("#btnLogin").on('click', () => {
url: "/doLogin",
data: JSON.stringify(login),
contentType: 'application/json',
beforeSend: () => {
$("#loginError").removeClass("show").addClass("d-none");
},
success: () => {
window.location.href = "/index.html";
},
error: () => {
alert("Login Incorrect");
$("#loginError").removeClass("d-none").addClass("show");
}
})
});

// Add keypress handler for Enter key
$('#username, #password').on('keypress', function(e) {
if (e.which === 13) { // 13 is Enter key code
if (e.which === 13) {
e.preventDefault();
$('#btnLogin').click();
}
});

// Hide error when typing
$('#username, #password').on('input', function() {
$("#loginError").fadeOut();
});
7 changes: 6 additions & 1 deletion src/rust/lqosd/src/node_manager/static2/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ <h5 class="card-title">Login</h5>
</div>
</div>

<div id="loginError" class="alert alert-danger d-none mt-3">
<i class="fas fa-exclamation-triangle me-2"></i>
Login failed. You can manage users via the <code>lqusers</code> CLI tool on the LibreQoS server.
</div>

<script src="login.js"></script>

<footer class="justify-content-center">
Expand All @@ -48,4 +53,4 @@ <h5 class="card-title">Login</h5>

<script src="vendor/bootstrap.bundle.min.js"></script>
</body>
</html>
</html>

0 comments on commit 05a3ed0

Please sign in to comment.