From 77df5d114510b5d7e731287f0ca5840354003caf Mon Sep 17 00:00:00 2001 From: sven-n Date: Wed, 15 Jul 2026 22:34:30 +0200 Subject: [PATCH] Merge pull request #828 from Rhefew/feature/admin-account-search feat(admin): add account & character search to accounts page (cherry picked from commit 75a435d7d3ac424f32a271c5275eac102881a80a) --- src/Web/AdminPanel/Pages/Accounts.razor | 11 ++++++- src/Web/Shared/Services/AccountService.cs | 40 +++++++++++++++++++++-- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/Web/AdminPanel/Pages/Accounts.razor b/src/Web/AdminPanel/Pages/Accounts.razor index 1b1d677..81ab10a 100644 --- a/src/Web/AdminPanel/Pages/Accounts.razor +++ b/src/Web/AdminPanel/Pages/Accounts.razor @@ -1,4 +1,4 @@ -@page "/accounts" +@page "/accounts" @using MUnique.OpenMU.DataModel @using MUnique.OpenMU.DataModel.Entities; @using MUnique.OpenMU.Persistence; @@ -21,6 +21,15 @@ @typeof(Account).GetPropertyCaption(nameof(Account.EMail)) @Resources.Action + + +
+ + +
+ + +
@item.LoginName @item.State.GetEnumCaption() diff --git a/src/Web/Shared/Services/AccountService.cs b/src/Web/Shared/Services/AccountService.cs index e54f372..a4e5be9 100644 --- a/src/Web/Shared/Services/AccountService.cs +++ b/src/Web/Shared/Services/AccountService.cs @@ -1,4 +1,4 @@ -// +// // Licensed under the MIT License. See LICENSE file in the project root for full license information. // @@ -31,6 +31,25 @@ public class AccountService : IDataService, ISupportDataChangedNotifica this._modalService = modalService; } + private string _searchFilter = string.Empty; + + /// + /// Gets or sets the search filter query. + /// + public string SearchFilter + { + get => this._searchFilter; + set + { + var newValue = value ?? string.Empty; + if (this._searchFilter != newValue) + { + this._searchFilter = newValue; + this.RaiseDataChanged(); + } + } + } + /// public event EventHandler? DataChanged; @@ -45,7 +64,24 @@ public class AccountService : IDataService, ISupportDataChangedNotifica try { var playerContext = (IPlayerContext)await this._dataSource.GetContextAsync().ConfigureAwait(false); - return (await playerContext.GetAccountsOrderedByLoginNameAsync(offset, count).ConfigureAwait(false)).ToList(); + var filter = this.SearchFilter.Trim(); + if (string.IsNullOrWhiteSpace(filter)) + { + return (await playerContext.GetAccountsOrderedByLoginNameAsync(offset, count).ConfigureAwait(false)).ToList(); + } + + var allAccounts = await playerContext.GetAsync().ConfigureAwait(false); + var results = allAccounts.Where(account => + (account.LoginName != null && account.LoginName.Contains(filter, StringComparison.InvariantCultureIgnoreCase)) + || account.Characters.Any(c => c.Name != null && c.Name.Contains(filter, StringComparison.InvariantCultureIgnoreCase)) + ).ToList(); + + if (offset >= results.Count) + { + return results.Take(count).ToList(); + } + + return results.Skip(offset).Take(count).ToList(); } catch {