Add balzor UI.

pull/16861/head
maliming 2 years ago
parent 7dc370b697
commit c91f2c90fe
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4

@ -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; }
}
}

@ -5,7 +5,9 @@ using Microsoft.Extensions.Localization;
using Volo.Abp.Features;
using Volo.Abp.MultiTenancy;
using Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement.EmailSettingGroup;
using Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement.TimeZoneSettingGroup;
using Volo.Abp.SettingManagement.Localization;
using Volo.Abp.Timing;
namespace Volo.Abp.SettingManagement.Blazor.Settings;
@ -26,6 +28,17 @@ public class EmailingPageContributor : ISettingComponentContributor
typeof(EmailSettingGroupViewComponent)
)
);
if (context.ServiceProvider.GetRequiredService<IClock>().SupportsMultipleTimezone)
{
context.Groups.Add(
new SettingComponentGroup(
"Volo.Abp.TimeZone",
l["Menu:TimeZone"],
typeof(TimeZoneSettingGroupViewComponent)
)
);
}
}
public async Task<bool> CheckPermissionsAsync(SettingComponentCreationContext context)

@ -29,7 +29,7 @@ public class EmailingPageContributor : SettingPageContributorBase
)
);
if (!context.ServiceProvider.GetRequiredService<IClock>().SupportsMultipleTimezone)
if (context.ServiceProvider.GetRequiredService<IClock>().SupportsMultipleTimezone)
{
context.Groups.Add(
new SettingPageGroup(

Loading…
Cancel
Save