|
|
|
@ -1,12 +1,15 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; |
|
|
|
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; |
|
|
|
using Volo.Abp.EventBus.Local; |
|
|
|
using Volo.Abp.Features; |
|
|
|
using Volo.Abp.Localization; |
|
|
|
using Volo.Abp.Validation.StringValues; |
|
|
|
|
|
|
|
namespace Volo.Abp.FeatureManagement.Web.Pages.FeatureManagement; |
|
|
|
@ -31,14 +34,18 @@ public class FeatureManagementModal : AbpPageModel |
|
|
|
|
|
|
|
protected ILocalEventBus LocalEventBus { get; } |
|
|
|
|
|
|
|
public AbpLocalizationOptions LocalizationOptions { get; } |
|
|
|
|
|
|
|
public FeatureManagementModal( |
|
|
|
IFeatureAppService featureAppService, |
|
|
|
ILocalEventBus localEventBus) |
|
|
|
ILocalEventBus localEventBus, |
|
|
|
IOptions<AbpLocalizationOptions> localizationOptions) |
|
|
|
{ |
|
|
|
ObjectMapperContext = typeof(AbpFeatureManagementWebModule); |
|
|
|
|
|
|
|
FeatureAppService = featureAppService; |
|
|
|
LocalEventBus = localEventBus; |
|
|
|
LocalizationOptions = localizationOptions.Value; |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<IActionResult> OnGetAsync() |
|
|
|
@ -47,9 +54,60 @@ public class FeatureManagementModal : AbpPageModel |
|
|
|
|
|
|
|
FeatureListResultDto = await FeatureAppService.GetAsync(ProviderName, ProviderKey); |
|
|
|
|
|
|
|
UpdateLocalizations(FeatureListResultDto); |
|
|
|
|
|
|
|
return Page(); |
|
|
|
} |
|
|
|
|
|
|
|
private void UpdateLocalizations(GetFeatureListResultDto result) |
|
|
|
{ |
|
|
|
foreach (var group in result.Groups) |
|
|
|
{ |
|
|
|
group.DisplayName = Localize( |
|
|
|
group.DisplayNameKey, |
|
|
|
group.DisplayNameResource, |
|
|
|
group.DisplayName |
|
|
|
); |
|
|
|
|
|
|
|
foreach (var feature in group.Features) |
|
|
|
{ |
|
|
|
feature.DisplayName = Localize( |
|
|
|
feature.DisplayNameKey, |
|
|
|
feature.DisplayNameResource, |
|
|
|
feature.DisplayName |
|
|
|
); |
|
|
|
|
|
|
|
feature.Description = Localize( |
|
|
|
feature.DescriptionKey, |
|
|
|
feature.DescriptionResource, |
|
|
|
feature.Description |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private string Localize(string key, string resourceName, string fallbackValue) |
|
|
|
{ |
|
|
|
if (key.IsNullOrEmpty() || resourceName.IsNullOrEmpty()) |
|
|
|
{ |
|
|
|
return fallbackValue; |
|
|
|
} |
|
|
|
|
|
|
|
var resource = LocalizationOptions.Resources.GetOrNull(resourceName); |
|
|
|
if (resource == null) |
|
|
|
{ |
|
|
|
return fallbackValue; |
|
|
|
} |
|
|
|
|
|
|
|
var result = new LocalizableString(resource.ResourceType, key).Localize(StringLocalizerFactory); |
|
|
|
if (result.ResourceNotFound) |
|
|
|
{ |
|
|
|
return fallbackValue; |
|
|
|
} |
|
|
|
|
|
|
|
return result.Value; |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<IActionResult> OnPostAsync() |
|
|
|
{ |
|
|
|
var features = new UpdateFeaturesDto |
|
|
|
|