mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-05-03 22:02:23 +03:00
Add search functionality
Set search bar visible on clients page. Search looks in name, email and ip fields for matches, case insensitive.
This commit is contained in:
parent
705e49bb81
commit
34415d1944
1 changed files with 24 additions and 2 deletions
|
@ -250,6 +250,28 @@ Wireguard Clients
|
||||||
populateClientList();
|
populateClientList();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// show search bar and override :contains to be case-insensitive
|
||||||
|
$(document).ready(function () {
|
||||||
|
$("#search-form").show();
|
||||||
|
jQuery.expr[':'].contains = function(a, i, m) {
|
||||||
|
return jQuery(a).text().toUpperCase()
|
||||||
|
.indexOf(m[3].toUpperCase()) >= 0;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
||||||
|
// hide all clients and display only the ones that meet the search criteria (name, email, IP)
|
||||||
|
$('#search-input').keyup(function () {
|
||||||
|
var query = $(this).val();
|
||||||
|
$('.col-lg-4').hide();
|
||||||
|
$(".info-box-text").each(function() {
|
||||||
|
if($(this).children('i.fa-user').length > 0 || $(this).children('i.fa-envelope').length > 0)
|
||||||
|
{
|
||||||
|
$(this).filter(':contains("' + query + '")').parent().parent().parent().show();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$(".badge-secondary").filter(':contains("' + query + '")').parent().parent().parent().show();
|
||||||
|
})
|
||||||
|
|
||||||
// modal_pause_client modal event
|
// modal_pause_client modal event
|
||||||
$("#modal_pause_client").on('show.bs.modal', function (event) {
|
$("#modal_pause_client").on('show.bs.modal', function (event) {
|
||||||
const button = $(event.relatedTarget);
|
const button = $(event.relatedTarget);
|
||||||
|
|
Loading…
Add table
Reference in a new issue