Browse Source

Provide Global Features in application configuration.

Resolve #12042
pull/12043/head
maliming 4 years ago
parent
commit
9b0b1a8e6d
No known key found for this signature in database GPG Key ID: 96224957E51C89E
  1. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs
  2. 18
      framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationGlobalFeatureConfigurationDto.cs
  3. 20
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs

2
framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs

@ -17,6 +17,8 @@ public class ApplicationConfigurationDto
public ApplicationFeatureConfigurationDto Features { get; set; }
public ApplicationGlobalFeatureConfigurationDto GlobalFeatures { get; set; }
public MultiTenancyInfoDto MultiTenancy { get; set; }
public CurrentTenantDto CurrentTenant { get; set; }

18
framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationGlobalFeatureConfigurationDto.cs

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations;
[Serializable]
public class ApplicationGlobalFeatureConfigurationDto
{
public HashSet<string> EnabledFeatures { get; set; }
public Dictionary<string, List<string>> ModuleEnabledFeatures { get; set; }
public ApplicationGlobalFeatureConfigurationDto()
{
EnabledFeatures = new HashSet<string>();
ModuleEnabledFeatures = new Dictionary<string, List<string>>();
}
}

20
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs

@ -14,6 +14,7 @@ using Volo.Abp.AspNetCore.Mvc.MultiTenancy;
using Volo.Abp.Authorization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Features;
using Volo.Abp.GlobalFeatures;
using Volo.Abp.Localization;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Settings;
@ -87,6 +88,7 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp
{
Auth = await GetAuthConfigAsync(),
Features = await GetFeaturesConfigAsync(),
GlobalFeatures = await GetGlobalFeaturesConfigAsync(),
Localization = await GetLocalizationConfigAsync(),
CurrentUser = GetCurrentUser(),
Setting = await GetSettingConfigAsync(),
@ -284,6 +286,24 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp
return result;
}
protected virtual Task<ApplicationGlobalFeatureConfigurationDto> GetGlobalFeaturesConfigAsync()
{
var result = new ApplicationGlobalFeatureConfigurationDto();
foreach (var enabledFeatureName in GlobalFeatureManager.Instance.GetEnabledFeatureNames())
{
result.EnabledFeatures.AddIfNotContains(enabledFeatureName);
}
foreach (var module in GlobalFeatureManager.Instance.Modules)
{
result.ModuleEnabledFeatures.AddIfNotContains(new KeyValuePair<string, List<string>>(module.Key, module.Value.GetFeatures().Select(x => x.FeatureName).ToList()));
}
return Task.FromResult(result);
}
protected virtual async Task<TimingDto> GetTimingConfigAsync()
{
var windowsTimeZoneId = await _settingProvider.GetOrNullAsync(TimingSettingNames.TimeZone);

Loading…
Cancel
Save