Skip to content

Commit

Permalink
Merge pull request #650 from LibreQoE/login_enter
Browse files Browse the repository at this point in the history
Improvements to login form and search
  • Loading branch information
rchac authored Feb 26, 2025
2 parents 5c1edc6 + 05a3ed0 commit a88cc7e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
20 changes: 18 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,11 +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) {
e.preventDefault();
$('#btnLogin').click();
}
});

// Hide error when typing
$('#username, #password').on('input', function() {
$("#loginError").fadeOut();
});
10 changes: 9 additions & 1 deletion src/rust/lqosd/src/node_manager/js_build/src/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ function setupSearch() {
const search = $("#txtSearch").val();
doSearch(search);
});

// Add this new key handler for '/' to focus search
$(document).on('keydown', (e) => {
if (e.key === '/' && !$(e.target).is('input, textarea, select')) {
e.preventDefault();
$('#txtSearch').focus();
}
});
}

function setupReload() {
Expand All @@ -95,4 +103,4 @@ initDayNightMode();
initRedact();
getDeviceCounts();
setupSearch();
setupReload();
setupReload();
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 a88cc7e

Please sign in to comment.