mirror of https://github.com/abpframework/abp.git
4 changed files with 106 additions and 1 deletions
@ -0,0 +1,27 @@ |
|||
@using Volo.Abp.SettingManagement.Localization |
|||
@inherits Volo.Abp.AspNetCore.Components.AbpComponentBase |
|||
@inject AbpBlazorMessageLocalizerHelper<AbpSettingManagementResource> LH |
|||
|
|||
@if (TimezoneSettings != null) |
|||
{ |
|||
<Form> |
|||
<Row> |
|||
<Column> |
|||
<Field> |
|||
<FieldLabel>@L["DisplayName:Timezone"] *</FieldLabel> |
|||
<Select TValue="string" SelectedValue="TimezoneSettings.Timezone" SelectedValueChanged="OnSelectedValueChangedAsync"> |
|||
@foreach (var item in TimezoneSettings.TimeZoneItems) |
|||
{ |
|||
<SelectItem Value="item.Value">@item.Name</SelectItem> |
|||
} |
|||
</Select> |
|||
</Field> |
|||
</Column> |
|||
</Row> |
|||
<Row> |
|||
<Column> |
|||
<SubmitButton Clicked="@UpdateSettingsAsync"/> |
|||
</Column> |
|||
</Row> |
|||
</Form> |
|||
} |
|||
@ -0,0 +1,65 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Volo.Abp.AspNetCore.Components.Messages; |
|||
using Volo.Abp.AspNetCore.Components.Web.Configuration; |
|||
using Volo.Abp.SettingManagement.Localization; |
|||
|
|||
namespace Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement.TimeZoneSettingGroup; |
|||
|
|||
public partial class TimeZoneSettingGroupViewComponent |
|||
{ |
|||
[Inject] |
|||
protected ITimeZoneSettingsAppService TimeZoneSettingsAppService { get; set; } |
|||
|
|||
[Inject] |
|||
private ICurrentApplicationConfigurationCacheResetService CurrentApplicationConfigurationCacheResetService { get; set; } |
|||
|
|||
[Inject] |
|||
protected IUiMessageService UiMessageService { get; set; } |
|||
|
|||
protected UpdateTimezoneSettingsViewModel TimezoneSettings; |
|||
|
|||
public TimeZoneSettingGroupViewComponent() |
|||
{ |
|||
ObjectMapperContext = typeof(AbpSettingManagementBlazorModule); |
|||
LocalizationResource = typeof(AbpSettingManagementResource); |
|||
} |
|||
|
|||
protected async override Task OnInitializedAsync() |
|||
{ |
|||
TimezoneSettings = new UpdateTimezoneSettingsViewModel() |
|||
{ |
|||
Timezone = await TimeZoneSettingsAppService.GetAsync(), |
|||
TimeZoneItems = await TimeZoneSettingsAppService.GetTimezonesAsync() |
|||
}; |
|||
} |
|||
|
|||
protected virtual async Task OnSelectedValueChangedAsync(string timezone) |
|||
{ |
|||
TimezoneSettings.Timezone = timezone; |
|||
await InvokeAsync(StateHasChanged); |
|||
} |
|||
|
|||
protected virtual async Task UpdateSettingsAsync() |
|||
{ |
|||
try |
|||
{ |
|||
await TimeZoneSettingsAppService.UpdateAsync(TimezoneSettings.Timezone); |
|||
await CurrentApplicationConfigurationCacheResetService.ResetAsync(); |
|||
await UiMessageService.Success(L["SuccessfullySaved"]); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
await HandleErrorAsync(ex); |
|||
} |
|||
} |
|||
|
|||
public class UpdateTimezoneSettingsViewModel |
|||
{ |
|||
public string Timezone { get; set; } |
|||
|
|||
public List<NameValue> TimeZoneItems { get; set; } |
|||
} |
|||
} |
|||
Loading…
Reference in new issue