diff --git a/modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/AbpSettingManagementBlazorAntDesignModule.cs b/modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/AbpSettingManagementBlazorAntDesignModule.cs index aee43fe..bab45e2 100644 --- a/modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/AbpSettingManagementBlazorAntDesignModule.cs +++ b/modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/AbpSettingManagementBlazorAntDesignModule.cs @@ -40,6 +40,7 @@ public class AbpSettingManagementBlazorAntDesignModule : AbpModule Configure(options => { options.Contributors.Add(new AntDesignSettingDefultPageContributor()); + options.Contributors.Add(new AntDesignTimeZonePageContributor()); }); } } diff --git a/modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Pages/SettingManagement/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.razor b/modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Pages/SettingManagement/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.razor new file mode 100644 index 0000000..3e0ba69 --- /dev/null +++ b/modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Pages/SettingManagement/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.razor @@ -0,0 +1,20 @@ +@using Volo.Abp.SettingManagement.Localization +@inherits Volo.Abp.AspNetCore.Components.AbpComponentBase +@inject AbpBlazorMessageLocalizerHelper LH + +
+ + + + + + + + +
diff --git a/modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Pages/SettingManagement/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.razor.cs b/modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Pages/SettingManagement/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.razor.cs new file mode 100644 index 0000000..c249bbe --- /dev/null +++ b/modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Pages/SettingManagement/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.razor.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; +using Volo.Abp; +using Volo.Abp.AspNetCore.Components.Web.Configuration; +using Volo.Abp.SettingManagement; +using Volo.Abp.SettingManagement.Localization; + +namespace Lsw.Abp.SettingManagement.Blazor.AntDesignUI.Pages.SettingManagement.TimeZoneSettingGroup; + +public partial class TimeZoneSettingGroupViewComponent +{ + [Inject] + protected ITimeZoneSettingsAppService TimeZoneSettingsAppService { get; set; } + + [Inject] + protected ICurrentApplicationConfigurationCacheResetService CurrentApplicationConfigurationCacheResetService { get; set; } + + protected UpdateTimezoneSettingsViewModel TimezoneSettings = new(); + + public TimeZoneSettingGroupViewComponent() + { + ObjectMapperContext = typeof(AbpSettingManagementBlazorAntDesignModule); + LocalizationResource = typeof(AbpSettingManagementResource); + } + + protected override async Task OnInitializedAsync() + { + try + { + TimezoneSettings.Timezone = await TimeZoneSettingsAppService.GetAsync(); + TimezoneSettings.TimeZoneItems = await TimeZoneSettingsAppService.GetTimezonesAsync(); + } + catch (Exception ex) + { + await HandleErrorAsync(ex); + } + } + + protected virtual async Task UpdateSettingsAsync() + { + try + { + await TimeZoneSettingsAppService.UpdateAsync(TimezoneSettings.Timezone); + await CurrentApplicationConfigurationCacheResetService.ResetAsync(); + await Message.Success(L["SuccessfullySaved"]); + } + catch (Exception ex) + { + await HandleErrorAsync(ex); + } + } + + public class UpdateTimezoneSettingsViewModel + { + public string Timezone { get; set; } + + public List TimeZoneItems { get; set; } + } +} diff --git a/modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Settings/AntDesignTimeZonePageContributor.cs b/modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Settings/AntDesignTimeZonePageContributor.cs new file mode 100644 index 0000000..96a9af9 --- /dev/null +++ b/modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Settings/AntDesignTimeZonePageContributor.cs @@ -0,0 +1,38 @@ +using System.Threading.Tasks; +using Lsw.Abp.SettingManagement.Blazor.AntDesignUI.Pages.SettingManagement.TimeZoneSettingGroup; +using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Localization; +using Volo.Abp.SettingManagement; +using Volo.Abp.SettingManagement.Blazor; +using Volo.Abp.SettingManagement.Localization; +using Volo.Abp.Timing; + +namespace Lsw.Abp.SettingManagement.Blazor.AntDesignUI.Settings; + +public class AntDesignTimeZonePageContributor : ISettingComponentContributor +{ + public virtual async Task CheckPermissionsAsync(SettingComponentCreationContext context) + { + var authorizationService = context.ServiceProvider.GetRequiredService(); + + return await authorizationService.IsGrantedAsync(SettingManagementPermissions.TimeZone); + } + + public virtual Task ConfigureAsync(SettingComponentCreationContext context) + { + var l = context.ServiceProvider.GetRequiredService>(); + if (context.ServiceProvider.GetRequiredService().SupportsMultipleTimezone) + { + context.Groups.Add( + new SettingComponentGroup( + "Volo.Abp.TimeZone", + l["Menu:TimeZone"], + typeof(TimeZoneSettingGroupViewComponent) + ) + ); + } + + return Task.CompletedTask; + } +} diff --git a/samples/BookStore/src/BookStore.BlazorServer/BookStoreBlazorModule.cs b/samples/BookStore/src/BookStore.BlazorServer/BookStoreBlazorModule.cs index 0117330..12959f7 100644 --- a/samples/BookStore/src/BookStore.BlazorServer/BookStoreBlazorModule.cs +++ b/samples/BookStore/src/BookStore.BlazorServer/BookStoreBlazorModule.cs @@ -34,6 +34,7 @@ using Volo.Abp.Swashbuckle; using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation.Urls; using Volo.Abp.VirtualFileSystem; +using Volo.Abp.Timing; namespace BookStore.Blazor; @@ -73,6 +74,8 @@ public class BookStoreBlazorModule : AbpModule var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); + Configure(options => options.Kind = DateTimeKind.Utc); + ConfigureUrls(configuration); ConfigureBundles(); ConfigureAuthentication(context, configuration); @@ -107,15 +110,15 @@ public class BookStoreBlazorModule : AbpModule ); //BLAZOR UI - options.StyleBundles.Configure( - BlazorAntDesignThemeBundles.Styles.Global, - bundle => - { - bundle.AddFiles("/blazor-global-styles.css"); - //You can remove the following line if you don't use Blazor CSS isolation for components - bundle.AddFiles("/BookStore.BlazorServer.styles.css"); - } - ); + options.StyleBundles.Configure( + BlazorAntDesignThemeBundles.Styles.Global, + bundle => + { + bundle.AddFiles("/blazor-global-styles.css"); + //You can remove the following line if you don't use Blazor CSS isolation for components + bundle.AddFiles("/BookStore.BlazorServer.styles.css"); + } + ); }); }