mirror of https://github.com/abpframework/abp.git
8 changed files with 245 additions and 0 deletions
@ -0,0 +1,16 @@ |
|||
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming; |
|||
using Volo.Abp.AutoMapper; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.FeatureManagement.Blazor |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpAspNetCoreComponentsWebAssemblyThemingModule), |
|||
typeof(AbpAutoMapperModule), |
|||
typeof(AbpFeatureManagementHttpApiClientModule) |
|||
)] |
|||
public class AbpFeatureManagementBlazorModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,85 @@ |
|||
@using Microsoft.Extensions.Localization |
|||
@using Volo.Abp.FeatureManagement.Localization |
|||
@using Volo.Abp.Validation.StringValues |
|||
@inject IStringLocalizer<AbpFeatureManagementResource> L |
|||
|
|||
<Modal @ref="_modal"> |
|||
<ModalBackdrop /> |
|||
<ModalContent Size="ModalSize.Large" IsCentered="true"> |
|||
<ModalHeader> |
|||
<ModalTitle>@L["Features"]</ModalTitle> |
|||
<CloseButton Clicked="CloseModal" /> |
|||
</ModalHeader> |
|||
<ModalBody MaxHeight="50"> |
|||
@if (_groups == null) |
|||
{ |
|||
<span>@L["NoFeatureFoundMessage"]</span> |
|||
} |
|||
else |
|||
{ |
|||
<Tabs TabPosition="TabPosition.Left" Pills="true" SelectedTab="@GetNormalizedGroupName(_groups.First().Name)"> |
|||
<Items> |
|||
@foreach (var group in _groups) |
|||
{ |
|||
<Tab Name="@GetNormalizedGroupName(group.Name)"> |
|||
<span>@group.DisplayName</span> |
|||
</Tab> |
|||
} |
|||
</Items> |
|||
<Content> |
|||
@foreach (var group in _groups) |
|||
{ |
|||
<TabPanel Name="@GetNormalizedGroupName(group.Name)"> |
|||
<h4>@group.DisplayName</h4> |
|||
|
|||
@foreach (var feature in group.Features) |
|||
{ |
|||
var disabled = IsDisabled(feature.Provider.Name); |
|||
|
|||
if (feature.ValueType is FreeTextStringValueType) |
|||
{ |
|||
<Field> |
|||
<FieldLabel>@feature.DisplayName</FieldLabel> |
|||
<TextEdit Disabled="@disabled" @bind-text="@feature.Value" /> |
|||
@if (feature.Description != null) |
|||
{ |
|||
<span>@feature.Description</span> |
|||
} |
|||
</Field> |
|||
} |
|||
|
|||
if (feature.ValueType is SelectionStringValueType) |
|||
{ |
|||
var items = ((SelectionStringValueType) feature.ValueType).ItemSource.Items; |
|||
|
|||
<Field> |
|||
<FieldLabel>@feature.DisplayName</FieldLabel> |
|||
<Select TValue="string" SelectedValue="feature.Value"> |
|||
@foreach (var item in items) |
|||
{ |
|||
<SelectItem Value="@item.Value">@item.DisplayText</SelectItem> |
|||
} |
|||
</Select> |
|||
</Field> |
|||
} |
|||
|
|||
if (feature.ValueType is ToggleStringValueType) |
|||
{ |
|||
<Field> |
|||
<Check TValue="bool" @bind-checked="@ToggleValues[feature.Name]">@feature.DisplayName</Check> |
|||
</Field> |
|||
} |
|||
} |
|||
|
|||
</TabPanel> |
|||
} |
|||
</Content> |
|||
</Tabs> |
|||
} |
|||
</ModalBody> |
|||
<ModalFooter> |
|||
<Button Color="Color.Secondary" Clicked="CloseModal">@L["Cancel"]</Button> |
|||
<Button Color="Color.Primary" Clicked="SaveAsync">@L["Save"]</Button> |
|||
</ModalFooter> |
|||
</ModalContent> |
|||
</Modal> |
|||
@ -0,0 +1,70 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Blazorise; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Volo.Abp.Features; |
|||
using Volo.Abp.Validation.StringValues; |
|||
|
|||
namespace Volo.Abp.FeatureManagement.Blazor.Components |
|||
{ |
|||
public partial class FeatureManagementModal |
|||
{ |
|||
[Inject] private IFeatureAppService FeatureAppService { get; set; } |
|||
|
|||
private Modal _modal; |
|||
|
|||
private string _providerName; |
|||
private string _providerKey; |
|||
|
|||
private List<FeatureGroupDto> _groups { get; set; } |
|||
|
|||
private Dictionary<string, bool> ToggleValues; |
|||
|
|||
public async Task OpenAsync(string providerName, string providerKey) |
|||
{ |
|||
_providerName = providerName; |
|||
_providerKey = providerKey; |
|||
|
|||
_groups = (await FeatureAppService.GetAsync(_providerName, _providerKey)).Groups; |
|||
|
|||
ToggleValues = _groups |
|||
.SelectMany(x => x.Features) |
|||
.Where(x => x.ValueType is ToggleStringValueType) |
|||
.ToDictionary(x => x.Name, x => bool.Parse(x.Value)); |
|||
|
|||
_modal.Show(); |
|||
} |
|||
|
|||
private void CloseModal() |
|||
{ |
|||
_modal.Hide(); |
|||
} |
|||
|
|||
private async Task SaveAsync() |
|||
{ |
|||
var features = new UpdateFeaturesDto |
|||
{ |
|||
Features = _groups.SelectMany(g => g.Features).Select(f => new UpdateFeatureDto |
|||
{ |
|||
Name = f.Name, |
|||
Value = f.ValueType is ToggleStringValueType ? ToggleValues[f.Name].ToString() : f.Value |
|||
}).ToList() |
|||
}; |
|||
|
|||
await FeatureAppService.UpdateAsync(_providerName, _providerKey, features); |
|||
|
|||
_modal.Hide(); |
|||
} |
|||
|
|||
public string GetNormalizedGroupName(string name) |
|||
{ |
|||
return "FeatureGroup_" + name.Replace(".", "_"); |
|||
} |
|||
|
|||
public virtual bool IsDisabled(string providerName) |
|||
{ |
|||
return providerName != _providerName && providerName != DefaultValueFeatureValueProvider.ProviderName; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,29 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<Import Project="..\..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.1</TargetFramework> |
|||
<RazorLangVersion>3.0</RazorLangVersion> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.WebAssembly.Theming\Volo.Abp.AspNetCore.Components.WebAssembly.Theming.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.FeatureManagement.HttpApi.Client\Volo.Abp.FeatureManagement.HttpApi.Client.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Content Update="_Imports.razor"> |
|||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile> |
|||
</Content> |
|||
<Content Update="Components\FeatureManagementModal.razor"> |
|||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile> |
|||
</Content> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
@using Microsoft.AspNetCore.Components.Web |
|||
@using Volo.Abp.AspNetCore.Components.WebAssembly |
|||
@using Volo.Abp.BlazoriseUI |
|||
@using Blazorise |
|||
@using Blazorise.DataGrid |
|||
Loading…
Reference in new issue