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/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..baa24e1a59 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/TimeZoneSettingsAppService.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +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)] +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.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..6cbafb8bcc 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 @@ -16,6 +16,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 +31,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/tr.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/tr.json index f050801fe5..668fb4c0e9 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 @@ -16,6 +16,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 +31,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..c96ad492bb 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 @@ -16,6 +16,8 @@ "SuccessfullySent": "发送成功", "Send": "发送", "Menu:Emailing": "邮件", + "Menu:TimeZone": "时区", + "DisplayName:Timezone": "时区", "SmtpHost": "主机", "SmtpPort": "端口", "SmtpUserName": "用户名", @@ -29,6 +31,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..5f18516463 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 @@ -16,6 +16,8 @@ "SuccessfullySent": "成功發送", "Send": "發送", "Menu:Emailing": "信箱", + "Menu:TimeZone": "時區", + "DisplayName:Timezone": "時區", "SmtpHost": "主機", "SmtpPort": "Port", "SmtpUserName": "帳號", @@ -29,6 +31,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/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..027d16fa6b --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/TimeZoneSettingGroup/Default.cshtml @@ -0,0 +1,22 @@ +@using Microsoft.AspNetCore.Mvc.Localization +@using Microsoft.AspNetCore.Mvc.TagHelpers +@using Volo.Abp.SettingManagement.Localization +@inject IHtmlLocalizer L +@model Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup.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..64ffcae2a3 --- /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.EmailSettingGroup; + +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..baad83aaf5 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,9 +1,12 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; +using Microsoft.Extensions.Options; using Volo.Abp.SettingManagement.Localization; using Volo.Abp.SettingManagement.Web.Pages.SettingManagement; using Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup; +using Volo.Abp.Timing; namespace Volo.Abp.SettingManagement.Web.Settings; @@ -25,6 +28,18 @@ public class EmailingPageContributor : SettingPageContributorBase typeof(EmailSettingGroupViewComponent) ) ); + + if (!context.ServiceProvider.GetRequiredService().SupportsMultipleTimezone) + { + context.Groups.Add( + new SettingPageGroup( + "Volo.Abp.TimeZone", + l["Menu:TimeZone"], + typeof(TimeZoneSettingGroupViewComponent) + ) + ); + } + return Task.CompletedTask; } } 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)); + }; + + })(); + })();