mirror of https://github.com/abpframework/abp.git
15 changed files with 366 additions and 0 deletions
@ -0,0 +1,36 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Routing; |
||||
|
using Volo.Abp.AutoMapper; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.SettingManagement.Blazor.Menus; |
||||
|
using Volo.Abp.UI.Navigation; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(AbpSettingManagementDomainSharedModule), |
||||
|
typeof(AbpAutoMapperModule) |
||||
|
)] |
||||
|
public class AbpSettingManagementBlazorModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
context.Services.AddAutoMapperObjectMapper<AbpSettingManagementBlazorModule>(); |
||||
|
|
||||
|
Configure<AbpAutoMapperOptions>(options => |
||||
|
{ |
||||
|
options.AddProfile<SettingManagementBlazorAutoMapperProfile>(validate: true); |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpNavigationOptions>(options => |
||||
|
{ |
||||
|
options.MenuContributors.Add(new SettingManagementMenuContributor()); |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpRouterOptions>(options => |
||||
|
{ |
||||
|
options.AdditionalAssemblies.Add(typeof(AbpSettingManagementBlazorModule).Assembly); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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,11 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor |
||||
|
{ |
||||
|
public interface ISettingComponentContributor |
||||
|
{ |
||||
|
Task ConfigureAsync(SettingComponentCreationContext context); |
||||
|
|
||||
|
Task<bool> CheckPermissionsAsync(SettingComponentCreationContext context); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,60 @@ |
|||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using Volo.Abp.SettingManagement.Localization; |
||||
|
using Volo.Abp.UI.Navigation; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor.Menus |
||||
|
{ |
||||
|
public class SettingManagementMenuContributor : IMenuContributor |
||||
|
{ |
||||
|
public async Task ConfigureMenuAsync(MenuConfigurationContext context) |
||||
|
{ |
||||
|
if (context.Menu.Name == StandardMenus.Main) |
||||
|
{ |
||||
|
await ConfigureMainMenu(context); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private async Task ConfigureMainMenu(MenuConfigurationContext context) |
||||
|
{ |
||||
|
var settingManagementPageOptions = context.ServiceProvider.GetRequiredService<IOptions<SettingManagementComponentOptions>>().Value; |
||||
|
var settingPageCreationContext = new SettingComponentCreationContext(context.ServiceProvider); |
||||
|
if ( |
||||
|
!settingManagementPageOptions.Contributors.Any() || |
||||
|
!(await CheckAnyOfPagePermissionsGranted(settingManagementPageOptions, settingPageCreationContext)) |
||||
|
) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
var l = context.GetLocalizer<AbpSettingManagementResource>(); |
||||
|
|
||||
|
context.Menu |
||||
|
.GetAdministration() |
||||
|
.AddItem( |
||||
|
new ApplicationMenuItem( |
||||
|
SettingManagementMenus.GroupName, |
||||
|
l["Settings"], |
||||
|
"/SettingManagement", |
||||
|
icon: "fa fa-cog" |
||||
|
) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task<bool> CheckAnyOfPagePermissionsGranted( |
||||
|
SettingManagementComponentOptions settingManagementComponentOptions, |
||||
|
SettingComponentCreationContext settingComponentCreationContext) |
||||
|
{ |
||||
|
foreach (var contributor in settingManagementComponentOptions.Contributors) |
||||
|
{ |
||||
|
if (await contributor.CheckPermissionsAsync(settingComponentCreationContext)) |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
namespace Volo.Abp.SettingManagement.Blazor.Menus |
||||
|
{ |
||||
|
public class SettingManagementMenus |
||||
|
{ |
||||
|
public const string GroupName = "SettingManagement"; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,57 @@ |
|||||
|
@page "/SettingManagement" |
||||
|
@using Microsoft.Extensions.Localization |
||||
|
@using Volo.Abp.SettingManagement.Localization |
||||
|
@inject IStringLocalizer<AbpSettingManagementResource> L |
||||
|
@inherits SettingManagementBase |
||||
|
|
||||
|
@* ************************* PAGE HEADER ************************* *@ |
||||
|
<div class="row entry-row"> |
||||
|
<div class="col-auto"> |
||||
|
<h1 class="content-header-title">@L["Settings"]</h1> |
||||
|
</div> |
||||
|
<div class="col-lg-auto pl-lg-0"> |
||||
|
<ol class="breadcrumb"> |
||||
|
<li class="breadcrumb-item"><a href="~/"><i class="fa fa-home"></i> </a></li> |
||||
|
<li class="breadcrumb-item active" aria-current="page">@L["Settings"]</li> |
||||
|
</ol> |
||||
|
</div> |
||||
|
<div class="col"> |
||||
|
<div class="text-lg-right pt-2" id="AbpContentToolbar"> |
||||
|
|
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<Card> |
||||
|
<CardBody> |
||||
|
<Tabs @bind-SelectedTab="@SelectedGroup" TabPosition="TabPosition.Left" Pills="true"> |
||||
|
<Items> |
||||
|
@foreach (var group in SettingComponentCreationContext.Groups) |
||||
|
{ |
||||
|
<Tab Name="@GetNormalizedString(group.Id)"> |
||||
|
@group.DisplayName |
||||
|
</Tab> |
||||
|
} |
||||
|
</Items> |
||||
|
<Content> |
||||
|
@foreach (var group in SettingComponentCreationContext.Groups) |
||||
|
{ |
||||
|
<TabPanel Name="@GetNormalizedString(group.Id)"> |
||||
|
<h2>@group.DisplayName</h2> |
||||
|
<Divider /> |
||||
|
|
||||
|
@{ |
||||
|
SettingItemRenders.Add(builder => |
||||
|
{ |
||||
|
builder.OpenComponent(0, group.ComponentType); |
||||
|
builder.CloseComponent(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
@SettingItemRenders.Last() |
||||
|
</TabPanel> |
||||
|
} |
||||
|
</Content> |
||||
|
</Tabs> |
||||
|
</CardBody> |
||||
|
</Card> |
||||
@ -0,0 +1,45 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Components; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement |
||||
|
{ |
||||
|
public abstract class SettingManagementBase : OwningComponentBase |
||||
|
{ |
||||
|
[Inject] |
||||
|
protected IServiceProvider ServiceProvider { get; set; } |
||||
|
|
||||
|
protected SettingComponentCreationContext SettingComponentCreationContext { get; set; } |
||||
|
|
||||
|
[Inject] |
||||
|
protected IOptions<SettingManagementComponentOptions> _options { get; set; } |
||||
|
|
||||
|
protected SettingManagementComponentOptions Options => _options.Value; |
||||
|
|
||||
|
protected List<RenderFragment> SettingItemRenders { get; set; } = new List<RenderFragment>(); |
||||
|
|
||||
|
protected string SelectedGroup; |
||||
|
|
||||
|
protected override async Task OnInitializedAsync() |
||||
|
{ |
||||
|
SettingComponentCreationContext = new SettingComponentCreationContext(ServiceProvider); |
||||
|
|
||||
|
foreach (var contributor in Options.Contributors) |
||||
|
{ |
||||
|
await contributor.ConfigureAsync(SettingComponentCreationContext); |
||||
|
} |
||||
|
|
||||
|
SettingItemRenders.Clear(); |
||||
|
|
||||
|
SelectedGroup = GetNormalizedString(SettingComponentCreationContext.Groups.First().Id); |
||||
|
} |
||||
|
|
||||
|
protected string GetNormalizedString(string value) |
||||
|
{ |
||||
|
return value.Replace('.', '_'); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor |
||||
|
{ |
||||
|
public class SettingComponentCreationContext : IServiceProviderAccessor |
||||
|
{ |
||||
|
public IServiceProvider ServiceProvider { get; } |
||||
|
|
||||
|
public List<SettingComponentGroup> Groups { get; } |
||||
|
|
||||
|
public SettingComponentCreationContext(IServiceProvider serviceProvider) |
||||
|
{ |
||||
|
ServiceProvider = serviceProvider; |
||||
|
|
||||
|
Groups = new List<SettingComponentGroup>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,39 @@ |
|||||
|
using System; |
||||
|
using JetBrains.Annotations; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor |
||||
|
{ |
||||
|
public class SettingComponentGroup |
||||
|
{ |
||||
|
public string Id |
||||
|
{ |
||||
|
get => _id; |
||||
|
set => _id = Check.NotNullOrWhiteSpace(value, nameof(Id)); |
||||
|
} |
||||
|
private string _id; |
||||
|
|
||||
|
public string DisplayName |
||||
|
{ |
||||
|
get => _displayName; |
||||
|
set => _displayName = Check.NotNullOrWhiteSpace(value, nameof(DisplayName)); |
||||
|
} |
||||
|
private string _displayName; |
||||
|
|
||||
|
public Type ComponentType |
||||
|
{ |
||||
|
get => _componentType; |
||||
|
set => _componentType = Check.NotNull(value, nameof(ComponentType)); |
||||
|
} |
||||
|
private Type _componentType; |
||||
|
|
||||
|
public object Parameter { get; set; } |
||||
|
|
||||
|
public SettingComponentGroup([NotNull] string id, [NotNull] string displayName, [NotNull] Type componentType, object parameter = null) |
||||
|
{ |
||||
|
Id = id; |
||||
|
DisplayName = displayName; |
||||
|
ComponentType = componentType; |
||||
|
Parameter = parameter; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
using AutoMapper; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor |
||||
|
{ |
||||
|
public class SettingManagementBlazorAutoMapperProfile : Profile |
||||
|
{ |
||||
|
public SettingManagementBlazorAutoMapperProfile() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor |
||||
|
{ |
||||
|
public class SettingManagementComponentOptions |
||||
|
{ |
||||
|
public List<ISettingComponentContributor> Contributors { get; } |
||||
|
|
||||
|
public SettingManagementComponentOptions() |
||||
|
{ |
||||
|
Contributors = new List<ISettingComponentContributor>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
||||
|
|
||||
|
<Import Project="..\..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.1</TargetFramework> |
||||
|
<RazorLangVersion>3.0</RazorLangVersion> |
||||
|
<RootNamespace>Volo.Abp.SettingManagement.Blazor</RootNamespace> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" /> |
||||
|
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.WebAssembly.Theming\Volo.Abp.AspNetCore.Components.WebAssembly.Theming.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Volo.Abp.SettingManagement.Domain.Shared\Volo.Abp.SettingManagement.Domain.Shared.csproj" /> |
||||
|
</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