mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-05-24 16:32:20 -04:00
Reset page back to 1 when search term changes in admin (#705)
This commit is contained in:
committed by
Leendert de Borst
parent
75385c4b5d
commit
505a2445eb
@@ -76,6 +76,7 @@ else
|
||||
private int TotalRecords { get; set; }
|
||||
|
||||
private string _searchTerm = string.Empty;
|
||||
private string _lastSearchTerm = string.Empty;
|
||||
private string SearchTerm
|
||||
{
|
||||
get => _searchTerm;
|
||||
@@ -135,7 +136,24 @@ else
|
||||
|
||||
if (!string.IsNullOrEmpty(SearchTerm))
|
||||
{
|
||||
query = query.Where(x => EF.Functions.Like(x.Username.ToLower(), "%" + SearchTerm.ToLower() + "%"));
|
||||
// Reset page number back to 1 if the search term has changed.
|
||||
if (SearchTerm != _lastSearchTerm)
|
||||
{
|
||||
CurrentPage = 1;
|
||||
}
|
||||
_lastSearchTerm = SearchTerm;
|
||||
|
||||
// If the search term starts with "client:", we search for the client header.
|
||||
if (SearchTerm.StartsWith("client:", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var clientSearchTerm = SearchTerm.Substring(7).ToLower();
|
||||
query = query.Where(x => EF.Functions.Like((x.Client ?? string.Empty).ToLower(), "%" + clientSearchTerm + "%"));
|
||||
}
|
||||
else
|
||||
{
|
||||
query = query.Where(x => EF.Functions.Like((x.Username ?? string.Empty).ToLower(), "%" + SearchTerm.ToLower() + "%") ||
|
||||
EF.Functions.Like((x.IpAddress ?? string.Empty).ToLower(), "%" + SearchTerm.ToLower() + "%"));
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(SelectedEventType))
|
||||
|
||||
@@ -91,6 +91,7 @@ else
|
||||
private int TotalRecords { get; set; }
|
||||
|
||||
private string _searchTerm = string.Empty;
|
||||
private string _lastSearchTerm = string.Empty;
|
||||
private string SearchTerm
|
||||
{
|
||||
get => _searchTerm;
|
||||
@@ -154,6 +155,13 @@ else
|
||||
|
||||
if (!string.IsNullOrEmpty(SearchTerm))
|
||||
{
|
||||
// Reset page number back to 1 if the search term has changed.
|
||||
if (SearchTerm != _lastSearchTerm)
|
||||
{
|
||||
CurrentPage = 1;
|
||||
}
|
||||
_lastSearchTerm = SearchTerm;
|
||||
|
||||
query = query.Where(x => EF.Functions.Like(x.Application.ToLower(), "%" + SearchTerm.ToLower() + "%") ||
|
||||
EF.Functions.Like(x.Message.ToLower(), "%" + SearchTerm.ToLower() + "%") ||
|
||||
EF.Functions.Like(x.Level.ToLower(), "%" + SearchTerm.ToLower() + "%"));
|
||||
|
||||
@@ -72,6 +72,7 @@ else
|
||||
private int TotalRecords { get; set; }
|
||||
|
||||
private string _searchTerm = string.Empty;
|
||||
private string _lastSearchTerm = string.Empty;
|
||||
private string SearchTerm
|
||||
{
|
||||
get => _searchTerm;
|
||||
@@ -117,6 +118,13 @@ else
|
||||
|
||||
if (SearchTerm.Length > 0)
|
||||
{
|
||||
// Reset page number back to 1 if the search term has changed.
|
||||
if (SearchTerm != _lastSearchTerm)
|
||||
{
|
||||
CurrentPage = 1;
|
||||
}
|
||||
_lastSearchTerm = SearchTerm;
|
||||
|
||||
query = query.Where(x => EF.Functions.Like(x.UserName!.ToLower(), "%" + SearchTerm.ToLower() + "%"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user