diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/AllowChangingTimeZoneSettingsFeatureSimpleStateChecker.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/AllowChangingTimeZoneSettingsFeatureSimpleStateChecker.cs new file mode 100644 index 0000000000..b6d50f2046 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/AllowChangingTimeZoneSettingsFeatureSimpleStateChecker.cs @@ -0,0 +1,24 @@ +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.Features; +using Volo.Abp.MultiTenancy; +using Volo.Abp.SimpleStateChecking; + +namespace Volo.Abp.SettingManagement; + +public class AllowChangingTimeZoneSettingsFeatureSimpleStateChecker : ISimpleStateChecker +{ + public async Task IsEnabledAsync(SimpleStateCheckerContext context) + { + var currentTenant = context.ServiceProvider.GetRequiredService(); + + if (!currentTenant.IsAvailable) + { + return true; + } + + var featureChecker = context.ServiceProvider.GetRequiredService(); + return await featureChecker.IsEnabledAsync(SettingManagementFeatures.EnableTimeZone); + } +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/ITimeZoneSettingsAppService.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/ITimeZoneSettingsAppService.cs new file mode 100644 index 0000000000..d42387a37e --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/ITimeZoneSettingsAppService.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.Application.Services; + +namespace Volo.Abp.SettingManagement; + +public interface ITimeZoneSettingsAppService : IApplicationService +{ + Task GetAsync(); + + Task> GetTimezonesAsync(); + + Task UpdateAsync(string timezone); +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissionDefinitionProvider.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissionDefinitionProvider.cs index db0b8dd907..6270460623 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissionDefinitionProvider.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissionDefinitionProvider.cs @@ -15,6 +15,9 @@ public class SettingManagementPermissionDefinitionProvider : PermissionDefinitio emailPermission.StateCheckers.Add(new AllowChangingEmailSettingsFeatureSimpleStateChecker()); emailPermission.AddChild(SettingManagementPermissions.EmailingTest, L("Permission:EmailingTest")); + + moduleGroup.AddPermission(SettingManagementPermissions.TimeZone, L("Permission:TimeZone")); + emailPermission.StateCheckers.Add(new AllowChangingTimeZoneSettingsFeatureSimpleStateChecker()); } private static LocalizableString L(string name) diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissions.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissions.cs index 43f0c5a104..5a5d01c52a 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissions.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissions.cs @@ -7,9 +7,11 @@ public class SettingManagementPermissions public const string GroupName = "SettingManagement"; public const string Emailing = GroupName + ".Emailing"; - + public const string EmailingTest = Emailing + ".Test"; + public const string TimeZone = GroupName + ".TimeZone"; + public static string[] GetAll() { return ReflectionHelper.GetPublicConstantsRecursively(typeof(SettingManagementPermissions)); diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/AbpSettingManagementApplicationModule.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/AbpSettingManagementApplicationModule.cs index 0f7b5584d2..6e9c5704de 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/AbpSettingManagementApplicationModule.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/AbpSettingManagementApplicationModule.cs @@ -1,6 +1,7 @@ using Volo.Abp.Application; using Volo.Abp.Emailing; using Volo.Abp.Modularity; +using Volo.Abp.Timing; namespace Volo.Abp.SettingManagement; @@ -8,7 +9,8 @@ namespace Volo.Abp.SettingManagement; typeof(AbpDddApplicationModule), typeof(AbpSettingManagementDomainModule), typeof(AbpSettingManagementApplicationContractsModule), - typeof(AbpEmailingModule) + typeof(AbpEmailingModule), + typeof(AbpTimingModule) )] public class AbpSettingManagementApplicationModule : AbpModule { diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/TimeZoneSettingsAppService.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/TimeZoneSettingsAppService.cs new file mode 100644 index 0000000000..423840284e --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/TimeZoneSettingsAppService.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using TimeZoneConverter; +using Volo.Abp.Features; +using Volo.Abp.MultiTenancy; +using Volo.Abp.Settings; +using Volo.Abp.Timing; + +namespace Volo.Abp.SettingManagement; + +[RequiresFeature(SettingManagementFeatures.EnableTimeZone)] +[Authorize(SettingManagementPermissions.TimeZone)] +public class TimeZoneSettingsAppService : SettingManagementAppServiceBase, ITimeZoneSettingsAppService +{ + protected ISettingManager SettingManager { get; } + protected ISettingProvider SettingProvider { get; } + protected ITimezoneProvider TimezoneProvider { get; } + + public TimeZoneSettingsAppService(ISettingManager settingManager, ISettingProvider settingProvider, ITimezoneProvider timezoneProvider) + { + SettingManager = settingManager; + SettingProvider = settingProvider; + TimezoneProvider = timezoneProvider; + } + + public virtual async Task GetAsync() + { + var timezone = await SettingProvider.GetOrNullAsync(TimingSettingNames.TimeZone); + return timezone ?? "UTC"; + } + + public virtual Task> GetTimezonesAsync() + { + var timezones = TimezoneProvider.GetWindowsTimezones() + .OrderBy(x => x.Name) + .Select(x => new NameValue( $"{x.Name} ({GetTimezoneOffset(TZConvert.GetTimeZoneInfo(x.Name))})", x.Name)) + .ToList(); + + return Task.FromResult(timezones); + } + + protected virtual string GetTimezoneOffset(TimeZoneInfo timeZoneInfo) + { + if (timeZoneInfo.BaseUtcOffset < TimeSpan.Zero) + { + return "-" + timeZoneInfo.BaseUtcOffset.ToString(@"hh\:mm"); + } + + return "+" + timeZoneInfo.BaseUtcOffset.ToString(@"hh\:mm"); + } + + public virtual async Task UpdateAsync(string timezone) + { + if (CurrentTenant.GetMultiTenancySide() == MultiTenancySides.Host) + { + await SettingManager.SetGlobalAsync(TimingSettingNames.TimeZone, timezone); + } + else + { + await SettingManager.SetForCurrentTenantAsync(TimingSettingNames.TimeZone, timezone); + } + } +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/AbpSettingManagementBlazorModule.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/AbpSettingManagementBlazorModule.cs index 533e272198..d8e54353e1 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/AbpSettingManagementBlazorModule.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/AbpSettingManagementBlazorModule.cs @@ -41,6 +41,7 @@ public class AbpSettingManagementBlazorModule : AbpModule Configure(options => { options.Contributors.Add(new EmailingPageContributor()); + options.Contributors.Add(new TimeZonePageContributor()); }); Configure(options => diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.razor b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.razor new file mode 100644 index 0000000000..cd2d7cb503 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.razor @@ -0,0 +1,27 @@ +@using Volo.Abp.SettingManagement.Localization +@inherits Volo.Abp.AspNetCore.Components.AbpComponentBase +@inject AbpBlazorMessageLocalizerHelper LH + +@if (TimezoneSettings != null) +{ +
+ + + + @L["DisplayName:Timezone"] * + + + + + + + + + +
+} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.razor.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.razor.cs new file mode 100644 index 0000000000..27dc472e1c --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.razor.cs @@ -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 TimeZoneItems { get; set; } + } +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Settings/TimeZonePageContributor.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Settings/TimeZonePageContributor.cs new file mode 100644 index 0000000000..cd1b2dd13a --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Settings/TimeZonePageContributor.cs @@ -0,0 +1,49 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Localization; +using Volo.Abp.Features; +using Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement.TimeZoneSettingGroup; +using Volo.Abp.SettingManagement.Localization; +using Volo.Abp.Timing; + +namespace Volo.Abp.SettingManagement.Blazor.Settings; + +public class TimeZonePageContributor : ISettingComponentContributor +{ + public async Task ConfigureAsync(SettingComponentCreationContext context) + { + await CheckFeatureAsync(context); + + var l = context.ServiceProvider.GetRequiredService>(); + if (context.ServiceProvider.GetRequiredService().SupportsMultipleTimezone) + { + context.Groups.Add( + new SettingComponentGroup( + "Volo.Abp.TimeZone", + l["Menu:TimeZone"], + typeof(TimeZoneSettingGroupViewComponent) + ) + ); + } + } + + public async Task CheckPermissionsAsync(SettingComponentCreationContext context) + { + if (!await CheckFeatureAsync(context)) + { + return false; + } + + var authorizationService = context.ServiceProvider.GetRequiredService(); + + return await authorizationService.IsGrantedAsync(SettingManagementPermissions.TimeZone); + } + + private async Task CheckFeatureAsync(SettingComponentCreationContext context) + { + var featureCheck = context.ServiceProvider.GetRequiredService(); + + return await featureCheck.IsEnabledAsync(SettingManagementFeatures.EnableTimeZone); + } +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/el.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/el.json index 03846bbea2..b2c8048d52 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/el.json +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/el.json @@ -6,6 +6,7 @@ "Permission:SettingManagement": "Διαχείριση ρυθμίσεων", "Permission:Emailing": "Αποστολή email", "Permission:EmailingTest": "Αποστολή δοκιμαστικού email", + "Permission:TimeZone": "Ζώνη ώρας", "SendTestEmail": "Αποστολή δοκιμαστικού email", "SenderEmailAddress": "Διεύθυνση email αποστολέα", "TargetEmailAddress": "Διεύθυνση email παραλήπτη", diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/en.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/en.json index b6de38e979..b2c9bc0b11 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/en.json +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/en.json @@ -6,6 +6,7 @@ "Permission:SettingManagement": "Setting Management", "Permission:Emailing": "Emailing", "Permission:EmailingTest": "Emailing test", + "Permission:TimeZone": "Time zone", "SendTestEmail": "Send test email", "SenderEmailAddress": "Sender email address", "TargetEmailAddress": "Target email address", @@ -16,6 +17,8 @@ "SuccessfullySent": "Successfully sent", "Send": "Send", "Menu:Emailing": "Emailing", + "Menu:TimeZone": "Time zone", + "DisplayName:Timezone": "Time zone", "SmtpHost": "Host", "SmtpPort": "Port", "SmtpUserName": "User name", @@ -29,6 +32,7 @@ "Feature:SettingManagementEnable": "Enable setting management", "Feature:SettingManagementEnableDescription": "Enable setting management system in the application.", "Feature:AllowChangingEmailSettings": "Allow changing email settings.", - "Feature:AllowChangingEmailSettingsDescription": "Allow changing email settings." + "Feature:AllowChangingEmailSettingsDescription": "Allow changing email settings.", + "Feature:EnableTimeZone": "Enable time zone" } } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/fi.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/fi.json index 2e0c11d63f..dfb712bae3 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/fi.json +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/fi.json @@ -6,6 +6,7 @@ "Permission:SettingManagement": "Asetusten hallinta", "Permission:Emailing": "Sähköpostiviestit", "Permission:EmailingTest": "Sähköpostitesti", + "Permission:TimeZone": "Aikavyöhyke", "SendTestEmail": "Lähetä testisähköposti", "SenderEmailAddress": "Lähettäjän sähköpostiosoite", "TargetEmailAddress": "Kohdesähköpostiosoite", @@ -31,4 +32,4 @@ "Feature:AllowChangingEmailSettings": "Salli sähköpostiasetusten muuttaminen.", "Feature:AllowChangingEmailSettingsDescription": "Salli sähköpostiasetusten muuttaminen." } -} \ No newline at end of file +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/hr.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/hr.json index cd45f2339d..8b779c491e 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/hr.json +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/hr.json @@ -7,6 +7,7 @@ "Permission:Emailing": "Slanje e-poštom", "Permission:EmailingTest": "Test slanja e-pošte", "SendTestEmail": "Po�alji probnu e-poštu", + "Permission:TimeZone": "Vremenska zona", "SenderEmailAddress": "Adresa e-pošte pošiljatelja", "TargetEmailAddress": "Ciljana adresa e-pošte", "Subject": "Predmet", diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/hu.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/hu.json index 878ca22fc3..a0eaac826a 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/hu.json +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/hu.json @@ -6,6 +6,7 @@ "Permission:SettingManagement": "Beállításkezelés", "Permission:Emailing": "E-mailezés", "Permission:EmailingTest": "E-mail teszt", + "Permission:TimeZone": "Időzóna", "SendTestEmail": "Küldj teszt e-mailt", "SenderEmailAddress": "Feladó e-mail címe", "TargetEmailAddress": "Cél e-mail cím", @@ -31,4 +32,4 @@ "Feature:AllowChangingEmailSettings": "Az e-mail beállítások módosításának engedélyezése.", "Feature:AllowChangingEmailSettingsDescription": "Az e-mail beállítások módosításának engedélyezése." } -} \ No newline at end of file +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/pt-BR.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/pt-BR.json index b609a6e762..3bbae86055 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/pt-BR.json +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/pt-BR.json @@ -6,6 +6,7 @@ "Permission:SettingManagement": "Gestão de Cenários", "Permission:Emailing": "Enviando por e-mail", "Permission:EmailingTest": "Teste de e-mail", + "Permission:TimeZone": "Fuso horário", "SendTestEmail": "Enviar e-mail de teste", "SenderEmailAddress": "E-mail remetente", "TargetEmailAddress": "E-mail destinatário", diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/tr.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/tr.json index f050801fe5..4db9d13242 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/tr.json +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/tr.json @@ -6,6 +6,7 @@ "Permission:SettingManagement": "Ayarlar yönetimi", "Permission:Emailing": "Email", "Permission:EmailingTest": "Email testi", + "Permission:TimeZone": "Zaman dilimi", "SendTestEmail": "Test emaili gönder", "SenderEmailAddress": "Gönderen email adresi", "TargetEmailAddress": "Hedef email adresi", @@ -16,6 +17,8 @@ "SuccessfullySent": "Başarıyla gönderildi", "Send": "Gönder", "Menu:Emailing": "Email", + "Menu:TimeZone": "Zaman dilimi", + "DisplayName:Timezone": "Zaman dilimi", "SmtpHost": "Sunucu", "SmtpPort": "Port", "SmtpUserName": "Kullanıcı adı", @@ -29,6 +32,7 @@ "Feature:SettingManagementEnable": "Ayar yönetimini etkinleştir", "Feature:SettingManagementEnableDescription": "Uygulamada ayar yönetim sistemini etkinleştirin.", "Feature:AllowChangingEmailSettings": "E-posta ayarlarını değiştirmeye izin verin.", - "Feature:AllowChangingEmailSettingsDescription": "E-posta ayarlarını değiştirmeye izin verin." + "Feature:AllowChangingEmailSettingsDescription": "E-posta ayarlarını değiştirmeye izin verin.", + "Feature:EnableTimeZone": "Zaman dilimini etkinleştir" } } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/zh-Hans.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/zh-Hans.json index 4399439eed..d988cd639f 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/zh-Hans.json +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/zh-Hans.json @@ -6,6 +6,7 @@ "Permission:SettingManagement": "设置管理", "Permission:Emailing": "邮件", "Permission:EmailingTest": "邮件测试", + "Permission:TimeZone": "时区", "SendTestEmail": "发送测试邮件", "SenderEmailAddress": "发件人邮箱地址", "TargetEmailAddress": "收件人邮箱地址", @@ -16,6 +17,8 @@ "SuccessfullySent": "发送成功", "Send": "发送", "Menu:Emailing": "邮件", + "Menu:TimeZone": "时区", + "DisplayName:Timezone": "时区", "SmtpHost": "主机", "SmtpPort": "端口", "SmtpUserName": "用户名", @@ -29,6 +32,7 @@ "Feature:SettingManagementEnable": "启用设置管理", "Feature:SettingManagementEnableDescription": "在应用程序中启用设置管理系统.", "Feature:AllowChangingEmailSettings": "允许更改邮件设置.", - "Feature:AllowChangingEmailSettingsDescription": "允许更改邮件设置." + "Feature:AllowChangingEmailSettingsDescription": "允许更改邮件设置.", + "Feature:EnableTimeZone": "启用时区", } } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/zh-Hant.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/zh-Hant.json index b0a071732d..87de5451b8 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/zh-Hant.json +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/zh-Hant.json @@ -6,6 +6,7 @@ "Permission:SettingManagement": "設定管理", "Permission:Emailing": "信箱", "Permission:EmailingTest": "郵件測試", + "Permission:TimeZone": "時區", "SendTestEmail": "發送測試郵件", "SenderEmailAddress": "發送者電子郵件地址", "TargetEmailAddress": "目標電子郵件地址", @@ -16,6 +17,8 @@ "SuccessfullySent": "成功發送", "Send": "發送", "Menu:Emailing": "信箱", + "Menu:TimeZone": "時區", + "DisplayName:Timezone": "時區", "SmtpHost": "主機", "SmtpPort": "Port", "SmtpUserName": "帳號", @@ -29,6 +32,7 @@ "Feature:SettingManagementEnable": "啟用設定管理", "Feature:SettingManagementEnableDescription": "在應用程序中啟用設定管理系統.", "Feature:AllowChangingEmailSettings": "允許更改電子郵件設置。", - "Feature:AllowChangingEmailSettingsDescription": "允許更改電子郵件設置。" + "Feature:AllowChangingEmailSettingsDescription": "允許更改電子郵件設置。", + "Feature:EnableTimeZone": "啟用時區" } } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingManagementFeatureDefinitionProvider.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingManagementFeatureDefinitionProvider.cs index 6800ce4e2b..b0f6abb06e 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingManagementFeatureDefinitionProvider.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingManagementFeatureDefinitionProvider.cs @@ -27,6 +27,14 @@ public class SettingManagementFeatureDefinitionProvider : FeatureDefinitionProvi null, new ToggleStringValueType(), isAvailableToHost: false); + + settingEnableFeature.CreateChild( + SettingManagementFeatures.EnableTimeZone, + "false", + L("Feature:EnableTimeZone"), + null, + new ToggleStringValueType(), + isAvailableToHost: true); } private static LocalizableString L(string name) diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingManagementFeatures.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingManagementFeatures.cs index 3769852bed..dfb525baa2 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingManagementFeatures.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingManagementFeatures.cs @@ -7,4 +7,6 @@ public class SettingManagementFeatures public const string Enable = GroupName + ".Enable"; public const string AllowChangingEmailSettings = GroupName + ".AllowChangingEmailSettings"; + + public const string EnableTimeZone = GroupName + ".EnableTimeZone"; } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/Volo/Abp/SettingManagement/EmailSettingsClientProxy.Generated.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/Volo/Abp/SettingManagement/EmailSettingsClientProxy.Generated.cs new file mode 100644 index 0000000000..664062e15b --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/Volo/Abp/SettingManagement/EmailSettingsClientProxy.Generated.cs @@ -0,0 +1,40 @@ +// This file is automatically generated by ABP framework to use MVC Controllers from CSharp +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Http.Client; +using Volo.Abp.Http.Client.ClientProxying; +using Volo.Abp.Http.Modeling; +using Volo.Abp.SettingManagement; + +// ReSharper disable once CheckNamespace +namespace Volo.Abp.SettingManagement; + +[Dependency(ReplaceServices = true)] +[ExposeServices(typeof(IEmailSettingsAppService), typeof(EmailSettingsClientProxy))] +public partial class EmailSettingsClientProxy : ClientProxyBase, IEmailSettingsAppService +{ + public virtual async Task GetAsync() + { + return await RequestAsync(nameof(GetAsync)); + } + + public virtual async Task UpdateAsync(UpdateEmailSettingsDto input) + { + await RequestAsync(nameof(UpdateAsync), new ClientProxyRequestTypeValue + { + { typeof(UpdateEmailSettingsDto), input } + }); + } + + public virtual async Task SendTestEmailAsync(SendTestEmailInput input) + { + await RequestAsync(nameof(SendTestEmailAsync), new ClientProxyRequestTypeValue + { + { typeof(SendTestEmailInput), input } + }); + } +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/Volo/Abp/SettingManagement/EmailSettingsClientProxy.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/Volo/Abp/SettingManagement/EmailSettingsClientProxy.cs new file mode 100644 index 0000000000..9f08cfbab0 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/Volo/Abp/SettingManagement/EmailSettingsClientProxy.cs @@ -0,0 +1,7 @@ +// This file is part of EmailSettingsClientProxy, you can customize it here +// ReSharper disable once CheckNamespace +namespace Volo.Abp.SettingManagement; + +public partial class EmailSettingsClientProxy +{ +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/Volo/Abp/SettingManagement/TimeZoneSettingsClientProxy.Generated.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/Volo/Abp/SettingManagement/TimeZoneSettingsClientProxy.Generated.cs new file mode 100644 index 0000000000..da35cb7a26 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/Volo/Abp/SettingManagement/TimeZoneSettingsClientProxy.Generated.cs @@ -0,0 +1,37 @@ +// This file is automatically generated by ABP framework to use MVC Controllers from CSharp +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Http.Client; +using Volo.Abp.Http.Client.ClientProxying; +using Volo.Abp.Http.Modeling; +using Volo.Abp.SettingManagement; + +// ReSharper disable once CheckNamespace +namespace Volo.Abp.SettingManagement; + +[Dependency(ReplaceServices = true)] +[ExposeServices(typeof(ITimeZoneSettingsAppService), typeof(TimeZoneSettingsClientProxy))] +public partial class TimeZoneSettingsClientProxy : ClientProxyBase, ITimeZoneSettingsAppService +{ + public virtual async Task GetAsync() + { + return await RequestAsync(nameof(GetAsync)); + } + + public virtual async Task> GetTimezonesAsync() + { + return await RequestAsync>(nameof(GetTimezonesAsync)); + } + + public virtual async Task UpdateAsync(string timezone) + { + await RequestAsync(nameof(UpdateAsync), new ClientProxyRequestTypeValue + { + { typeof(string), timezone } + }); + } +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/Volo/Abp/SettingManagement/TimeZoneSettingsClientProxy.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/Volo/Abp/SettingManagement/TimeZoneSettingsClientProxy.cs new file mode 100644 index 0000000000..1b03c78e01 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/Volo/Abp/SettingManagement/TimeZoneSettingsClientProxy.cs @@ -0,0 +1,7 @@ +// This file is part of TimeZoneSettingsClientProxy, you can customize it here +// ReSharper disable once CheckNamespace +namespace Volo.Abp.SettingManagement; + +public partial class TimeZoneSettingsClientProxy +{ +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/settingManagement-generate-proxy.json b/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/settingManagement-generate-proxy.json index 93f29bf3ce..7fe19e9cb9 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/settingManagement-generate-proxy.json +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/settingManagement-generate-proxy.json @@ -8,11 +8,57 @@ "controllerName": "EmailSettings", "controllerGroupName": "EmailSettings", "isRemoteService": true, + "isIntegrationService": false, "apiVersion": null, "type": "Volo.Abp.SettingManagement.EmailSettingsController", "interfaces": [ { - "type": "Volo.Abp.SettingManagement.IEmailSettingsAppService" + "type": "Volo.Abp.SettingManagement.IEmailSettingsAppService", + "name": "IEmailSettingsAppService", + "methods": [ + { + "name": "GetAsync", + "parametersOnMethod": [], + "returnValue": { + "type": "Volo.Abp.SettingManagement.EmailSettingsDto", + "typeSimple": "Volo.Abp.SettingManagement.EmailSettingsDto" + } + }, + { + "name": "UpdateAsync", + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Abp.SettingManagement.UpdateEmailSettingsDto, Volo.Abp.SettingManagement.Application.Contracts", + "type": "Volo.Abp.SettingManagement.UpdateEmailSettingsDto", + "typeSimple": "Volo.Abp.SettingManagement.UpdateEmailSettingsDto", + "isOptional": false, + "defaultValue": null + } + ], + "returnValue": { + "type": "System.Void", + "typeSimple": "System.Void" + } + }, + { + "name": "SendTestEmailAsync", + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Abp.SettingManagement.SendTestEmailInput, Volo.Abp.SettingManagement.Application.Contracts", + "type": "Volo.Abp.SettingManagement.SendTestEmailInput", + "typeSimple": "Volo.Abp.SettingManagement.SendTestEmailInput", + "isOptional": false, + "defaultValue": null + } + ], + "returnValue": { + "type": "System.Void", + "typeSimple": "System.Void" + } + } + ] } ], "actions": { @@ -106,6 +152,124 @@ "implementFrom": "Volo.Abp.SettingManagement.IEmailSettingsAppService" } } + }, + "Volo.Abp.SettingManagement.TimeZoneSettingsController": { + "controllerName": "TimeZoneSettings", + "controllerGroupName": "TimeZoneSettings", + "isRemoteService": true, + "isIntegrationService": false, + "apiVersion": null, + "type": "Volo.Abp.SettingManagement.TimeZoneSettingsController", + "interfaces": [ + { + "type": "Volo.Abp.SettingManagement.ITimeZoneSettingsAppService", + "name": "ITimeZoneSettingsAppService", + "methods": [ + { + "name": "GetAsync", + "parametersOnMethod": [], + "returnValue": { + "type": "System.String", + "typeSimple": "string" + } + }, + { + "name": "GetTimezonesAsync", + "parametersOnMethod": [], + "returnValue": { + "type": "System.Collections.Generic.List", + "typeSimple": "[Volo.Abp.NameValue]" + } + }, + { + "name": "UpdateAsync", + "parametersOnMethod": [ + { + "name": "timezone", + "typeAsString": "System.String, System.Private.CoreLib", + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null + } + ], + "returnValue": { + "type": "System.Void", + "typeSimple": "System.Void" + } + } + ] + } + ], + "actions": { + "GetAsync": { + "uniqueName": "GetAsync", + "name": "GetAsync", + "httpMethod": "GET", + "url": "api/setting-management/timezone", + "supportedVersions": [], + "parametersOnMethod": [], + "parameters": [], + "returnValue": { + "type": "System.String", + "typeSimple": "string" + }, + "allowAnonymous": null, + "implementFrom": "Volo.Abp.SettingManagement.ITimeZoneSettingsAppService" + }, + "GetTimezonesAsync": { + "uniqueName": "GetTimezonesAsync", + "name": "GetTimezonesAsync", + "httpMethod": "GET", + "url": "api/setting-management/timezone", + "supportedVersions": [], + "parametersOnMethod": [], + "parameters": [], + "returnValue": { + "type": "System.Collections.Generic.List", + "typeSimple": "[Volo.Abp.NameValue]" + }, + "allowAnonymous": null, + "implementFrom": "Volo.Abp.SettingManagement.ITimeZoneSettingsAppService" + }, + "UpdateAsyncByTimezone": { + "uniqueName": "UpdateAsyncByTimezone", + "name": "UpdateAsync", + "httpMethod": "POST", + "url": "api/setting-management/timezone", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "timezone", + "typeAsString": "System.String, System.Private.CoreLib", + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "timezone", + "name": "timezone", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "" + } + ], + "returnValue": { + "type": "System.Void", + "typeSimple": "System.Void" + }, + "allowAnonymous": null, + "implementFrom": "Volo.Abp.SettingManagement.ITimeZoneSettingsAppService" + } + } } } } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi/Volo/Abp/SettingManagement/TimeZoneSettingsController.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi/Volo/Abp/SettingManagement/TimeZoneSettingsController.cs new file mode 100644 index 0000000000..3a33db3462 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi/Volo/Abp/SettingManagement/TimeZoneSettingsController.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc; + +namespace Volo.Abp.SettingManagement; + +[RemoteService(Name = SettingManagementRemoteServiceConsts.RemoteServiceName)] +[Area(SettingManagementRemoteServiceConsts.ModuleName)] +[Route("api/setting-management/timezone")] +public class TimeZoneSettingsController : AbpControllerBase, ITimeZoneSettingsAppService +{ + private readonly ITimeZoneSettingsAppService _timeZoneSettingsAppService; + + public TimeZoneSettingsController(ITimeZoneSettingsAppService timeZoneSettingsAppService) + { + _timeZoneSettingsAppService = timeZoneSettingsAppService; + } + + [HttpGet] + public Task GetAsync() + { + return _timeZoneSettingsAppService.GetAsync(); + } + + [HttpGet] + public Task> GetTimezonesAsync() + { + return _timeZoneSettingsAppService.GetTimezonesAsync(); + } + + [HttpPost] + public Task UpdateAsync(string timezone) + { + return _timeZoneSettingsAppService.UpdateAsync(timezone); + } +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs index b544d4a7bf..b5d3df17ad 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs @@ -45,6 +45,7 @@ public class AbpSettingManagementWebModule : AbpModule Configure(options => { options.Contributors.Add(new EmailingPageContributor()); + options.Contributors.Add(new TimeZonePageContributor()); }); Configure(options => diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/TimeZoneSettingGroup/Default.cshtml b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/TimeZoneSettingGroup/Default.cshtml new file mode 100644 index 0000000000..99469b61a7 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/TimeZoneSettingGroup/Default.cshtml @@ -0,0 +1,21 @@ +@using Microsoft.AspNetCore.Mvc.Localization +@using Volo.Abp.SettingManagement.Localization +@inject IHtmlLocalizer L +@model Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.TimeZoneSettingGroup.TimeZoneSettingGroupViewComponent.UpdateTimezoneSettingsViewModel + + + +
+ + +
+ +
+
+ + @L["Save"] + +
+
+
+
diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/TimeZoneSettingGroup/Default.js b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/TimeZoneSettingGroup/Default.js new file mode 100644 index 0000000000..d6e720dbe3 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/TimeZoneSettingGroup/Default.js @@ -0,0 +1,15 @@ +(function ($) { + $(function () { + + var l = abp.localization.getResource('AbpSettingManagement'); + + $("#TimeZoneSettingsForm").on('submit', function (event) { + event.preventDefault(); + + volo.abp.settingManagement.timeZoneSettings.update($("#Timezone").val()).then(function (result) { + $(document).trigger("AbpSettingSaved"); + }); + + }); + }); +})(jQuery); diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.cs new file mode 100644 index 0000000000..eaf24ab2f2 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Rendering; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Auditing; +using Volo.Abp.Timing.Localization.Resources.AbpTiming; + +namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.TimeZoneSettingGroup; + +public class TimeZoneSettingGroupViewComponent : AbpViewComponent +{ + protected ITimeZoneSettingsAppService TimeZoneSettingsAppService { get; } + + public TimeZoneSettingGroupViewComponent(ITimeZoneSettingsAppService timeZoneSettingsAppService) + { + ObjectMapperContext = typeof(AbpSettingManagementWebModule); + TimeZoneSettingsAppService = timeZoneSettingsAppService; + } + + public virtual async Task InvokeAsync() + { + var timezone = await TimeZoneSettingsAppService.GetAsync(); + var timezones = await TimeZoneSettingsAppService.GetTimezonesAsync(); + var model = new UpdateTimezoneSettingsViewModel() + { + Timezone = timezone, + TimeZoneItems = new List() + }; + model.TimeZoneItems.AddRange(timezones.Select(x => new SelectListItem(x.Name, x.Value)).ToList()); + return View("~/Pages/SettingManagement/Components/TimeZoneSettingGroup/Default.cshtml", model); + } + + public class UpdateTimezoneSettingsViewModel + { + public string Timezone { get; set; } + + public List TimeZoneItems { get; set; } + } +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Settings/EmailingPageContributor.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Settings/EmailingPageContributor.cs index bedb993480..5096404a11 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Settings/EmailingPageContributor.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Settings/EmailingPageContributor.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; using Volo.Abp.SettingManagement.Localization; diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Settings/TimeZonePageContributor.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Settings/TimeZonePageContributor.cs new file mode 100644 index 0000000000..a7a7674b08 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Settings/TimeZonePageContributor.cs @@ -0,0 +1,36 @@ +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Localization; +using Volo.Abp.SettingManagement.Localization; +using Volo.Abp.SettingManagement.Web.Pages.SettingManagement; +using Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup; +using Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.TimeZoneSettingGroup; +using Volo.Abp.Timing; + +namespace Volo.Abp.SettingManagement.Web.Settings; + +public class TimeZonePageContributor : SettingPageContributorBase +{ + public TimeZonePageContributor() + { + RequiredFeatures(SettingManagementFeatures.EnableTimeZone); + } + + public override Task ConfigureAsync(SettingPageCreationContext context) + { + var l = context.ServiceProvider.GetRequiredService>(); + + if (context.ServiceProvider.GetRequiredService().SupportsMultipleTimezone) + { + context.Groups.Add( + new SettingPageGroup( + "Volo.Abp.TimeZone", + l["Menu:TimeZone"], + typeof(TimeZoneSettingGroupViewComponent) + ) + ); + } + + return Task.CompletedTask; + } +} \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.csproj b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.csproj index f4f03b3706..8f9c81e7d0 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.csproj +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.csproj @@ -41,8 +41,4 @@ - - - - diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/wwwroot/client-proxies/settingManagement-proxy.js b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/wwwroot/client-proxies/settingManagement-proxy.js index 2c227c39a9..d49a500606 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/wwwroot/client-proxies/settingManagement-proxy.js +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/wwwroot/client-proxies/settingManagement-proxy.js @@ -38,6 +38,36 @@ })(); + // controller volo.abp.settingManagement.timeZoneSettings + + (function(){ + + abp.utils.createNamespace(window, 'volo.abp.settingManagement.timeZoneSettings'); + + volo.abp.settingManagement.timeZoneSettings.get = function(ajaxParams) { + return abp.ajax($.extend(true, { + url: abp.appPath + 'api/setting-management/timezone', + type: 'GET' + }, { dataType: 'text' }, ajaxParams)); + }; + + volo.abp.settingManagement.timeZoneSettings.getTimezones = function(ajaxParams) { + return abp.ajax($.extend(true, { + url: abp.appPath + 'api/setting-management/timezone', + type: 'GET' + }, ajaxParams)); + }; + + volo.abp.settingManagement.timeZoneSettings.update = function(timezone, ajaxParams) { + return abp.ajax($.extend(true, { + url: abp.appPath + 'api/setting-management/timezone' + abp.utils.buildQueryString([{ name: 'timezone', value: timezone }]) + '', + type: 'POST', + dataType: null + }, ajaxParams)); + }; + + })(); + })();