5 changed files with 132 additions and 9 deletions
@ -0,0 +1,20 @@ |
|||||
|
@using Volo.Abp.SettingManagement.Localization |
||||
|
@inherits Volo.Abp.AspNetCore.Components.AbpComponentBase |
||||
|
@inject AbpBlazorMessageLocalizerHelper<AbpSettingManagementResource> LH |
||||
|
|
||||
|
<Form Layout="@FormLayout.Vertical" Model="@TimezoneSettings"> |
||||
|
|
||||
|
<FormItem Label="@L["DisplayName:Timezone"]"> |
||||
|
<Select DataSource="@context.TimeZoneItems" |
||||
|
ValueName="@nameof(Volo.Abp.NameValue.Value)" |
||||
|
LabelName="@nameof(Volo.Abp.NameValue.Name)" |
||||
|
@bind-Value="@context.Timezone"> |
||||
|
</Select> |
||||
|
</FormItem> |
||||
|
|
||||
|
<FormItem WrapperColOffset="8"> |
||||
|
<Button Type="@ButtonType.Primary" HtmlType="submit" OnClick="@UpdateSettingsAsync"> |
||||
|
@L["Submit"] |
||||
|
</Button> |
||||
|
</FormItem> |
||||
|
</Form> |
||||
@ -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<NameValue> TimeZoneItems { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -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<bool> CheckPermissionsAsync(SettingComponentCreationContext context) |
||||
|
{ |
||||
|
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>(); |
||||
|
|
||||
|
return await authorizationService.IsGrantedAsync(SettingManagementPermissions.TimeZone); |
||||
|
} |
||||
|
|
||||
|
public virtual Task ConfigureAsync(SettingComponentCreationContext context) |
||||
|
{ |
||||
|
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpSettingManagementResource>>(); |
||||
|
if (context.ServiceProvider.GetRequiredService<IClock>().SupportsMultipleTimezone) |
||||
|
{ |
||||
|
context.Groups.Add( |
||||
|
new SettingComponentGroup( |
||||
|
"Volo.Abp.TimeZone", |
||||
|
l["Menu:TimeZone"], |
||||
|
typeof(TimeZoneSettingGroupViewComponent) |
||||
|
) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue