From cdc4de432a911e9adca1fa9d92dcd9c96a310a0a Mon Sep 17 00:00:00 2001 From: Pavel Vesely Date: Wed, 3 Jun 2020 20:10:52 +0200 Subject: [PATCH 1/2] User manager search persistence --- Oqtane.Client/Modules/Admin/Users/Index.razor | 53 +++++++++++++++---- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/Oqtane.Client/Modules/Admin/Users/Index.razor b/Oqtane.Client/Modules/Admin/Users/Index.razor index cf180d73..4abc278a 100644 --- a/Oqtane.Client/Modules/Admin/Users/Index.razor +++ b/Oqtane.Client/Modules/Admin/Users/Index.razor @@ -2,17 +2,20 @@ @inherits ModuleBase @inject IUserRoleService UserRoleService @inject IUserService UserService +@inject ISettingService SettingService @if (userroles == null) { -

Loading...

+

+ Loading... +

} else {
- +
@@ -23,9 +26,15 @@ else Name - - - + + + + + + + + + @context.User.DisplayName @@ -34,19 +43,24 @@ else @code { private List allroles; private List userroles; - private string search; + private string _search; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; protected override async Task OnInitializedAsync() { allroles = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId); - userroles = allroles.Where(item => item.Role.Name == Constants.RegisteredRole).ToList(); + await LoadSettingsAsync(); + userroles = Search(_search); } - private void OnSearch() + private List Search(string search) { - userroles = allroles + if (string.IsNullOrEmpty(_search)) + { + return allroles.Where(item => item.Role.Name == Constants.RegisteredRole).ToList(); + } + return allroles .Where(item => item.Role.Name == Constants.RegisteredRole && ( item.User.Username.Contains(search, StringComparison.OrdinalIgnoreCase) || @@ -57,6 +71,11 @@ else .ToList(); } + private async Task OnSearch() + { + userroles = Search(_search); + await UpdateSettingsAsync(); + } private async Task DeleteUser(UserRole UserRole) { @@ -76,4 +95,20 @@ else AddModuleMessage(ex.Message, MessageType.Error); } } + + private string settingSearch = "AU-search"; + + private async Task LoadSettingsAsync() + { + Dictionary settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId); + _search = SettingService.GetSetting(settings, settingSearch, ""); + } + + private async Task UpdateSettingsAsync() + { + Dictionary settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId); + SettingService.SetSetting(settings, settingSearch, _search); + await SettingService.UpdateUserSettingsAsync(settings, PageState.User.UserId); + } + } From e24c6fc235bfdd74a4f7777009797ef0af58f818 Mon Sep 17 00:00:00 2001 From: Pavel Vesely Date: Wed, 3 Jun 2020 20:13:48 +0200 Subject: [PATCH 2/2] Move module startup install up to allow install middleware --- Oqtane.Server/Startup.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Oqtane.Server/Startup.cs b/Oqtane.Server/Startup.cs index b47cdd4f..183547d2 100644 --- a/Oqtane.Server/Startup.cs +++ b/Oqtane.Server/Startup.cs @@ -222,6 +222,8 @@ namespace Oqtane // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } + // to allow install middleware it should be moved up + app.ConfigureOqtaneAssemblies(env); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseBlazorFrameworkFiles(); @@ -240,7 +242,7 @@ namespace Oqtane endpoints.MapControllers(); endpoints.MapFallbackToPage("/_Host"); }); - app.ConfigureOqtaneAssemblies(env); + } } }