diff --git a/core/scripts/webpanel/assets/js/users.js b/core/scripts/webpanel/assets/js/users.js index d50dee3..7356090 100644 --- a/core/scripts/webpanel/assets/js/users.js +++ b/core/scripts/webpanel/assets/js/users.js @@ -11,10 +11,12 @@ $(function () { const BULK_URI_URL = contentSection.dataset.bulkUriUrl; const USERS_BASE_URL = contentSection.dataset.usersBaseUrl; const GET_USER_URL_TEMPLATE = contentSection.dataset.getUserUrlTemplate; + const SEARCH_USERS_URL = contentSection.dataset.searchUrl; const usernameRegex = /^[a-zA-Z0-9_]+$/; const passwordRegex = /^[a-zA-Z0-9]+$/; let cachedUserData = []; + let searchTimeout = null; function setCookie(name, value, days) { let expires = ""; @@ -65,12 +67,80 @@ $(function () { function validatePassword(inputElement, errorElement) { const password = $(inputElement).val(); - // The password is valid if it's empty (no change) OR it matches the alphanumeric regex. const isValid = password === '' || passwordRegex.test(password); $(errorElement).text(isValid ? "" : "Password can only contain letters and numbers."); $('#editSubmitButton').prop('disabled', !isValid); } + function refreshUserList() { + const query = $("#searchInput").val().trim(); + if (query !== "") { + performSearch(); + } else { + restoreInitialView(); + } + } + + function performSearch() { + const query = $("#searchInput").val().trim(); + const $userTableBody = $("#userTableBody"); + const $paginationContainer = $("#paginationContainer"); + const $userTotalCount = $("#user-total-count"); + + $paginationContainer.hide(); + $userTableBody.css('opacity', 0.5).html('
| Details | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| - - | -{{ loop.index + ((current_page - 1) * limit) }} | -{{ user.username }} | -- {% if user.status == "Online" %} - Online - {% if user.online_count and user.online_count > 0 %} - ({{ user.online_count }}) - {% endif %} - {% elif user.status == "Offline" %} - Offline - {% elif user.status == "On-hold" %} - On-hold - {% elif user.status == "Conflict" %} - Conflict - {% else %} - {{ user.status }} - {% endif %} - | -{{ user.traffic_used }} | -{{ user.expiry_date }} | -{{ user.expiry_days }} | -{{ user.day_usage }} | -- {% if user.enable %} - - {% else %} - - {% endif %} - | -- {% if user.note %} - {{ user.note | truncate(20, True) }} - {% endif %} - | - -- - - - | -- - - - | -- - | -