969 changed files with 219089 additions and 122 deletions
@ -0,0 +1,20 @@ |
|||
@ECHO off |
|||
cls |
|||
|
|||
ECHO Deleting all BIN and OBJ folders... |
|||
ECHO. |
|||
|
|||
FOR /d /r . %%d in (bin,obj) DO ( |
|||
IF EXIST "%%d" ( |
|||
ECHO %%d | FIND /I "\node_modules\" > Nul && ( |
|||
ECHO.Skipping: %%d |
|||
) || ( |
|||
ECHO.Deleting: %%d |
|||
rd /s/q "%%d" |
|||
) |
|||
) |
|||
) |
|||
|
|||
ECHO. |
|||
ECHO.BIN and OBJ folders have been successfully deleted. Press any key to exit. |
|||
pause > nul |
|||
@ -0,0 +1,18 @@ |
|||
using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme; |
|||
using Volo.Abp.AutoMapper; |
|||
using Volo.Abp.FeatureManagement; |
|||
using Volo.Abp.Features; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Lsw.Abp.FeatureManagement.Blazor.AntDesignUI; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpAspNetCoreComponentsWebAntDesignThemeModule), |
|||
typeof(AbpAutoMapperModule), |
|||
typeof(AbpFeatureManagementApplicationContractsModule), |
|||
typeof(AbpFeaturesModule) |
|||
)] |
|||
public class AbpFeatureManagementBlazorAntDesignModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using Volo.Abp.AspNetCore.Components; |
|||
using Volo.Abp.FeatureManagement.Localization; |
|||
|
|||
namespace Lsw.Abp.FeatureManagement.Blazor.AntDesignUI; |
|||
|
|||
public abstract class AbpFeatureManagementComponentBase : AbpComponentBase |
|||
{ |
|||
protected AbpFeatureManagementComponentBase() |
|||
{ |
|||
LocalizationResource = typeof(AbpFeatureManagementResource); |
|||
} |
|||
} |
|||
@ -0,0 +1,78 @@ |
|||
@using AntDesign |
|||
@using Microsoft.AspNetCore.Components |
|||
@using Microsoft.Extensions.Localization |
|||
@using Volo.Abp.Validation.StringValues |
|||
@inherits AbpFeatureManagementComponentBase |
|||
|
|||
<Modal Title="@L["Features"]" |
|||
Visible="@_visible" |
|||
OnOk="@SaveAsync" |
|||
OnCancel="@CloseModal" Style="min-width: 700px"> |
|||
|
|||
@if (_visible) |
|||
{ |
|||
@if (Groups == null || !Groups.Any()) |
|||
{ |
|||
<Empty Description="false" /> |
|||
} |
|||
else |
|||
{ |
|||
<Tabs TabPosition="@TabPosition.Left"> |
|||
@foreach (var group in Groups) |
|||
{ |
|||
<TabPane Key="@GetNormalizedGroupName(group.Name)" Tab="@group.DisplayName"> |
|||
<h4>@group.DisplayName</h4> |
|||
<Divider/> |
|||
|
|||
@foreach (var feature in group.Features) |
|||
{ |
|||
var disabled = IsDisabled(feature.Provider.Name); |
|||
|
|||
<div style="@GetFeatureStyles(feature)"> |
|||
|
|||
|
|||
@if (feature.ValueType is FreeTextStringValueType) |
|||
{ |
|||
<Text>@feature.DisplayName</Text> |
|||
<Input |
|||
TValue="string" |
|||
Disabled="@disabled" |
|||
@bind-Value="@feature.Value" |
|||
OnChange=" args => OnFeatureValueChangedAsync(args, feature)"/> |
|||
@if (feature.Description != null) |
|||
{ |
|||
<span>@feature.Description</span> |
|||
} |
|||
} |
|||
|
|||
@if (feature.ValueType is SelectionStringValueType type) |
|||
{ |
|||
var items = type.ItemSource.Items; |
|||
<Select DataSource="@items" |
|||
@bind-Value="@SelectionStringValues[feature.Name]" |
|||
LabelName="@nameof(ISelectionStringValueItem.DisplayText)" |
|||
ValueName="@nameof(ISelectionStringValueItem.Value)" |
|||
DefaultActiveFirstItem="false"> |
|||
<ItemTemplate> |
|||
<span>@CreateStringLocalizer(context.DisplayText.ResourceName).GetString(context.DisplayText.Name)</span> |
|||
</ItemTemplate> |
|||
</Select> |
|||
} |
|||
|
|||
@if (feature.ValueType is ToggleStringValueType) |
|||
{ |
|||
<Checkbox |
|||
Disabled="@disabled" |
|||
@bind-Checked="@ToggleValues[feature.Name]" |
|||
OnChange="b => OnSelectedValueChangedAsync(b, feature)"> |
|||
@feature.DisplayName |
|||
</Checkbox> |
|||
} |
|||
</div> |
|||
} |
|||
</TabPane> |
|||
} |
|||
</Tabs> |
|||
} |
|||
} |
|||
</Modal> |
|||
@ -0,0 +1,202 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using AntDesign; |
|||
using JetBrains.Annotations; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Microsoft.AspNetCore.Components.Web; |
|||
using Microsoft.Extensions.Localization; |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.Abp.AspNetCore.Components.Messages; |
|||
using Volo.Abp.AspNetCore.Components.Web.Configuration; |
|||
using Volo.Abp.FeatureManagement; |
|||
using Volo.Abp.Features; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Validation.StringValues; |
|||
|
|||
namespace Lsw.Abp.FeatureManagement.Blazor.AntDesignUI.Components; |
|||
|
|||
public partial class FeatureManagementModal |
|||
{ |
|||
[Inject] |
|||
protected IFeatureAppService FeatureAppService { get; set; } |
|||
|
|||
[Inject] |
|||
protected IUiMessageService UiMessageService { get; set; } |
|||
|
|||
[Inject] |
|||
protected IStringLocalizerFactory HtmlLocalizerFactory { get; set; } |
|||
|
|||
[Inject] |
|||
protected IOptions<AbpLocalizationOptions> LocalizationOptions { get; set; } |
|||
|
|||
[Inject] |
|||
private ICurrentApplicationConfigurationCacheResetService CurrentApplicationConfigurationCacheResetService { get; set; } |
|||
|
|||
protected Modal Modal; |
|||
|
|||
protected string ProviderName; |
|||
protected string ProviderKey; |
|||
|
|||
protected List<FeatureGroupDto> Groups { get; set; } |
|||
|
|||
protected Dictionary<string, bool> ToggleValues; |
|||
|
|||
protected Dictionary<string, string> SelectionStringValues; |
|||
|
|||
private bool _visible; |
|||
|
|||
public virtual async Task OpenAsync([NotNull] string providerName, string providerKey = null) |
|||
{ |
|||
try |
|||
{ |
|||
ProviderName = providerName; |
|||
ProviderKey = providerKey; |
|||
|
|||
ToggleValues = new Dictionary<string, bool>(); |
|||
SelectionStringValues = new Dictionary<string, string>(); |
|||
|
|||
Groups = (await FeatureAppService.GetAsync(ProviderName, ProviderKey))?.Groups; |
|||
|
|||
Groups ??= new List<FeatureGroupDto>(); |
|||
|
|||
foreach (var featureGroupDto in Groups) |
|||
{ |
|||
foreach (var featureDto in featureGroupDto.Features) |
|||
{ |
|||
if (featureDto.ValueType is ToggleStringValueType) |
|||
{ |
|||
ToggleValues.Add(featureDto.Name, bool.Parse(featureDto.Value)); |
|||
} |
|||
|
|||
if (featureDto.ValueType is SelectionStringValueType) |
|||
{ |
|||
SelectionStringValues.Add(featureDto.Name, featureDto.Value); |
|||
} |
|||
} |
|||
} |
|||
_visible = true; |
|||
StateHasChanged(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
await HandleErrorAsync(ex); |
|||
} |
|||
} |
|||
|
|||
public virtual void CloseModal() |
|||
{ |
|||
_visible = false; |
|||
} |
|||
|
|||
protected virtual async Task SaveAsync() |
|||
{ |
|||
try |
|||
{ |
|||
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.ValueType is SelectionStringValueType ? SelectionStringValues[f.Name] : f.Value |
|||
}).ToList() |
|||
}; |
|||
|
|||
await FeatureAppService.UpdateAsync(ProviderName, ProviderKey, features); |
|||
|
|||
await CurrentApplicationConfigurationCacheResetService.ResetAsync(); |
|||
|
|||
_visible = false; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
await HandleErrorAsync(ex); |
|||
} |
|||
} |
|||
|
|||
protected virtual string GetNormalizedGroupName(string name) |
|||
{ |
|||
return "FeatureGroup_" + name.Replace(".", "_"); |
|||
} |
|||
|
|||
protected virtual string GetFeatureStyles(FeatureDto feature) |
|||
{ |
|||
return $"margin-left: {feature.Depth * 20}px; margin-top: 10px"; |
|||
} |
|||
|
|||
protected virtual bool IsDisabled(string providerName) |
|||
{ |
|||
return providerName != ProviderName && providerName != DefaultValueFeatureValueProvider.ProviderName; |
|||
} |
|||
|
|||
protected virtual async Task OnFeatureValueChangedAsync(string value, FeatureDto feature) |
|||
{ |
|||
if (feature?.ValueType?.Validator.IsValid(value) == true) |
|||
{ |
|||
feature.Value = value; |
|||
} |
|||
else |
|||
{ |
|||
await UiMessageService.Warn(L["Volo.Abp.FeatureManagement:InvalidFeatureValue", feature.DisplayName]); |
|||
} |
|||
} |
|||
|
|||
protected virtual Task OnSelectedValueChangedAsync(bool value, FeatureDto feature) |
|||
{ |
|||
ToggleValues[feature.Name] = value; |
|||
|
|||
if (value) |
|||
{ |
|||
CheckParents(feature.ParentName); |
|||
} |
|||
else |
|||
{ |
|||
UncheckChildren(feature.Name); |
|||
} |
|||
|
|||
return Task.CompletedTask; |
|||
} |
|||
|
|||
protected virtual void CheckParents(string parentName) |
|||
{ |
|||
if (parentName.IsNullOrWhiteSpace()) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
foreach (var featureGroupDto in Groups) |
|||
{ |
|||
foreach (var featureDto in featureGroupDto.Features) |
|||
{ |
|||
if (featureDto.Name == parentName && ToggleValues.ContainsKey(featureDto.Name)) |
|||
{ |
|||
ToggleValues[featureDto.Name] = true; |
|||
CheckParents(featureDto.ParentName); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
protected virtual void UncheckChildren(string featureName) |
|||
{ |
|||
foreach (var featureGroupDto in Groups) |
|||
{ |
|||
foreach (var featureDto in featureGroupDto.Features) |
|||
{ |
|||
if (featureDto.ParentName == featureName && ToggleValues.ContainsKey(featureDto.Name)) |
|||
{ |
|||
ToggleValues[featureDto.Name] = false; |
|||
UncheckChildren(featureDto.Name); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
protected virtual IStringLocalizer CreateStringLocalizer(string resourceName) |
|||
{ |
|||
var resource = LocalizationOptions.Value.Resources.Values.FirstOrDefault(x => x.ResourceName == resourceName); |
|||
return HtmlLocalizerFactory.Create(resource != null ? resource.ResourceType : LocalizationOptions.Value.DefaultResourceType); |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.AutoMapper" Version="5.1.4" /> |
|||
<PackageReference Include="Volo.Abp.Features" Version="5.1.4" /> |
|||
<PackageReference Include="Volo.Abp.FeatureManagement.Application.Contracts" Version="5.1.4" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme\Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,13 @@ |
|||
using Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme; |
|||
using Lsw.Abp.FeatureManagement.Blazor.AntDesignUI; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Lsw.Abp.FeatureManagement.Blazor.Server.AntDesignUI; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpFeatureManagementBlazorAntDesignModule), |
|||
typeof(AbpAspNetCoreComponentsServerAntDesignThemeModule) |
|||
)] |
|||
public class AbpFeatureManagementBlazorWebServerAntDesignModule : AbpModule |
|||
{ |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
<ImplicitUsings>enable</ImplicitUsings> |
|||
<Nullable>enable</Nullable> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme\Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme.csproj" /> |
|||
<ProjectReference Include="..\Lsw.Abp.FeatureManagement.Blazor.AntDesignUI\Lsw.Abp.FeatureManagement.Blazor.AntDesignUI.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,15 @@ |
|||
using Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme; |
|||
using Lsw.Abp.FeatureManagement.Blazor.AntDesignUI; |
|||
using Volo.Abp.FeatureManagement; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Lsw.Abp.FeatureManagement.Blazor.WebAssembly.AntDesignUI; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpFeatureManagementBlazorAntDesignModule), |
|||
typeof(AbpAspNetCoreComponentsWebAssemblyAntDesignThemeModule), |
|||
typeof(AbpFeatureManagementHttpApiClientModule) |
|||
)] |
|||
public class AbpFeatureManagementBlazorWebAssemblyAntDesignModule : AbpModule |
|||
{ |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.FeatureManagement.HttpApi.Client" Version="5.1.4" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme\Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme.csproj" /> |
|||
<ProjectReference Include="..\Lsw.Abp.FeatureManagement.Blazor.AntDesignUI\Lsw.Abp.FeatureManagement.Blazor.AntDesignUI.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,19 @@ |
|||
using AutoMapper; |
|||
using Volo.Abp.AutoMapper; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace Lsw.Abp.IdentityManagement.Blazor.AntDesignUI; |
|||
|
|||
public class AbpIdentityBlazorAntDesignAutoMapperProfile: Profile |
|||
{ |
|||
public AbpIdentityBlazorAntDesignAutoMapperProfile() |
|||
{ |
|||
CreateMap<IdentityUserDto, IdentityUserUpdateDto>() |
|||
.MapExtraProperties() |
|||
.Ignore(x => x.Password) |
|||
.Ignore(x => x.RoleNames); |
|||
|
|||
CreateMap<IdentityRoleDto, IdentityRoleUpdateDto>() |
|||
.MapExtraProperties(); |
|||
} |
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
using Lsw.Abp.AntDesignUI; |
|||
using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme; |
|||
using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Routing; |
|||
using Lsw.Abp.PermissionManagement.Blazor.AntDesignUI; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.AutoMapper; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.ObjectExtending; |
|||
using Volo.Abp.ObjectExtending.Modularity; |
|||
using Volo.Abp.Threading; |
|||
using Volo.Abp.UI.Navigation; |
|||
|
|||
namespace Lsw.Abp.IdentityManagement.Blazor.AntDesignUI; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpIdentityApplicationContractsModule), |
|||
typeof(AbpAutoMapperModule), |
|||
typeof(AbpPermissionManagementBlazorAntDesignModule), |
|||
typeof(AbpAspNetCoreComponentsWebAntDesignThemeModule), |
|||
typeof(AbpAntDesignUIModule) |
|||
)] |
|||
public class AbpIdentityBlazorAntDesignModule: AbpModule |
|||
{ |
|||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddAutoMapperObjectMapper<AbpIdentityBlazorAntDesignModule>(); |
|||
|
|||
Configure<AbpAutoMapperOptions>(options => |
|||
{ |
|||
options.AddProfile<AbpIdentityBlazorAntDesignAutoMapperProfile>(validate: true); |
|||
}); |
|||
|
|||
Configure<AbpNavigationOptions>(options => |
|||
{ |
|||
options.MenuContributors.Add(new AbpIdentityWebMainMenuContributor()); |
|||
}); |
|||
|
|||
Configure<AbpRouterOptions>(options => |
|||
{ |
|||
options.AdditionalAssemblies.Add(typeof(AbpIdentityBlazorAntDesignModule).Assembly); |
|||
}); |
|||
} |
|||
|
|||
public override void PostConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
OneTimeRunner.Run(() => |
|||
{ |
|||
ModuleExtensionConfigurationHelper |
|||
.ApplyEntityConfigurationToUi( |
|||
IdentityModuleExtensionConsts.ModuleName, |
|||
IdentityModuleExtensionConsts.EntityNames.Role, |
|||
createFormTypes: new[] { typeof(IdentityRoleCreateDto) }, |
|||
editFormTypes: new[] { typeof(IdentityRoleUpdateDto) } |
|||
); |
|||
|
|||
ModuleExtensionConfigurationHelper |
|||
.ApplyEntityConfigurationToUi( |
|||
IdentityModuleExtensionConsts.ModuleName, |
|||
IdentityModuleExtensionConsts.EntityNames.User, |
|||
createFormTypes: new[] { typeof(IdentityUserCreateDto) }, |
|||
editFormTypes: new[] { typeof(IdentityUserUpdateDto) } |
|||
); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
using System.Threading.Tasks; |
|||
using AntDesign; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.Identity.Localization; |
|||
using Volo.Abp.UI.Navigation; |
|||
|
|||
namespace Lsw.Abp.IdentityManagement.Blazor.AntDesignUI; |
|||
|
|||
public class AbpIdentityWebMainMenuContributor : IMenuContributor |
|||
{ |
|||
public virtual Task ConfigureMenuAsync(MenuConfigurationContext context) |
|||
{ |
|||
if (context.Menu.Name != StandardMenus.Main) |
|||
{ |
|||
return Task.CompletedTask; |
|||
} |
|||
|
|||
var administrationMenu = context.Menu.GetAdministration(); |
|||
administrationMenu.Icon = IconType.Outline.PicLeft; |
|||
|
|||
var l = context.GetLocalizer<IdentityResource>(); |
|||
|
|||
var identityMenuItem = new ApplicationMenuItem(IdentityMenuNames.GroupName, l["Menu:IdentityManagement"], |
|||
icon: IconType.Outline.User); |
|||
administrationMenu.AddItem(identityMenuItem); |
|||
|
|||
identityMenuItem.AddItem(new ApplicationMenuItem( |
|||
IdentityMenuNames.Roles, |
|||
l["Roles"], |
|||
url: "~/identity/roles").RequirePermissions(IdentityPermissions.Roles.Default)); |
|||
|
|||
identityMenuItem.AddItem(new ApplicationMenuItem( |
|||
IdentityMenuNames.Users, |
|||
l["Users"], |
|||
url: "~/identity/users").RequirePermissions(IdentityPermissions.Users.Default)); |
|||
|
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
namespace Lsw.Abp.IdentityManagement.Blazor.AntDesignUI; |
|||
|
|||
public class IdentityMenuNames |
|||
{ |
|||
public const string GroupName = "AbpIdentity"; |
|||
|
|||
public const string Roles = GroupName + ".Roles"; |
|||
public const string Users = GroupName + ".Users"; |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.AutoMapper" Version="5.1.4" /> |
|||
<PackageReference Include="Volo.Abp.Identity.Application.Contracts" Version="5.1.4" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme\Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.csproj" /> |
|||
<ProjectReference Include="..\..\PermissionManagement\Lsw.Abp.PermissionManagement.Blazor.AntDesignUI\Lsw.Abp.PermissionManagement.Blazor.AntDesignUI.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,70 @@ |
|||
@page "/identity/roles" |
|||
@attribute [Authorize(IdentityPermissions.Roles.Default)] |
|||
@using Microsoft.AspNetCore.Authorization |
|||
@using Volo.Abp.Identity |
|||
@using Volo.Abp.Identity.Localization |
|||
@using Lsw.Abp.PermissionManagement.Blazor.AntDesignUI.Components |
|||
@using Volo.Abp.AspNetCore.Components.Web |
|||
@inject AbpBlazorMessageLocalizerHelper<IdentityResource> LH |
|||
@inherits AbpCrudPageBase<IIdentityRoleAppService, IdentityRoleDto, Guid, GetIdentityRolesInput, IdentityRoleCreateDto, IdentityRoleUpdateDto> |
|||
|
|||
<AbpPageHeader Title="@L["Roles"]" BreadcrumbItems="@BreadcrumbItems" Toolbar="@Toolbar"/> |
|||
|
|||
<div class="page-content"> |
|||
<AbpExtensibleDataGrid TItem="IdentityRoleDto" |
|||
Data="@Entities" |
|||
OnChange="@OnDataGridReadAsync" |
|||
TotalItems="@TotalCount" |
|||
PageSize="@PageSize" |
|||
CurrentPage="@CurrentPage" |
|||
Columns="@RoleManagementTableColumns"> |
|||
</AbpExtensibleDataGrid> |
|||
</div> |
|||
|
|||
@if (HasCreatePermission) |
|||
{ |
|||
<Modal @ref="CreateModal" Title="@L["NewRole"]" Visible="@CreateModalVisible" OnCancel="@CloseCreateModalAsync" OnOk="CreateEntityAsync"> |
|||
<Form |
|||
Layout="@FormLayout.Vertical" |
|||
@ref="@CreateFormRef" |
|||
Model="@NewEntity"> |
|||
|
|||
<FormItem Label="@L["DisplayName:RoleName"]"> |
|||
<Input @bind-Value="@context.Name"/> |
|||
</FormItem> |
|||
<FormItem> |
|||
<Checkbox @bind-Value="context.IsDefault">@L["DisplayName:IsDefault"]</Checkbox> |
|||
</FormItem> |
|||
<FormItem> |
|||
<Checkbox @bind-Value="context.IsPublic">@L["DisplayName:IsPublic"]</Checkbox> |
|||
</FormItem> |
|||
</Form> |
|||
</Modal> |
|||
} |
|||
|
|||
@if (HasUpdatePermission) |
|||
{ |
|||
<Modal @ref="EditModal" Title="@L["Edit"]" Visible="@EditModalVisible" OnCancel="@CloseEditModalAsync" OnOk="UpdateEntityAsync"> |
|||
<Form |
|||
Layout="@FormLayout.Vertical" |
|||
@ref="@EditFormRef" |
|||
Model="@EditingEntity"> |
|||
<input type="hidden" name="ConcurrencyStamp" @bind-value="EditingEntity.ConcurrencyStamp"/> |
|||
<FormItem Label="@L["DisplayName:RoleName"]"> |
|||
<Input @bind-Value="@context.Name"/> |
|||
</FormItem> |
|||
<FormItem> |
|||
<Checkbox @bind-Value="context.IsDefault">@L["DisplayName:IsDefault"]</Checkbox> |
|||
</FormItem> |
|||
<FormItem> |
|||
<Checkbox @bind-Value="context.IsPublic">@L["DisplayName:IsPublic"]</Checkbox> |
|||
</FormItem> |
|||
</Form> |
|||
</Modal> |
|||
} |
|||
|
|||
|
|||
@if (HasManagePermissionsPermission) |
|||
{ |
|||
<PermissionManagementModal @ref="PermissionManagementModal"/> |
|||
} |
|||
@ -0,0 +1,137 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using AntDesign; |
|||
using Lsw.Abp.AntDesignUI; |
|||
using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.PageToolbars; |
|||
using Lsw.Abp.PermissionManagement.Blazor.AntDesignUI.Components; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Volo.Abp.AspNetCore.Components.Web.Extensibility.EntityActions; |
|||
using Volo.Abp.AspNetCore.Components.Web.Extensibility.TableColumns; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.Identity.Localization; |
|||
|
|||
namespace Lsw.Abp.IdentityManagement.Blazor.AntDesignUI.Pages; |
|||
|
|||
public partial class RoleManagement |
|||
{ |
|||
protected const string PermissionProviderName = "R"; |
|||
|
|||
protected PermissionManagementModal PermissionManagementModal; |
|||
|
|||
protected string ManagePermissionsPolicyName; |
|||
|
|||
protected bool HasManagePermissionsPermission { get; set; } |
|||
|
|||
protected PageToolbar Toolbar { get; } = new(); |
|||
|
|||
protected List<TableColumn> RoleManagementTableColumns => TableColumns.Get<RoleManagement>(); |
|||
|
|||
public RoleManagement() |
|||
{ |
|||
ObjectMapperContext = typeof(AbpIdentityBlazorAntDesignModule); |
|||
LocalizationResource = typeof(IdentityResource); |
|||
|
|||
CreatePolicyName = IdentityPermissions.Roles.Create; |
|||
UpdatePolicyName = IdentityPermissions.Roles.Update; |
|||
DeletePolicyName = IdentityPermissions.Roles.Delete; |
|||
ManagePermissionsPolicyName = IdentityPermissions.Roles.ManagePermissions; |
|||
} |
|||
|
|||
protected override ValueTask SetBreadcrumbItemsAsync() |
|||
{ |
|||
BreadcrumbItems = new List<AbpBreadcrumbItem>() |
|||
{ |
|||
new(L["Menu:IdentityManagement"]), |
|||
new(L["Roles"]) |
|||
}; |
|||
|
|||
return base.SetBreadcrumbItemsAsync(); |
|||
} |
|||
|
|||
protected override ValueTask SetEntityActionsAsync() |
|||
{ |
|||
EntityActions |
|||
.Get<RoleManagement>() |
|||
.AddRange(new EntityAction[] |
|||
{ |
|||
new EntityAction |
|||
{ |
|||
Text = L["Edit"], |
|||
Visible = (data) => HasUpdatePermission, |
|||
Clicked = async (data) => |
|||
{ |
|||
await OpenEditModalAsync(data.As<IdentityRoleDto>()); |
|||
} |
|||
}, |
|||
new EntityAction |
|||
{ |
|||
Text = L["Permissions"], |
|||
Visible = (data) => HasManagePermissionsPermission, |
|||
Clicked = async (data) => |
|||
{ |
|||
await PermissionManagementModal.OpenAsync(PermissionProviderName, |
|||
data.As<IdentityRoleDto>().Name); |
|||
} |
|||
}, |
|||
new EntityAction |
|||
{ |
|||
Text = L["Delete"], |
|||
Visible = (data) => HasDeletePermission, |
|||
Clicked = async (data) => await DeleteEntityAsync(data.As<IdentityRoleDto>()), |
|||
ConfirmationMessage = (data) => GetDeleteConfirmationMessage(data.As<IdentityRoleDto>()) |
|||
} |
|||
}); |
|||
|
|||
return base.SetEntityActionsAsync(); |
|||
} |
|||
|
|||
protected override ValueTask SetTableColumnsAsync() |
|||
{ |
|||
RoleManagementTableColumns |
|||
.AddRange(new TableColumn[] |
|||
{ |
|||
new TableColumn |
|||
{ |
|||
Title = L["RoleName"], |
|||
Data = nameof(IdentityRoleDto.Name), |
|||
Component = typeof(RoleNameComponent) |
|||
}, |
|||
new TableColumn |
|||
{ |
|||
Title = L["Actions"], |
|||
Actions = EntityActions.Get<RoleManagement>() |
|||
}, |
|||
}); |
|||
|
|||
|
|||
//TODO Implement object extensions
|
|||
// RoleManagementTableColumns.AddRange(GetExtensionTableColumns(IdentityModuleExtensionConsts.ModuleName,
|
|||
// IdentityModuleExtensionConsts.EntityNames.Role));
|
|||
|
|||
return base.SetTableColumnsAsync(); |
|||
} |
|||
|
|||
protected override async Task SetPermissionsAsync() |
|||
{ |
|||
await base.SetPermissionsAsync(); |
|||
|
|||
HasManagePermissionsPermission = |
|||
await AuthorizationService.IsGrantedAsync(IdentityPermissions.Roles.ManagePermissions); |
|||
} |
|||
|
|||
protected override string GetDeleteConfirmationMessage(IdentityRoleDto entity) |
|||
{ |
|||
return string.Format(L["RoleDeletionConfirmationMessage"], entity.Name); |
|||
} |
|||
|
|||
protected override ValueTask SetToolbarItemsAsync() |
|||
{ |
|||
Toolbar.AddButton(L["NewRole"], |
|||
OpenCreateModalAsync, |
|||
IconType.Outline.Plus, |
|||
requiredPolicyName: CreatePolicyName); |
|||
|
|||
return base.SetToolbarItemsAsync(); |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
@using System; |
|||
@using Volo.Abp.Identity |
|||
@using Microsoft.Extensions.Localization |
|||
@using Volo.Abp.Identity.Localization |
|||
|
|||
@inject IStringLocalizer<IdentityResource> L |
|||
|
|||
@(Data.As<IdentityRoleDto>().Name) |
|||
@if (Data.As<IdentityRoleDto>().IsDefault) |
|||
{ |
|||
<Badge Dot="true" |
|||
Status="success" |
|||
Style="margin-left: 0.25rem" |
|||
Text="@L["DisplayName:IsDefault"]"/> |
|||
} |
|||
@if (Data.As<IdentityRoleDto>().IsPublic) |
|||
{ |
|||
<Badge Dot="true" |
|||
Status="processing" |
|||
Style="margin-left: 0.25rem" |
|||
Text="@L["DisplayName:IsPublic"]"/> |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using Microsoft.AspNetCore.Components; |
|||
|
|||
namespace Lsw.Abp.IdentityManagement.Blazor.AntDesignUI.Pages; |
|||
|
|||
public partial class RoleNameComponent: ComponentBase |
|||
{ |
|||
[Parameter] |
|||
public object Data { get; set; } |
|||
} |
|||
@ -0,0 +1,129 @@ |
|||
@page "/identity/users" |
|||
@attribute [Authorize(IdentityPermissions.Users.Default)] |
|||
@using Microsoft.AspNetCore.Authorization |
|||
@using Lsw.Abp.PermissionManagement.Blazor.AntDesignUI.Components |
|||
@using Volo.Abp.Identity |
|||
@using Volo.Abp.Identity.Localization |
|||
@inject AbpBlazorMessageLocalizerHelper<IdentityResource> LH |
|||
@inherits AbpCrudPageBase<IIdentityUserAppService, IdentityUserDto, Guid, GetIdentityUsersInput, IdentityUserCreateDto, IdentityUserUpdateDto> |
|||
|
|||
<AbpPageHeader Title="@L["Users"]" BreadcrumbItems="@BreadcrumbItems" Toolbar="@Toolbar"/> |
|||
|
|||
<div class="page-content"> |
|||
<AbpExtensibleDataGrid TItem="IdentityUserDto" |
|||
Data="@Entities" |
|||
OnChange="@OnDataGridReadAsync" |
|||
TotalItems="@TotalCount" |
|||
PageSize="@PageSize" |
|||
CurrentPage="@CurrentPage" |
|||
Columns="@UserManagementTableColumns"> |
|||
</AbpExtensibleDataGrid> |
|||
</div> |
|||
|
|||
@if (HasCreatePermission) |
|||
{ |
|||
<Modal @ref="CreateModal" Title="@L["NewUser"]" Visible="@CreateModalVisible" OnCancel="@CloseCreateModalAsync" OnOk="CreateEntityAsync"> |
|||
<Form |
|||
@ref="@CreateFormRef" |
|||
Layout="@FormLayout.Vertical" |
|||
Model="@NewEntity"> |
|||
@if (CreateModalVisible) |
|||
{ |
|||
<Tabs> |
|||
<TabPane Tab="@L["UserInformations"]"> |
|||
<FormItem Label="@L["DisplayName:UserName"]"> |
|||
<Input @bind-Value="@context.UserName"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["DisplayName:Name"]"> |
|||
<Input @bind-Value="@context.Name"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["DisplayName:Surname"]"> |
|||
<Input @bind-Value="@context.Surname"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["DisplayName:Password"]"> |
|||
<InputPassword @bind-Value="@context.Password"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["DisplayName:Email"]"> |
|||
<Input @bind-Value="@context.Email"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["DisplayName:PhoneNumber"]"> |
|||
<Input @bind-Value="@context.PhoneNumber"/> |
|||
</FormItem> |
|||
<FormItem> |
|||
<Checkbox @bind-Value="context.IsActive">@L["DisplayName:IsActive"]</Checkbox> |
|||
</FormItem> |
|||
<FormItem> |
|||
<Checkbox @bind-Value="context.LockoutEnabled">@L["DisplayName:LockoutEnabled"]</Checkbox> |
|||
</FormItem> |
|||
</TabPane> |
|||
|
|||
<TabPane Tab="@L["Roles"]"> |
|||
@foreach (var role in NewUserRoles) |
|||
{ |
|||
<FormItem WrapperColOffset="2"> |
|||
<Checkbox @bind-Value="role.IsAssigned">@role.Name</Checkbox> |
|||
</FormItem> |
|||
} |
|||
</TabPane> |
|||
</Tabs> |
|||
} |
|||
</Form> |
|||
</Modal> |
|||
} |
|||
|
|||
@if (HasUpdatePermission) |
|||
{ |
|||
<Modal @ref="EditModal" Title="@L["Edit"]" Visible="@EditModalVisible" OnCancel="@CloseEditModalAsync" OnOk="UpdateEntityAsync"> |
|||
<Form |
|||
@ref="@EditFormRef" |
|||
Layout="@FormLayout.Vertical" |
|||
Model="@EditingEntity"> |
|||
@if (EditModalVisible) |
|||
{ |
|||
<Tabs> |
|||
<TabPane Tab="@L["UserInformations"]"> |
|||
<FormItem Label="@L["DisplayName:UserName"]"> |
|||
<Input @bind-Value="@context.UserName"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["DisplayName:Name"]"> |
|||
<Input @bind-Value="@context.Name"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["DisplayName:Surname"]"> |
|||
<Input @bind-Value="@context.Surname"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["DisplayName:Password"]"> |
|||
<InputPassword @bind-Value="@context.Password"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["DisplayName:Email"]"> |
|||
<Input @bind-Value="@context.Email"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["DisplayName:PhoneNumber"]"> |
|||
<Input @bind-Value="@context.PhoneNumber"/> |
|||
</FormItem> |
|||
<FormItem> |
|||
<Checkbox @bind-Value="context.IsActive">@L["DisplayName:IsActive"]</Checkbox> |
|||
</FormItem> |
|||
<FormItem> |
|||
<Checkbox @bind-Value="context.LockoutEnabled">@L["DisplayName:LockoutEnabled"]</Checkbox> |
|||
</FormItem> |
|||
</TabPane> |
|||
|
|||
<TabPane Tab="@L["Roles"]"> |
|||
@foreach (var role in EditUserRoles) |
|||
{ |
|||
<FormItem WrapperColOffset="2"> |
|||
<Checkbox @bind-Value="role.IsAssigned">@role.Name</Checkbox> |
|||
</FormItem> |
|||
} |
|||
</TabPane> |
|||
</Tabs> |
|||
} |
|||
</Form> |
|||
</Modal> |
|||
} |
|||
|
|||
|
|||
@if (HasManagePermissionsPermission) |
|||
{ |
|||
<PermissionManagementModal @ref="PermissionManagementModal"/> |
|||
} |
|||
@ -0,0 +1,212 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using AntDesign; |
|||
using Lsw.Abp.AntDesignUI; |
|||
using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.PageToolbars; |
|||
using Lsw.Abp.PermissionManagement.Blazor.AntDesignUI.Components; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Volo.Abp.AspNetCore.Components.Web.Extensibility.EntityActions; |
|||
using Volo.Abp.AspNetCore.Components.Web.Extensibility.TableColumns; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.Identity.Localization; |
|||
|
|||
namespace Lsw.Abp.IdentityManagement.Blazor.AntDesignUI.Pages; |
|||
|
|||
public partial class UserManagement |
|||
{ |
|||
protected const string PermissionProviderName = "U"; |
|||
|
|||
protected PermissionManagementModal PermissionManagementModal; |
|||
|
|||
protected IReadOnlyList<IdentityRoleDto> Roles; |
|||
|
|||
protected AssignedRoleViewModel[] NewUserRoles; |
|||
|
|||
protected AssignedRoleViewModel[] EditUserRoles; |
|||
|
|||
protected string ManagePermissionsPolicyName; |
|||
|
|||
protected bool HasManagePermissionsPermission { get; set; } |
|||
|
|||
protected PageToolbar Toolbar { get; } = new(); |
|||
|
|||
private List<TableColumn> UserManagementTableColumns => TableColumns.Get<UserManagement>(); |
|||
|
|||
public UserManagement() |
|||
{ |
|||
ObjectMapperContext = typeof(AbpIdentityBlazorAntDesignModule); |
|||
LocalizationResource = typeof(IdentityResource); |
|||
|
|||
CreatePolicyName = IdentityPermissions.Users.Create; |
|||
UpdatePolicyName = IdentityPermissions.Users.Update; |
|||
DeletePolicyName = IdentityPermissions.Users.Delete; |
|||
ManagePermissionsPolicyName = IdentityPermissions.Users.ManagePermissions; |
|||
} |
|||
|
|||
protected override async Task OnInitializedAsync() |
|||
{ |
|||
await base.OnInitializedAsync(); |
|||
|
|||
try |
|||
{ |
|||
Roles = (await AppService.GetAssignableRolesAsync()).Items; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
await HandleErrorAsync(ex); |
|||
} |
|||
} |
|||
|
|||
protected override ValueTask SetBreadcrumbItemsAsync() |
|||
{ |
|||
BreadcrumbItems = new List<AbpBreadcrumbItem>() |
|||
{ |
|||
new(L["Menu:IdentityManagement"]), |
|||
new(L["Users"]) |
|||
}; |
|||
|
|||
return base.SetBreadcrumbItemsAsync(); |
|||
} |
|||
|
|||
protected override async Task SetPermissionsAsync() |
|||
{ |
|||
await base.SetPermissionsAsync(); |
|||
|
|||
HasManagePermissionsPermission = |
|||
await AuthorizationService.IsGrantedAsync(IdentityPermissions.Users.ManagePermissions); |
|||
} |
|||
|
|||
protected override Task OpenCreateModalAsync() |
|||
{ |
|||
NewUserRoles = Roles.Select(x => new AssignedRoleViewModel |
|||
{ |
|||
Name = x.Name, |
|||
IsAssigned = x.IsDefault |
|||
}).ToArray(); |
|||
|
|||
return base.OpenCreateModalAsync(); |
|||
} |
|||
|
|||
protected override Task OnCreatingEntityAsync() |
|||
{ |
|||
// apply roles before saving
|
|||
NewEntity.RoleNames = NewUserRoles.Where(x => x.IsAssigned).Select(x => x.Name).ToArray(); |
|||
|
|||
return base.OnCreatingEntityAsync(); |
|||
} |
|||
|
|||
protected override async Task OpenEditModalAsync(IdentityUserDto entity) |
|||
{ |
|||
try |
|||
{ |
|||
var userRoleNames = (await AppService.GetRolesAsync(entity.Id)).Items.Select(r => r.Name).ToList(); |
|||
|
|||
EditUserRoles = Roles.Select(x => new AssignedRoleViewModel |
|||
{ |
|||
Name = x.Name, |
|||
IsAssigned = userRoleNames.Contains(x.Name) |
|||
}).ToArray(); |
|||
|
|||
await base.OpenEditModalAsync(entity); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
await HandleErrorAsync(ex); |
|||
} |
|||
} |
|||
|
|||
protected override Task OnUpdatingEntityAsync() |
|||
{ |
|||
// apply roles before saving
|
|||
EditingEntity.RoleNames = EditUserRoles.Where(x => x.IsAssigned).Select(x => x.Name).ToArray(); |
|||
|
|||
return base.OnUpdatingEntityAsync(); |
|||
} |
|||
|
|||
protected override string GetDeleteConfirmationMessage(IdentityUserDto entity) |
|||
{ |
|||
return string.Format(L["UserDeletionConfirmationMessage"], entity.UserName); |
|||
} |
|||
|
|||
protected override ValueTask SetEntityActionsAsync() |
|||
{ |
|||
EntityActions |
|||
.Get<UserManagement>() |
|||
.AddRange(new EntityAction[] |
|||
{ |
|||
new EntityAction |
|||
{ |
|||
Text = L["Edit"], |
|||
Visible = (data) => HasUpdatePermission, |
|||
Clicked = async (data) => await OpenEditModalAsync(data.As<IdentityUserDto>()) |
|||
}, |
|||
new EntityAction |
|||
{ |
|||
Text = L["Permissions"], |
|||
Visible = (data) => HasManagePermissionsPermission, |
|||
Clicked = async (data) => |
|||
{ |
|||
await PermissionManagementModal.OpenAsync(PermissionProviderName, |
|||
data.As<IdentityUserDto>().Id.ToString()); |
|||
} |
|||
}, |
|||
new EntityAction |
|||
{ |
|||
Text = L["Delete"], |
|||
Visible = (data) => HasDeletePermission, |
|||
Clicked = async (data) => await DeleteEntityAsync(data.As<IdentityUserDto>()), |
|||
ConfirmationMessage = (data) => GetDeleteConfirmationMessage(data.As<IdentityUserDto>()) |
|||
} |
|||
}); |
|||
|
|||
return base.SetEntityActionsAsync(); |
|||
} |
|||
|
|||
protected override ValueTask SetTableColumnsAsync() |
|||
{ |
|||
UserManagementTableColumns |
|||
.AddRange(new TableColumn[] |
|||
{ |
|||
new TableColumn |
|||
{ |
|||
Title = L["UserName"], |
|||
Data = nameof(IdentityUserDto.UserName), |
|||
}, |
|||
new TableColumn |
|||
{ |
|||
Title = L["Email"], |
|||
Data = nameof(IdentityUserDto.Email), |
|||
}, |
|||
new TableColumn |
|||
{ |
|||
Title = L["PhoneNumber"], |
|||
Data = nameof(IdentityUserDto.PhoneNumber), |
|||
}, |
|||
new TableColumn |
|||
{ |
|||
Title = L["Actions"], |
|||
Actions = EntityActions.Get<UserManagement>() |
|||
}, |
|||
}); |
|||
|
|||
return base.SetEntityActionsAsync(); |
|||
} |
|||
|
|||
protected override ValueTask SetToolbarItemsAsync() |
|||
{ |
|||
Toolbar.AddButton(L["NewUser"], OpenCreateModalAsync, |
|||
IconType.Outline.Plus, |
|||
requiredPolicyName: CreatePolicyName); |
|||
|
|||
return base.SetToolbarItemsAsync(); |
|||
} |
|||
} |
|||
|
|||
public class AssignedRoleViewModel |
|||
{ |
|||
public string Name { get; set; } |
|||
|
|||
public bool IsAssigned { get; set; } |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
@using Microsoft.AspNetCore.Components.Web |
|||
@using Volo.Abp.AspNetCore.Components.Web |
|||
@using Lsw.Abp.AntDesignUI |
|||
@using Lsw.Abp.AntDesignUI.Components |
|||
@using AntDesign |
|||
@using AntDesign.TableModels |
|||
@using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Layout |
|||
@ -0,0 +1,14 @@ |
|||
using Lsw.Abp.IdentityManagement.Blazor.AntDesignUI; |
|||
using Lsw.Abp.PermissionManagement.Blazor.AntDesignUI; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Lsw.Abp.IdentityManagement.Blazor.Server.AntDesignUI; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpIdentityBlazorAntDesignModule), |
|||
typeof(AbpPermissionManagementBlazorAntDesignModule) |
|||
)] |
|||
public class AbpIdentityBlazorServerAntDesignModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme\Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme.csproj" /> |
|||
<ProjectReference Include="..\Lsw.Abp.IdentityManagement.Blazor.AntDesignUI\Lsw.Abp.IdentityManagement.Blazor.AntDesignUI.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,15 @@ |
|||
using Lsw.Abp.IdentityManagement.Blazor.AntDesignUI; |
|||
using Lsw.Abp.PermissionManagement.Blazor.WebAssembly.AntDesignUI; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Lsw.Abp.IdentityManagement.Blazor.WebAssembly.AntDesignUI; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpIdentityBlazorAntDesignModule), |
|||
typeof(AbpPermissionManagementBlazorWebAssemblyAntDesignModule), |
|||
typeof(AbpIdentityHttpApiClientModule) |
|||
)] |
|||
public class AbpIdentityBlazorWebAssemblyAntDesignModule: AbpModule |
|||
{ |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Identity.HttpApi.Client" Version="5.1.4" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\PermissionManagement\Lsw.Abp.PermissionManagement.Blazor.WebAssembly.AntDesignUI\Lsw.Abp.PermissionManagement.Blazor.WebAssembly.AntDesignUI.csproj" /> |
|||
<ProjectReference Include="..\Lsw.Abp.IdentityManagement.Blazor.AntDesignUI\Lsw.Abp.IdentityManagement.Blazor.AntDesignUI.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
|
|||
</Project> |
|||
@ -0,0 +1,20 @@ |
|||
using System.Threading.Tasks; |
|||
using Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme.Themes.AntDesignTheme; |
|||
using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Toolbars; |
|||
|
|||
namespace Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme; |
|||
|
|||
|
|||
public class AntDesignThemeToolbarContributor: IToolbarContributor |
|||
{ |
|||
public Task ConfigureToolbarAsync(IToolbarConfigurationContext context) |
|||
{ |
|||
if (context.Toolbar.Name == StandardToolbars.Main) |
|||
{ |
|||
context.Toolbar.Items.Add(new ToolbarItem(typeof(LanguageSwitch))); |
|||
context.Toolbar.Items.Add(new ToolbarItem(typeof(LoginDisplay))); |
|||
} |
|||
|
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
namespace Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme.Bundling; |
|||
|
|||
public class BlazorAntDesignThemeBundles |
|||
{ |
|||
public static class Styles |
|||
{ |
|||
public static string Global = "Blazor.AntDesignTheme.Global"; |
|||
} |
|||
|
|||
public static class Scripts |
|||
{ |
|||
public static string Global = "Blazor.AntDesignTheme.Global"; |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
|||
|
|||
namespace Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme.Bundling; |
|||
|
|||
public class BlazorAntDesignThemeScriptContributor: BundleContributor |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System.Collections.Generic; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
|||
|
|||
namespace Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme.Bundling; |
|||
|
|||
public class BlazorAntDesignThemeStyleContributor: BundleContributor |
|||
{ |
|||
public override void ConfigureBundle(BundleConfigurationContext context) |
|||
{ |
|||
context.Files.AddIfNotContains("/_content/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/libs/abp/css/theme.css"); |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait /> |
|||
</Weavers> |
|||
@ -0,0 +1,64 @@ |
|||
@using Volo.Abp.Localization |
|||
@using System.Globalization |
|||
@using System.Collections.Immutable |
|||
@using Microsoft.AspNetCore.RequestLocalization |
|||
@inject ILanguageProvider LanguageProvider |
|||
@inject NavigationManager NavigationManager |
|||
@inject IAbpRequestLocalizationOptionsProvider RequestLocalizationOptionsProvider |
|||
|
|||
@if (_otherLanguages != null && _otherLanguages.Any()) |
|||
{ |
|||
<Dropdown> |
|||
<Overlay> |
|||
<Menu> |
|||
@foreach (var language in _otherLanguages) |
|||
{ |
|||
<MenuItem OnClick="() => ChangeLanguage(language)"> |
|||
@language.DisplayName |
|||
</MenuItem> |
|||
} |
|||
</Menu> |
|||
</Overlay> |
|||
<ChildContent> |
|||
<a class="ant-dropdown-link" @onclick:preventDefault> |
|||
@_currentLanguage.DisplayName <Icon Type="down" /> |
|||
</a> |
|||
</ChildContent> |
|||
</Dropdown> |
|||
} |
|||
|
|||
@code { |
|||
private IReadOnlyList<LanguageInfo> _otherLanguages; |
|||
private LanguageInfo _currentLanguage; |
|||
|
|||
protected override async Task OnInitializedAsync() |
|||
{ |
|||
var languages = await LanguageProvider.GetLanguagesAsync(); |
|||
var currentLanguage = languages.FindByCulture( |
|||
CultureInfo.CurrentCulture.Name, |
|||
CultureInfo.CurrentUICulture.Name |
|||
); |
|||
|
|||
if (currentLanguage == null) |
|||
{ |
|||
var localizationOptions = await RequestLocalizationOptionsProvider.GetLocalizationOptionsAsync(); |
|||
currentLanguage = new LanguageInfo( |
|||
localizationOptions.DefaultRequestCulture.Culture.Name, |
|||
localizationOptions.DefaultRequestCulture.UICulture.Name, |
|||
localizationOptions.DefaultRequestCulture.UICulture.DisplayName); |
|||
} |
|||
|
|||
_currentLanguage = currentLanguage; |
|||
_otherLanguages = languages.Where(l => l != _currentLanguage).ToImmutableList(); |
|||
} |
|||
|
|||
private void ChangeLanguage(LanguageInfo language) |
|||
{ |
|||
var relativeUrl = NavigationManager.Uri.RemovePreFix(NavigationManager.BaseUri).EnsureStartsWith('/').EnsureStartsWith('~'); |
|||
|
|||
NavigationManager.NavigateTo( |
|||
$"Abp/Languages/Switch?culture={language.CultureName}&uiCulture={language.UiCultureName}&returnUrl={relativeUrl}", |
|||
forceLoad: true |
|||
); |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
@using Volo.Abp.Users |
|||
@using Volo.Abp.MultiTenancy |
|||
@using Microsoft.Extensions.Localization |
|||
@using global::Localization.Resources.AbpUi |
|||
@inject ICurrentUser CurrentUser |
|||
@inject ICurrentTenant CurrentTenant |
|||
@inject IJSRuntime JsRuntime |
|||
@inject NavigationManager Navigation |
|||
@inject IStringLocalizer<AbpUiResource> L |
|||
|
|||
<AuthorizeView> |
|||
<Authorized> |
|||
<Dropdown> |
|||
<Overlay> |
|||
<Menu> |
|||
@if (Menu != null) |
|||
{ |
|||
@foreach (var menuItem in Menu.Items) |
|||
{ |
|||
<a class="nav-link ant-dropdown-menu-item" target="@menuItem.Target" href="@menuItem.Url?.TrimStart('/', '~')">@menuItem.DisplayName</a> |
|||
} |
|||
} |
|||
<MenuDivider/> |
|||
</Menu> |
|||
</Overlay> |
|||
<ChildContent> |
|||
@if (CurrentTenant.Name != null) |
|||
{ |
|||
<span><i>@CurrentTenant.Name</i>\@CurrentUser.UserName</span> |
|||
} |
|||
else |
|||
{ |
|||
<span>@CurrentUser.UserName</span> |
|||
} |
|||
<Icon Type="down" /> |
|||
</ChildContent> |
|||
</Dropdown> |
|||
</Authorized> |
|||
<NotAuthorized> |
|||
<a class="nav-link" href="Account/Login">@L["Login"]</a> |
|||
</NotAuthorized> |
|||
</AuthorizeView> |
|||
@ -0,0 +1,32 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Microsoft.AspNetCore.Components.Routing; |
|||
using Volo.Abp.UI.Navigation; |
|||
|
|||
namespace Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme.Themes.AntDesignTheme; |
|||
|
|||
public partial class LoginDisplay : IDisposable |
|||
{ |
|||
[Inject] |
|||
protected IMenuManager MenuManager { get; set; } |
|||
|
|||
protected ApplicationMenu Menu { get; set; } |
|||
|
|||
protected override async Task OnInitializedAsync() |
|||
{ |
|||
Menu = await MenuManager.GetAsync(StandardMenus.User); |
|||
|
|||
Navigation.LocationChanged += OnLocationChanged; |
|||
} |
|||
|
|||
protected virtual void OnLocationChanged(object sender, LocationChangedEventArgs e) |
|||
{ |
|||
InvokeAsync(StateHasChanged); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
Navigation.LocationChanged -= OnLocationChanged; |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
@using Microsoft.AspNetCore.Components.Web |
|||
@using System.Net.Http |
|||
@using Microsoft.AspNetCore.Components.Authorization |
|||
@using Microsoft.AspNetCore.Components.Forms |
|||
@using Microsoft.AspNetCore.Components.Routing |
|||
@using Microsoft.JSInterop |
|||
@using AntDesign |
|||
@ -0,0 +1,16 @@ |
|||
using Lsw.Abp.AntDesignUI; |
|||
using Volo.Abp.AutoMapper; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.PermissionManagement; |
|||
|
|||
namespace Lsw.Abp.PermissionManagement.Blazor.AntDesignUI; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpAntDesignUIModule), |
|||
typeof(AbpAutoMapperModule), |
|||
typeof(AbpPermissionManagementApplicationContractsModule) |
|||
)] |
|||
public class AbpPermissionManagementBlazorAntDesignModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
@inherits Volo.Abp.AspNetCore.Components.AbpComponentBase |
|||
|
|||
<Modal Title="@($"{L["Permissions"]} - {_entityDisplayName}")" |
|||
Visible="@_visible" |
|||
OnOk="@SaveAsync" |
|||
OnCancel="@ClosingModal" Style="min-width: 700px"> |
|||
|
|||
@if (_visible) |
|||
{ |
|||
var grantAll = _groups.All(x => x.Permissions.All(p => p.IsGranted)); |
|||
<Checkbox @bind-Checked="@grantAll" OnChange="@GrantAllChanged">@L["SelectAllInAllTabs"]</Checkbox> |
|||
<Divider/> |
|||
|
|||
@if (_groups != null) |
|||
{ |
|||
<Tabs DefaultActiveKey="@_selectedTabName" TabPosition="@TabPosition.Left"> |
|||
@foreach (var group in _groups) |
|||
{ |
|||
var selectAllInThisTab = group.Permissions.All(x => x.IsGranted); |
|||
<TabPane Key="@GetNormalizedGroupName(group.Name)" Tab="@group.DisplayName"> |
|||
<h4>@group.DisplayName</h4> |
|||
<Divider/> |
|||
<Checkbox |
|||
@bind-Checked="@selectAllInThisTab" |
|||
OnChange="b => GroupGrantAllChanged(b, group)"> |
|||
@L["SelectAllInThisTab"] |
|||
</Checkbox> |
|||
|
|||
<Divider/> |
|||
|
|||
@foreach (var permission in group.Permissions) |
|||
{ |
|||
var margin = permission.ParentName != null ? "1rem" : "0"; |
|||
<div style="margin: @margin"> |
|||
<Checkbox |
|||
Disabled="@(IsDisabledPermission(permission))" |
|||
@bind-Checked="@permission.IsGranted" |
|||
OnChange="b => PermissionChanged(b, group, permission)"> |
|||
@GetShownName(permission) |
|||
</Checkbox> |
|||
</div> |
|||
} |
|||
</TabPane> |
|||
} |
|||
</Tabs> |
|||
} |
|||
} |
|||
</Modal> |
|||
@ -0,0 +1,187 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Microsoft.AspNetCore.Components.Web; |
|||
using Volo.Abp.AspNetCore.Components.Web.Configuration; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.PermissionManagement.Localization; |
|||
|
|||
namespace Lsw.Abp.PermissionManagement.Blazor.AntDesignUI.Components; |
|||
|
|||
public partial class PermissionManagementModal |
|||
{ |
|||
[Inject] |
|||
protected IPermissionAppService PermissionAppService { get; set; } |
|||
|
|||
[Inject] |
|||
protected ICurrentApplicationConfigurationCacheResetService CurrentApplicationConfigurationCacheResetService { get; set; } |
|||
|
|||
private string _providerName; |
|||
private string _providerKey; |
|||
private bool _visible; |
|||
|
|||
private string _entityDisplayName; |
|||
private List<PermissionGroupDto> _groups; |
|||
private List<PermissionGrantInfoDto> _disabledPermissions = new(); |
|||
private string _selectedTabName; |
|||
|
|||
public PermissionManagementModal() |
|||
{ |
|||
LocalizationResource = typeof(AbpPermissionManagementResource); |
|||
} |
|||
|
|||
private async Task SaveAsync(MouseEventArgs e) |
|||
{ |
|||
try |
|||
{ |
|||
var updateDto = new UpdatePermissionsDto |
|||
{ |
|||
Permissions = _groups |
|||
.SelectMany(g => g.Permissions) |
|||
.Select(p => new UpdatePermissionDto { IsGranted = p.IsGranted, Name = p.Name }) |
|||
.ToArray() |
|||
}; |
|||
|
|||
await PermissionAppService.UpdateAsync(_providerName, _providerKey, updateDto); |
|||
|
|||
await CurrentApplicationConfigurationCacheResetService.ResetAsync(); |
|||
|
|||
_visible = false; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
await HandleErrorAsync(ex); |
|||
} |
|||
} |
|||
|
|||
private void ClosingModal(MouseEventArgs e) |
|||
{ |
|||
_visible = false; |
|||
} |
|||
|
|||
public async Task OpenAsync(string providerName, string providerKey, string entityDisplayName = null) |
|||
{ |
|||
try |
|||
{ |
|||
_providerName = providerName; |
|||
_providerKey = providerKey; |
|||
|
|||
var result = await PermissionAppService.GetAsync(_providerName, _providerKey); |
|||
|
|||
_entityDisplayName = entityDisplayName ?? result.EntityDisplayName; |
|||
_groups = result.Groups; |
|||
|
|||
foreach (var permission in _groups.SelectMany(x => x.Permissions)) |
|||
{ |
|||
if (permission.IsGranted && permission.GrantedProviders.All(x => x.ProviderName != _providerName)) |
|||
{ |
|||
_disabledPermissions.Add(permission); |
|||
} |
|||
} |
|||
|
|||
_selectedTabName = GetNormalizedGroupName(_groups.First().Name); |
|||
|
|||
_visible = true; |
|||
StateHasChanged(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
await HandleErrorAsync(ex); |
|||
} |
|||
} |
|||
|
|||
private string GetNormalizedGroupName(string name) |
|||
{ |
|||
return "PermissionGroup_" + name.Replace(".", "_"); |
|||
} |
|||
|
|||
private void GrantAllChanged(bool value) |
|||
{ |
|||
foreach (var groupDto in _groups) |
|||
{ |
|||
foreach (var permission in groupDto.Permissions) |
|||
{ |
|||
if (!IsDisabledPermission(permission)) |
|||
{ |
|||
SetPermissionGrant(permission, value); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
private void GroupGrantAllChanged(bool value, PermissionGroupDto permissionGroup) |
|||
{ |
|||
foreach (var permission in permissionGroup.Permissions) |
|||
{ |
|||
if (!IsDisabledPermission(permission)) |
|||
{ |
|||
SetPermissionGrant(permission, value); |
|||
} |
|||
} |
|||
} |
|||
|
|||
private bool IsDisabledPermission(PermissionGrantInfoDto permissionGrantInfo) |
|||
{ |
|||
return _disabledPermissions.Any(x => x == permissionGrantInfo); |
|||
} |
|||
|
|||
private void PermissionChanged(bool value, PermissionGroupDto permissionGroup, PermissionGrantInfoDto permission) |
|||
{ |
|||
SetPermissionGrant(permission, value); |
|||
|
|||
if (value && permission.ParentName != null) |
|||
{ |
|||
var parentPermission = GetParentPermission(permissionGroup, permission); |
|||
|
|||
SetPermissionGrant(parentPermission, true); |
|||
} |
|||
else if (value == false) |
|||
{ |
|||
var childPermissions = GetChildPermissions(permissionGroup, permission); |
|||
|
|||
foreach (var childPermission in childPermissions) |
|||
{ |
|||
SetPermissionGrant(childPermission, false); |
|||
} |
|||
} |
|||
} |
|||
|
|||
private void SetPermissionGrant(PermissionGrantInfoDto permission, bool value) |
|||
{ |
|||
if (permission.IsGranted == value) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
permission.IsGranted = value; |
|||
} |
|||
|
|||
private PermissionGrantInfoDto GetParentPermission(PermissionGroupDto permissionGroup, PermissionGrantInfoDto permission) |
|||
{ |
|||
return permissionGroup.Permissions.First(x => x.Name == permission.ParentName); |
|||
} |
|||
|
|||
private List<PermissionGrantInfoDto> GetChildPermissions(PermissionGroupDto permissionGroup, PermissionGrantInfoDto permission) |
|||
{ |
|||
return permissionGroup.Permissions.Where(x => x.Name.StartsWith(permission.Name)).ToList(); |
|||
} |
|||
|
|||
private string GetShownName(PermissionGrantInfoDto permissionGrantInfo) |
|||
{ |
|||
if (!IsDisabledPermission(permissionGrantInfo)) |
|||
{ |
|||
return permissionGrantInfo.DisplayName; |
|||
} |
|||
|
|||
return string.Format( |
|||
"{0} ({1})", |
|||
permissionGrantInfo.DisplayName, |
|||
permissionGrantInfo.GrantedProviders |
|||
.Where(p => p.ProviderName != _providerName) |
|||
.Select(p => p.ProviderName) |
|||
.JoinAsString(", ") |
|||
); |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.AutoMapper" Version="5.1.4" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.Application.Contracts" Version="5.1.4" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\src\Lsw.Abp.AntDesignUI\Lsw.Abp.AntDesignUI.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,6 @@ |
|||
@using Microsoft.AspNetCore.Components.Web |
|||
@using Volo.Abp.AspNetCore.Components.Web |
|||
@using AntDesign |
|||
@using Lsw.Abp.AntDesignUI |
|||
@using Lsw.Abp.AntDesignUI.Components |
|||
@using Lsw.Abp.PermissionManagement.Blazor.AntDesignUI.Components |
|||
@ -0,0 +1,13 @@ |
|||
using Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme; |
|||
using Lsw.Abp.PermissionManagement.Blazor.AntDesignUI; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Lsw.Abp.PermissionManagement.Blazor.Server.AntDesignUI; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpPermissionManagementBlazorAntDesignModule), |
|||
typeof(AbpAspNetCoreComponentsServerAntDesignThemeModule) |
|||
)] |
|||
public class AbpPermissionManagementBlazorServerAntDesignModule : AbpModule |
|||
{ |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme\Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme.csproj" /> |
|||
<ProjectReference Include="..\Lsw.Abp.PermissionManagement.Blazor.AntDesignUI\Lsw.Abp.PermissionManagement.Blazor.AntDesignUI.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,15 @@ |
|||
using Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme; |
|||
using Lsw.Abp.PermissionManagement.Blazor.AntDesignUI; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.PermissionManagement; |
|||
|
|||
namespace Lsw.Abp.PermissionManagement.Blazor.WebAssembly.AntDesignUI; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpPermissionManagementBlazorAntDesignModule), |
|||
typeof(AbpAspNetCoreComponentsWebAssemblyAntDesignThemeModule), |
|||
typeof(AbpPermissionManagementHttpApiClientModule) |
|||
)] |
|||
public class AbpPermissionManagementBlazorWebAssemblyAntDesignModule : AbpModule |
|||
{ |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.HttpApi.Client" Version="5.1.4" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme\Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme.csproj" /> |
|||
<ProjectReference Include="..\Lsw.Abp.PermissionManagement.Blazor.AntDesignUI\Lsw.Abp.PermissionManagement.Blazor.AntDesignUI.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,43 @@ |
|||
using AutoMapper; |
|||
using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme; |
|||
using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Routing; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.AutoMapper; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.SettingManagement.Blazor.AntDesignUI.Settings; |
|||
using Volo.Abp.UI.Navigation; |
|||
|
|||
namespace Volo.Abp.SettingManagement.Blazor.AntDesignUI; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpAutoMapperModule), |
|||
typeof(AbpSettingManagementApplicationContractsModule), |
|||
typeof(AbpAspNetCoreComponentsWebAntDesignThemeModule) |
|||
)] |
|||
public class AbpSettingManagementBlazorAntDesignModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddAutoMapperObjectMapper<AbpSettingManagementBlazorAntDesignModule>(); |
|||
|
|||
Configure<AbpAutoMapperOptions>(options => |
|||
{ |
|||
options.AddProfile<SettingManagementBlazorAutoMapperProfile>(validate: true); |
|||
}); |
|||
|
|||
Configure<AbpNavigationOptions>(options => |
|||
{ |
|||
options.MenuContributors.Add(new SettingManagementMenuContributor()); |
|||
}); |
|||
|
|||
Configure<AbpRouterOptions>(options => |
|||
{ |
|||
options.AdditionalAssemblies.Add(typeof(AbpSettingManagementBlazorAntDesignModule).Assembly); |
|||
}); |
|||
|
|||
Configure<SettingManagementComponentOptions>(options => |
|||
{ |
|||
options.Contributors.Add(new AntDesignSettingDefultPageContributor()); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System.Threading.Tasks; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace Volo.Abp.SettingManagement.Blazor; |
|||
|
|||
public interface ISettingComponentContributor |
|||
{ |
|||
Task ConfigureAsync(SettingComponentCreationContext context); |
|||
|
|||
Task<bool> CheckPermissionsAsync(SettingComponentCreationContext context); |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
@using Volo.Abp.SettingManagement.Localization |
|||
@inherits Volo.Abp.AspNetCore.Components.AbpComponentBase |
|||
@inject AbpBlazorMessageLocalizerHelper<AbpSettingManagementResource> LH |
|||
|
|||
<Form |
|||
Layout="@FormLayout.Vertical" |
|||
Model="@AbpAntDesignThemeOptions"> |
|||
|
|||
<FormItem Label="Menu placement"> |
|||
<Select DataSource="@MenuPlacements" |
|||
ValueName="@nameof(SelectOptionItem.Value)" |
|||
LabelName="@nameof(SelectOptionItem.Text)" |
|||
@bind-Value="@context.Menu.Placement"> |
|||
</Select> |
|||
</FormItem> |
|||
|
|||
<FormItem Label="Menu theme"> |
|||
<Select DataSource="@MenuThemes" |
|||
ValueName="@nameof(SelectOptionItem.Value)" |
|||
LabelName="@nameof(SelectOptionItem.Text)" |
|||
@bind-Value="@context.Menu.Theme"> |
|||
</Select> |
|||
</FormItem> |
|||
|
|||
<FormItem WrapperColOffset="8"> |
|||
<Button Type="@ButtonType.Primary" HtmlType="submit" OnClick="@UpdateSettingAsync"> |
|||
@L["Submit"] |
|||
</Button> |
|||
</FormItem> |
|||
</Form> |
|||
@ -0,0 +1,70 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using AntDesign; |
|||
using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme; |
|||
using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Settings; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.Abp.SettingManagement.Localization; |
|||
|
|||
namespace Volo.Abp.SettingManagement.Blazor.AntDesignUI.Pages.SettingManagement.AntDesignThemeGroup; |
|||
|
|||
|
|||
//TODO localization
|
|||
public partial class AntDesignThemeGroupViewComponent |
|||
{ |
|||
public const string Name = "Volo.Abp.AntDesignThemeGroupViewComponent"; |
|||
|
|||
[Inject] |
|||
protected IOptions<AbpAntDesignThemeOptions> Options { get; set; } |
|||
|
|||
[Inject] |
|||
protected IAntDesignSettingsProvider AntDesignSettingsProvider { get; set; } |
|||
|
|||
[CascadingParameter] |
|||
protected SettingManagement SettingManagement { get; set; } |
|||
|
|||
protected AbpAntDesignThemeOptions AbpAntDesignThemeOptions { get; set; } = new(); |
|||
|
|||
protected readonly List<SelectOptionItem> MenuPlacements = new() |
|||
{ |
|||
new SelectOptionItem("Left",MenuPlacement.Left), |
|||
new SelectOptionItem("Top",MenuPlacement.Top) |
|||
}; |
|||
|
|||
protected readonly List<SelectOptionItem> MenuThemes = new() |
|||
{ |
|||
new SelectOptionItem("Dark",MenuTheme.Dark), |
|||
new SelectOptionItem("Light",MenuTheme.Light) |
|||
}; |
|||
|
|||
public AntDesignThemeGroupViewComponent() |
|||
{ |
|||
LocalizationResource = typeof(AbpSettingManagementResource); |
|||
} |
|||
|
|||
protected override void OnInitialized() |
|||
{ |
|||
AbpAntDesignThemeOptions = Options.Value; |
|||
} |
|||
|
|||
private async Task UpdateSettingAsync() |
|||
{ |
|||
await AntDesignSettingsProvider.TriggerSettingChanged(); |
|||
|
|||
await Notify.Success(L["SuccessfullySaved"]); |
|||
} |
|||
} |
|||
|
|||
public class SelectOptionItem |
|||
{ |
|||
public SelectOptionItem(string text, object value) |
|||
{ |
|||
Text = text; |
|||
Value = value; |
|||
} |
|||
|
|||
public string Text { get; set; } |
|||
|
|||
public object Value { get; set; } |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
@using Volo.Abp.SettingManagement.Localization |
|||
@inherits Volo.Abp.AspNetCore.Components.AbpComponentBase |
|||
@inject AbpBlazorMessageLocalizerHelper<AbpSettingManagementResource> LH |
|||
|
|||
<Form |
|||
Layout="@FormLayout.Vertical" |
|||
Model="@EmailSettings"> |
|||
|
|||
<FormItem Label="@L["DefaultFromDisplayName"]"> |
|||
<Input @bind-Value="@context.DefaultFromDisplayName"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["DefaultFromAddress"]"> |
|||
<Input @bind-Value="@context.DefaultFromAddress"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["SmtpHost"]"> |
|||
<Input @bind-Value="@context.SmtpHost"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["SmtpPort"]"> |
|||
<Input @bind-Value="@context.SmtpPort"/> |
|||
</FormItem> |
|||
<FormItem> |
|||
<Checkbox @bind-Value="context.SmtpEnableSsl">@L["SmtpEnableSsl"]</Checkbox> |
|||
</FormItem> |
|||
<FormItem> |
|||
<Checkbox @bind-Value="context.SmtpUseDefaultCredentials">@L["SmtpUseDefaultCredentials"]</Checkbox> |
|||
</FormItem> |
|||
|
|||
@if (EmailSettings.SmtpUseDefaultCredentials) |
|||
{ |
|||
<FormItem Label="@L["SmtpDomain"]"> |
|||
<Input @bind-Value="@context.SmtpDomain"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["SmtpUserName"]"> |
|||
<Input @bind-Value="@context.SmtpUserName"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["Password"]"> |
|||
<InputPassword @bind-Value="@context.SmtpPassword"/> |
|||
</FormItem> |
|||
} |
|||
|
|||
<FormItem WrapperColOffset="8"> |
|||
<Button Type="@ButtonType.Primary" HtmlType="submit" OnClick="@UpdateSettingsAsync"> |
|||
@L["Submit"] |
|||
</Button> |
|||
</FormItem> |
|||
</Form> |
|||
@ -0,0 +1,54 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using AutoMapper; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Volo.Abp.AspNetCore.Components.Messages; |
|||
using Volo.Abp.AspNetCore.Components.Web.Configuration; |
|||
using Volo.Abp.SettingManagement.Localization; |
|||
|
|||
namespace Volo.Abp.SettingManagement.Blazor.AntDesignUI.Pages.SettingManagement.EmailSettingGroup; |
|||
|
|||
public partial class EmailSettingGroupViewComponent |
|||
{ |
|||
[Inject] |
|||
protected IEmailSettingsAppService EmailSettingsAppService { get; set; } |
|||
|
|||
[Inject] |
|||
private ICurrentApplicationConfigurationCacheResetService CurrentApplicationConfigurationCacheResetService { get; set; } |
|||
|
|||
protected EmailSettingsDto EmailSettings = new(); |
|||
|
|||
public EmailSettingGroupViewComponent() |
|||
{ |
|||
ObjectMapperContext = typeof(AbpSettingManagementBlazorAntDesignModule); |
|||
LocalizationResource = typeof(AbpSettingManagementResource); |
|||
} |
|||
|
|||
protected override async Task OnInitializedAsync() |
|||
{ |
|||
try |
|||
{ |
|||
EmailSettings = await EmailSettingsAppService.GetAsync(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
await HandleErrorAsync(ex); |
|||
} |
|||
} |
|||
|
|||
protected virtual async Task UpdateSettingsAsync() |
|||
{ |
|||
try |
|||
{ |
|||
await EmailSettingsAppService.UpdateAsync(ObjectMapper.Map<EmailSettingsDto, UpdateEmailSettingsDto>(EmailSettings)); |
|||
|
|||
await CurrentApplicationConfigurationCacheResetService.ResetAsync(); |
|||
|
|||
await Message.Success(L["SuccessfullySaved"]); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
await HandleErrorAsync(ex); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
@page "/setting-management" |
|||
@using Microsoft.AspNetCore.Authorization |
|||
@using Volo.Abp.Features |
|||
@using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Layout |
|||
@attribute [Authorize] |
|||
@attribute [RequiresFeature(SettingManagementFeatures.Enable)] |
|||
|
|||
<CascadingValue Value="this" IsFixed="true"> |
|||
|
|||
<AbpPageHeader Title="@L["Settings"]" BreadcrumbItems="@BreadcrumbItems"/> |
|||
|
|||
<div class="page-content"> |
|||
<Tabs ActiveKey="@SelectedGroup" TabPosition="@TabPosition.Left"> |
|||
@foreach (var group in SettingComponentCreationContext.Groups) |
|||
{ |
|||
<TabPane Key="@GetNormalizedString(group.Id)" Tab="@group.DisplayName"> |
|||
<h4>@group.DisplayName</h4> |
|||
<Divider/> |
|||
|
|||
@{ |
|||
SettingItemRenders.Add(b => |
|||
{ |
|||
b.OpenComponent(0, group.ComponentType); |
|||
b.CloseComponent(); |
|||
}); |
|||
} |
|||
@SettingItemRenders.Last() |
|||
|
|||
</TabPane> |
|||
} |
|||
</Tabs> |
|||
</div> |
|||
</CascadingValue> |
|||
@ -0,0 +1,57 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using AntDesign; |
|||
using Lsw.Abp.AntDesignUI; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Microsoft.Extensions.Localization; |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.Abp.SettingManagement.Blazor.AntDesignUI.Pages.SettingManagement.AntDesignThemeGroup; |
|||
using Volo.Abp.SettingManagement.Localization; |
|||
|
|||
namespace Volo.Abp.SettingManagement.Blazor.AntDesignUI.Pages.SettingManagement; |
|||
|
|||
public partial class SettingManagement |
|||
{ |
|||
[Inject] |
|||
protected IServiceProvider ServiceProvider { get; set; } |
|||
|
|||
protected SettingComponentCreationContext SettingComponentCreationContext { get; set; } |
|||
|
|||
[Inject] |
|||
protected IOptions<SettingManagementComponentOptions> _options { get; set; } |
|||
|
|||
[Inject] |
|||
protected IStringLocalizer<AbpSettingManagementResource> L { get; set; } |
|||
|
|||
protected SettingManagementComponentOptions Options => _options.Value; |
|||
|
|||
protected List<RenderFragment> SettingItemRenders { get; set; } = new(); |
|||
|
|||
protected string SelectedGroup { get; set; } |
|||
protected List<AbpBreadcrumbItem> BreadcrumbItems = new(); |
|||
|
|||
|
|||
protected override async Task OnInitializedAsync() |
|||
{ |
|||
BreadcrumbItems = new List<AbpBreadcrumbItem> |
|||
{ |
|||
new(L["Settings"]) |
|||
}; |
|||
|
|||
SettingComponentCreationContext = new SettingComponentCreationContext(ServiceProvider); |
|||
|
|||
foreach (var contributor in Options.Contributors) |
|||
{ |
|||
await contributor.ConfigureAsync(SettingComponentCreationContext); |
|||
} |
|||
|
|||
SettingItemRenders.Clear(); |
|||
} |
|||
|
|||
protected virtual string GetNormalizedString(string value) |
|||
{ |
|||
return value.Replace('.', '_'); |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
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,38 @@ |
|||
// ReSharper disable once CheckNamespace
|
|||
|
|||
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,11 @@ |
|||
using AutoMapper; |
|||
|
|||
namespace Volo.Abp.SettingManagement.Blazor.AntDesignUI; |
|||
|
|||
public class SettingManagementBlazorAutoMapperProfile : Profile |
|||
{ |
|||
public SettingManagementBlazorAutoMapperProfile() |
|||
{ |
|||
CreateMap<EmailSettingsDto, UpdateEmailSettingsDto>(); |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// ReSharper disable once CheckNamespace
|
|||
|
|||
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,62 @@ |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using AntDesign; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.Abp.Features; |
|||
using Volo.Abp.SettingManagement.Localization; |
|||
using Volo.Abp.UI.Navigation; |
|||
|
|||
namespace Volo.Abp.SettingManagement.Blazor.AntDesignUI; |
|||
|
|||
public class SettingManagementMenuContributor : IMenuContributor |
|||
{ |
|||
public async Task ConfigureMenuAsync(MenuConfigurationContext context) |
|||
{ |
|||
if (context.Menu.Name == StandardMenus.Main) |
|||
{ |
|||
await ConfigureMainMenuAsync(context); |
|||
} |
|||
} |
|||
|
|||
private async Task ConfigureMainMenuAsync(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().TryRemoveMenuItem(SettingManagementMenus.GroupName); |
|||
|
|||
context.Menu |
|||
.GetAdministration() |
|||
.AddItem( |
|||
new ApplicationMenuItem( |
|||
SettingManagementMenus.GroupName, |
|||
l["Settings"], |
|||
"~/setting-management", |
|||
icon: IconType.Outline.Setting |
|||
).RequireFeatures(SettingManagementFeatures.Enable) |
|||
); |
|||
} |
|||
|
|||
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,6 @@ |
|||
namespace Volo.Abp.SettingManagement.Blazor.AntDesignUI; |
|||
|
|||
public class SettingManagementMenus |
|||
{ |
|||
public const string GroupName = "SettingManagement"; |
|||
} |
|||
@ -0,0 +1,71 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Localization; |
|||
using Volo.Abp.Features; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.SettingManagement.Blazor.AntDesignUI.Pages.SettingManagement.AntDesignThemeGroup; |
|||
using Volo.Abp.SettingManagement.Blazor.AntDesignUI.Pages.SettingManagement.EmailSettingGroup; |
|||
using Volo.Abp.SettingManagement.Localization; |
|||
|
|||
namespace Volo.Abp.SettingManagement.Blazor.AntDesignUI.Settings; |
|||
|
|||
public class AntDesignSettingDefultPageContributor : ISettingComponentContributor |
|||
{ |
|||
public async Task ConfigureAsync(SettingComponentCreationContext context) |
|||
{ |
|||
if (!await CheckPermissionsInternalAsync(context)) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpSettingManagementResource>>(); |
|||
context.Groups.Add( |
|||
new SettingComponentGroup( |
|||
"Volo.Abp.SettingManagement", |
|||
l["Menu:Emailing"], |
|||
typeof(EmailSettingGroupViewComponent) |
|||
) |
|||
); |
|||
|
|||
context.Groups.Add( |
|||
new SettingComponentGroup( |
|||
AntDesignThemeGroupViewComponent.Name, |
|||
"Theme", |
|||
typeof(AntDesignThemeGroupViewComponent) |
|||
) |
|||
); |
|||
} |
|||
|
|||
public async Task<bool> CheckPermissionsAsync(SettingComponentCreationContext context) |
|||
{ |
|||
return await CheckPermissionsInternalAsync(context); |
|||
} |
|||
|
|||
private async Task<bool> CheckPermissionsInternalAsync(SettingComponentCreationContext context) |
|||
{ |
|||
if (!await CheckFeatureAsync(context)) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>(); |
|||
|
|||
return await authorizationService.IsGrantedAsync(SettingManagementPermissions.Emailing); |
|||
} |
|||
|
|||
private async Task<bool> CheckFeatureAsync(SettingComponentCreationContext context) |
|||
{ |
|||
var currentTenant = context.ServiceProvider.GetRequiredService<ICurrentTenant>(); |
|||
|
|||
if (!currentTenant.IsAvailable) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
var featureCheck = context.ServiceProvider.GetRequiredService<IFeatureChecker>(); |
|||
|
|||
return await featureCheck.IsEnabledAsync(SettingManagementFeatures.AllowTenantsToChangeEmailSettings); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.AutoMapper" Version="5.1.4" /> |
|||
<PackageReference Include="Volo.Abp.SettingManagement.Application.Contracts" Version="5.1.4" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\FeatureManagement\Lsw.Abp.FeatureManagement.Blazor.AntDesignUI\Lsw.Abp.FeatureManagement.Blazor.AntDesignUI.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
@using Microsoft.AspNetCore.Components.Web |
|||
@using Volo.Abp.AspNetCore.Components.Web |
|||
@using AntDesign |
|||
@using Lsw.Abp.AntDesignUI |
|||
@using Lsw.Abp.AntDesignUI.Components |
|||
@ -0,0 +1,14 @@ |
|||
using Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.SettingManagement.Blazor.AntDesignUI; |
|||
|
|||
namespace Volo.Abp.SettingManagement.Blazor.Server.AntDesignUI; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpSettingManagementBlazorAntDesignModule), |
|||
typeof(AbpAspNetCoreComponentsServerAntDesignThemeModule) |
|||
)] |
|||
public class AbpSettingManagementBlazorWebAssemblyAntDesignModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme\Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme.csproj" /> |
|||
<ProjectReference Include="..\Volo.Abp.SettingManagement.Blazor.AntDesignUI\Volo.Abp.SettingManagement.Blazor.AntDesignUI.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,15 @@ |
|||
using Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.SettingManagement.Blazor.AntDesignUI; |
|||
|
|||
namespace Volo.Abp.SettingManagement.Blazor.WebAssembly.AntDesignUI; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpSettingManagementBlazorAntDesignModule), |
|||
typeof(AbpAspNetCoreComponentsWebAssemblyAntDesignThemeModule), |
|||
typeof(AbpSettingManagementHttpApiClientModule) |
|||
)] |
|||
public class AbpSettingManagementBlazorWebAssemblyAntDesignModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.SettingManagement.HttpApi.Client" Version="5.1.4" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme\Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme.csproj" /> |
|||
<ProjectReference Include="..\Volo.Abp.SettingManagement.Blazor.AntDesignUI\Volo.Abp.SettingManagement.Blazor.AntDesignUI.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
|
|||
</Project> |
|||
@ -0,0 +1,57 @@ |
|||
using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Routing; |
|||
using Lsw.Abp.FeatureManagement.Blazor.AntDesignUI; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.AutoMapper; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.ObjectExtending; |
|||
using Volo.Abp.ObjectExtending.Modularity; |
|||
using Volo.Abp.TenantManagement; |
|||
using Volo.Abp.Threading; |
|||
using Volo.Abp.UI.Navigation; |
|||
|
|||
namespace Lsw.Abp.TenantManagement.Blazor.AntDesignUI; |
|||
|
|||
|
|||
[DependsOn( |
|||
typeof(AbpAutoMapperModule), |
|||
typeof(AbpTenantManagementApplicationContractsModule), |
|||
typeof(AbpFeatureManagementBlazorAntDesignModule) |
|||
)] |
|||
public class AbpTenantManagementBlazorAntDesignModule : AbpModule |
|||
{ |
|||
private static readonly OneTimeRunner OneTimeRunner = new(); |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddAutoMapperObjectMapper<AbpTenantManagementBlazorAntDesignModule>(); |
|||
|
|||
Configure<AbpAutoMapperOptions>(options => |
|||
{ |
|||
options.AddProfile<AbpTenantManagementBlazorAutoMapperProfile>(validate: true); |
|||
}); |
|||
|
|||
Configure<AbpNavigationOptions>(options => |
|||
{ |
|||
options.MenuContributors.Add(new TenantManagementBlazorMenuContributor()); |
|||
}); |
|||
|
|||
Configure<AbpRouterOptions>(options => |
|||
{ |
|||
options.AdditionalAssemblies.Add(typeof(AbpTenantManagementBlazorAntDesignModule).Assembly); |
|||
}); |
|||
} |
|||
|
|||
public override void PostConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
OneTimeRunner.Run(() => |
|||
{ |
|||
ModuleExtensionConfigurationHelper |
|||
.ApplyEntityConfigurationToUi( |
|||
TenantManagementModuleExtensionConsts.ModuleName, |
|||
TenantManagementModuleExtensionConsts.EntityNames.Tenant, |
|||
createFormTypes: new[] { typeof(TenantCreateDto) }, |
|||
editFormTypes: new[] { typeof(TenantUpdateDto) } |
|||
); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using AutoMapper; |
|||
using Volo.Abp.TenantManagement; |
|||
|
|||
namespace Lsw.Abp.TenantManagement.Blazor.AntDesignUI; |
|||
|
|||
public class AbpTenantManagementBlazorAutoMapperProfile : Profile |
|||
{ |
|||
public AbpTenantManagementBlazorAutoMapperProfile() |
|||
{ |
|||
CreateMap<TenantDto, TenantUpdateDto>() |
|||
.MapExtraProperties(); |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.AutoMapper" Version="5.1.4" /> |
|||
<PackageReference Include="Volo.Abp.TenantManagement.Application.Contracts" Version="5.1.4" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\FeatureManagement\Lsw.Abp.FeatureManagement.Blazor.AntDesignUI\Lsw.Abp.FeatureManagement.Blazor.AntDesignUI.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,66 @@ |
|||
@page "/tenant-management/tenants" |
|||
@attribute [Authorize(TenantManagementPermissions.Tenants.Default)] |
|||
@using Microsoft.AspNetCore.Authorization |
|||
@using Lsw.Abp.FeatureManagement.Blazor.AntDesignUI.Components |
|||
@using Microsoft.AspNetCore.Components.Forms |
|||
@using Volo.Abp.TenantManagement.Localization |
|||
@using Volo.Abp.AspNetCore.Components.Web |
|||
@using Volo.Abp.TenantManagement |
|||
@inject AbpBlazorMessageLocalizerHelper<AbpTenantManagementResource> LH |
|||
@inherits AbpCrudPageBase<ITenantAppService, TenantDto, Guid, GetTenantsInput, TenantCreateDto, TenantUpdateDto> |
|||
|
|||
<AbpPageHeader Title="@L["Tenants"]" BreadcrumbItems="@BreadcrumbItems" Toolbar="@Toolbar"/> |
|||
|
|||
<div class="page-content"> |
|||
<AbpExtensibleDataGrid TItem="TenantDto" |
|||
Data="@Entities" |
|||
OnChange="@OnDataGridReadAsync" |
|||
TotalItems="@TotalCount" |
|||
PageSize="@PageSize" |
|||
CurrentPage="@CurrentPage" |
|||
Columns="@TenantManagementTableColumns"> |
|||
</AbpExtensibleDataGrid> |
|||
</div> |
|||
|
|||
@if (HasCreatePermission) |
|||
{ |
|||
<Modal @ref="CreateModal" Title="@L["NewTenant"]" Visible="@CreateModalVisible" OnCancel="@CloseCreateModalAsync" OnOk="CreateEntityAsync"> |
|||
<Form |
|||
Layout="@FormLayout.Vertical" |
|||
@ref="@CreateFormRef" |
|||
Model="@NewEntity"> |
|||
|
|||
<FormItem Label="@L["TenantName"]"> |
|||
<Input @bind-Value="@context.Name"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["DisplayName:AdminEmailAddress"]"> |
|||
<Input @bind-Value="@context.AdminEmailAddress"/> |
|||
</FormItem> |
|||
<FormItem Label="@L["DisplayName:AdminPassword"]"> |
|||
<InputPassword @bind-Value="@context.AdminPassword"/> |
|||
</FormItem> |
|||
|
|||
</Form> |
|||
</Modal> |
|||
} |
|||
|
|||
@if (HasUpdatePermission) |
|||
{ |
|||
<Modal @ref="EditModal" Title="@L["Edit"]" Visible="@EditModalVisible" OnCancel="@CloseEditModalAsync" OnOk="UpdateEntityAsync"> |
|||
<Form |
|||
Layout="@FormLayout.Vertical" |
|||
@ref="@EditFormRef" |
|||
Model="@EditingEntity"> |
|||
|
|||
<FormItem Label="@L["TenantName"]"> |
|||
<Input @bind-Value="@context.Name"/> |
|||
</FormItem> |
|||
|
|||
</Form> |
|||
</Modal> |
|||
} |
|||
|
|||
@if (HasManageFeaturesPermission) |
|||
{ |
|||
<FeatureManagementModal @ref="FeatureManagementModal"/> |
|||
} |
|||
@ -0,0 +1,137 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using AntDesign; |
|||
using Lsw.Abp.AntDesignUI; |
|||
using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.PageToolbars; |
|||
using Lsw.Abp.FeatureManagement.Blazor.AntDesignUI.Components; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Volo.Abp.AspNetCore.Components.Web.Extensibility.EntityActions; |
|||
using Volo.Abp.AspNetCore.Components.Web.Extensibility.TableColumns; |
|||
using Volo.Abp.FeatureManagement; |
|||
using Volo.Abp.TenantManagement; |
|||
using Volo.Abp.TenantManagement.Localization; |
|||
|
|||
namespace Lsw.Abp.TenantManagement.Blazor.AntDesignUI.Pages; |
|||
|
|||
public partial class TenantManagement |
|||
{ |
|||
protected const string FeatureProviderName = "T"; |
|||
|
|||
protected bool HasManageFeaturesPermission; |
|||
protected string ManageFeaturesPolicyName; |
|||
|
|||
protected FeatureManagementModal FeatureManagementModal; |
|||
|
|||
protected PageToolbar Toolbar { get; } = new(); |
|||
|
|||
protected List<TableColumn> TenantManagementTableColumns => TableColumns.Get<TenantManagement>(); |
|||
|
|||
public TenantManagement() |
|||
{ |
|||
LocalizationResource = typeof(AbpTenantManagementResource); |
|||
ObjectMapperContext = typeof(AbpTenantManagementBlazorAntDesignModule); |
|||
|
|||
CreatePolicyName = TenantManagementPermissions.Tenants.Create; |
|||
UpdatePolicyName = TenantManagementPermissions.Tenants.Update; |
|||
DeletePolicyName = TenantManagementPermissions.Tenants.Delete; |
|||
|
|||
ManageFeaturesPolicyName = TenantManagementPermissions.Tenants.ManageFeatures; |
|||
} |
|||
|
|||
protected override ValueTask SetBreadcrumbItemsAsync() |
|||
{ |
|||
BreadcrumbItems = new List<AbpBreadcrumbItem>() |
|||
{ |
|||
new(L["Menu:TenantManagement"]), |
|||
new(L["Tenants"]) |
|||
}; |
|||
|
|||
return base.SetBreadcrumbItemsAsync(); |
|||
} |
|||
|
|||
protected override async Task SetPermissionsAsync() |
|||
{ |
|||
await base.SetPermissionsAsync(); |
|||
|
|||
HasManageFeaturesPermission = await AuthorizationService.IsGrantedAsync(ManageFeaturesPolicyName); |
|||
} |
|||
|
|||
protected override string GetDeleteConfirmationMessage(TenantDto entity) |
|||
{ |
|||
return string.Format(L["TenantDeletionConfirmationMessage"], entity.Name); |
|||
} |
|||
|
|||
protected override ValueTask SetToolbarItemsAsync() |
|||
{ |
|||
Toolbar.AddButton(L["ManageHostFeatures"], |
|||
async () => await FeatureManagementModal.OpenAsync(FeatureProviderName), |
|||
IconType.Outline.Setting, |
|||
requiredPolicyName: FeatureManagementPermissions.ManageHostFeatures); |
|||
|
|||
Toolbar.AddButton(L["NewTenant"], |
|||
OpenCreateModalAsync, |
|||
IconType.Outline.Plus, |
|||
requiredPolicyName: CreatePolicyName); |
|||
|
|||
return base.SetToolbarItemsAsync(); |
|||
} |
|||
|
|||
protected override ValueTask SetEntityActionsAsync() |
|||
{ |
|||
EntityActions |
|||
.Get<TenantManagement>() |
|||
.AddRange(new EntityAction[] |
|||
{ |
|||
new EntityAction |
|||
{ |
|||
Text = L["Edit"], |
|||
Visible = (data) => HasUpdatePermission, |
|||
Clicked = async (data) => { await OpenEditModalAsync(data.As<TenantDto>()); } |
|||
}, |
|||
new EntityAction |
|||
{ |
|||
Text = L["Features"], |
|||
Visible = (data) => HasManageFeaturesPermission, |
|||
Clicked = async (data) => |
|||
{ |
|||
var tenant = data.As<TenantDto>(); |
|||
await FeatureManagementModal.OpenAsync(FeatureProviderName, tenant.Id.ToString()); |
|||
} |
|||
}, |
|||
new EntityAction |
|||
{ |
|||
Text = L["Delete"], |
|||
Visible = (data) => HasDeletePermission, |
|||
Clicked = async (data) => await DeleteEntityAsync(data.As<TenantDto>()), |
|||
ConfirmationMessage = (data) => GetDeleteConfirmationMessage(data.As<TenantDto>()) |
|||
} |
|||
}); |
|||
|
|||
return base.SetEntityActionsAsync(); |
|||
} |
|||
|
|||
protected override ValueTask SetTableColumnsAsync() |
|||
{ |
|||
TenantManagementTableColumns |
|||
.AddRange(new TableColumn[] |
|||
{ |
|||
new TableColumn |
|||
{ |
|||
Title = L["TenantName"], |
|||
Data = nameof(TenantDto.Name), |
|||
}, |
|||
new TableColumn |
|||
{ |
|||
Title = L["Actions"], |
|||
Actions = EntityActions.Get<TenantManagement>() |
|||
}, |
|||
}); |
|||
|
|||
// TenantManagementTableColumns.AddRange(GetExtensionTableColumns(
|
|||
// TenantManagementModuleExtensionConsts.ModuleName,
|
|||
// TenantManagementModuleExtensionConsts.EntityNames.Tenant));
|
|||
|
|||
return base.SetTableColumnsAsync(); |
|||
} |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
using System.Threading.Tasks; |
|||
using AntDesign; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.TenantManagement; |
|||
using Volo.Abp.TenantManagement.Localization; |
|||
using Volo.Abp.UI.Navigation; |
|||
|
|||
namespace Lsw.Abp.TenantManagement.Blazor.AntDesignUI; |
|||
|
|||
public class TenantManagementBlazorMenuContributor : IMenuContributor |
|||
{ |
|||
public virtual Task ConfigureMenuAsync(MenuConfigurationContext context) |
|||
{ |
|||
if (context.Menu.Name != StandardMenus.Main) |
|||
{ |
|||
return Task.CompletedTask; |
|||
} |
|||
|
|||
var administrationMenu = context.Menu.GetAdministration(); |
|||
|
|||
var l = context.GetLocalizer<AbpTenantManagementResource>(); |
|||
|
|||
var tenantManagementMenuItem = new ApplicationMenuItem( |
|||
TenantManagementMenuNames.GroupName, |
|||
l["Menu:TenantManagement"], |
|||
icon: IconType.Outline.Team |
|||
); |
|||
administrationMenu.AddItem(tenantManagementMenuItem); |
|||
|
|||
tenantManagementMenuItem.AddItem(new ApplicationMenuItem( |
|||
TenantManagementMenuNames.Tenants, |
|||
l["Tenants"], |
|||
url: "~/tenant-management/tenants" |
|||
).RequirePermissions(TenantManagementPermissions.Tenants.Default)); |
|||
|
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
namespace Lsw.Abp.TenantManagement.Blazor.AntDesignUI; |
|||
|
|||
public class TenantManagementMenuNames |
|||
{ |
|||
public const string GroupName = "TenantManagement"; |
|||
|
|||
public const string Tenants = GroupName + ".Tenants"; |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
@using Microsoft.AspNetCore.Components.Web |
|||
@using Volo.Abp.AspNetCore.Components.Web |
|||
@using AntDesign |
|||
@using Lsw.Abp.AntDesignUI |
|||
@using Lsw.Abp.AntDesignUI.Components |
|||
@using Lsw.Abp.FeatureManagement.Blazor.AntDesignUI.Components |
|||
@using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Layout |
|||
@ -0,0 +1,14 @@ |
|||
using Lsw.Abp.FeatureManagement.Blazor.Server.AntDesignUI; |
|||
using Lsw.Abp.TenantManagement.Blazor.AntDesignUI; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Lsw.Abp.TenantManagement.Blazor.Server.AntDesignUI; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpTenantManagementBlazorAntDesignModule), |
|||
typeof(AbpFeatureManagementBlazorWebServerAntDesignModule) |
|||
)] |
|||
public class AbpTenantManagementBlazorServerAntDesignModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\FeatureManagement\Lsw.Abp.FeatureManagement.Blazor.Server.AntDesignUI\Lsw.Abp.FeatureManagement.Blazor.Server.AntDesignUI.csproj" /> |
|||
<ProjectReference Include="..\Lsw.Abp.TenantManagement.Blazor.AntDesignUI\Lsw.Abp.TenantManagement.Blazor.AntDesignUI.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,17 @@ |
|||
using Lsw.Abp.FeatureManagement.Blazor.WebAssembly.AntDesignUI; |
|||
using Lsw.Abp.TenantManagement.Blazor.AntDesignUI; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.TenantManagement; |
|||
|
|||
namespace Lsw.Abp.TenantManagement.Blazor.WebAssembly.AntDesignUI; |
|||
|
|||
|
|||
[DependsOn( |
|||
typeof(AbpTenantManagementBlazorAntDesignModule), |
|||
typeof(AbpFeatureManagementBlazorWebAssemblyAntDesignModule), |
|||
typeof(AbpTenantManagementHttpApiClientModule) |
|||
)] |
|||
public class AbpTenantManagementBlazorWebAssemblyAntDesignModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.TenantManagement.HttpApi.Client" Version="5.1.4" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\FeatureManagement\Lsw.Abp.FeatureManagement.Blazor.WebAssembly.AntDesignUI\Lsw.Abp.FeatureManagement.Blazor.WebAssembly.AntDesignUI.csproj" /> |
|||
<ProjectReference Include="..\Lsw.Abp.TenantManagement.Blazor.AntDesignUI\Lsw.Abp.TenantManagement.Blazor.AntDesignUI.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1 @@ |
|||
**/wwwroot/libs/** linguist-vendored |
|||
@ -0,0 +1,262 @@ |
|||
## Ignore Visual Studio temporary files, build results, and |
|||
## files generated by popular Visual Studio add-ons. |
|||
|
|||
# User-specific files |
|||
*.suo |
|||
*.user |
|||
*.userosscache |
|||
*.sln.docstates |
|||
|
|||
# User-specific files (MonoDevelop/Xamarin Studio) |
|||
*.userprefs |
|||
|
|||
# Build results |
|||
[Dd]ebug/ |
|||
[Dd]ebugPublic/ |
|||
[Rr]elease/ |
|||
[Rr]eleases/ |
|||
x64/ |
|||
x86/ |
|||
bld/ |
|||
[Bb]in/ |
|||
[Oo]bj/ |
|||
[Ll]og/ |
|||
|
|||
# Visual Studio 2015 cache/options directory |
|||
.vs/ |
|||
# Uncomment if you have tasks that create the project's static files in wwwroot |
|||
#wwwroot/ |
|||
|
|||
# MSTest test Results |
|||
[Tt]est[Rr]esult*/ |
|||
[Bb]uild[Ll]og.* |
|||
|
|||
# NUNIT |
|||
*.VisualState.xml |
|||
TestResult.xml |
|||
|
|||
# Build Results of an ATL Project |
|||
[Dd]ebugPS/ |
|||
[Rr]eleasePS/ |
|||
dlldata.c |
|||
|
|||
# DNX |
|||
project.lock.json |
|||
artifacts/ |
|||
|
|||
*_i.c |
|||
*_p.c |
|||
*_i.h |
|||
*.ilk |
|||
*.meta |
|||
*.obj |
|||
*.pch |
|||
*.pdb |
|||
*.pgc |
|||
*.pgd |
|||
*.rsp |
|||
*.sbr |
|||
*.tlb |
|||
*.tli |
|||
*.tlh |
|||
*.tmp |
|||
*.tmp_proj |
|||
*.log |
|||
*.vspscc |
|||
*.vssscc |
|||
.builds |
|||
*.pidb |
|||
*.svclog |
|||
*.scc |
|||
|
|||
# Chutzpah Test files |
|||
_Chutzpah* |
|||
|
|||
# Visual C++ cache files |
|||
ipch/ |
|||
*.aps |
|||
*.ncb |
|||
*.opendb |
|||
*.opensdf |
|||
*.sdf |
|||
*.cachefile |
|||
*.VC.db |
|||
*.VC.VC.opendb |
|||
|
|||
# Visual Studio profiler |
|||
*.psess |
|||
*.vsp |
|||
*.vspx |
|||
*.sap |
|||
|
|||
# TFS 2012 Local Workspace |
|||
$tf/ |
|||
|
|||
# Guidance Automation Toolkit |
|||
*.gpState |
|||
|
|||
# ReSharper is a .NET coding add-in |
|||
_ReSharper*/ |
|||
*.[Rr]e[Ss]harper |
|||
*.DotSettings.user |
|||
|
|||
# JustCode is a .NET coding add-in |
|||
.JustCode |
|||
|
|||
# TeamCity is a build add-in |
|||
_TeamCity* |
|||
|
|||
# DotCover is a Code Coverage Tool |
|||
*.dotCover |
|||
|
|||
# NCrunch |
|||
_NCrunch_* |
|||
.*crunch*.local.xml |
|||
nCrunchTemp_* |
|||
|
|||
# MightyMoose |
|||
*.mm.* |
|||
AutoTest.Net/ |
|||
|
|||
# Web workbench (sass) |
|||
.sass-cache/ |
|||
|
|||
# Installshield output folder |
|||
[Ee]xpress/ |
|||
|
|||
# DocProject is a documentation generator add-in |
|||
DocProject/buildhelp/ |
|||
DocProject/Help/*.HxT |
|||
DocProject/Help/*.HxC |
|||
DocProject/Help/*.hhc |
|||
DocProject/Help/*.hhk |
|||
DocProject/Help/*.hhp |
|||
DocProject/Help/Html2 |
|||
DocProject/Help/html |
|||
|
|||
# Click-Once directory |
|||
publish/ |
|||
|
|||
# Publish Web Output |
|||
*.[Pp]ublish.xml |
|||
*.azurePubxml |
|||
# TODO: Comment the next line if you want to checkin your web deploy settings |
|||
# but database connection strings (with potential passwords) will be unencrypted |
|||
*.pubxml |
|||
*.publishproj |
|||
|
|||
# Microsoft Azure Web App publish settings. Comment the next line if you want to |
|||
# checkin your Azure Web App publish settings, but sensitive information contained |
|||
# in these scripts will be unencrypted |
|||
PublishScripts/ |
|||
|
|||
# NuGet Packages |
|||
*.nupkg |
|||
# The packages folder can be ignored because of Package Restore |
|||
**/packages/* |
|||
# except build/, which is used as an MSBuild target. |
|||
!**/packages/build/ |
|||
# Uncomment if necessary however generally it will be regenerated when needed |
|||
#!**/packages/repositories.config |
|||
# NuGet v3's project.json files produces more ignoreable files |
|||
*.nuget.props |
|||
*.nuget.targets |
|||
|
|||
# Microsoft Azure Build Output |
|||
csx/ |
|||
*.build.csdef |
|||
|
|||
# Microsoft Azure Emulator |
|||
ecf/ |
|||
rcf/ |
|||
|
|||
# Windows Store app package directories and files |
|||
AppPackages/ |
|||
BundleArtifacts/ |
|||
Package.StoreAssociation.xml |
|||
_pkginfo.txt |
|||
|
|||
# Visual Studio cache files |
|||
# files ending in .cache can be ignored |
|||
*.[Cc]ache |
|||
# but keep track of directories ending in .cache |
|||
!*.[Cc]ache/ |
|||
|
|||
# Others |
|||
ClientBin/ |
|||
~$* |
|||
*~ |
|||
*.dbmdl |
|||
*.dbproj.schemaview |
|||
*.pfx |
|||
*.publishsettings |
|||
node_modules/ |
|||
orleans.codegen.cs |
|||
|
|||
# Since there are multiple workflows, uncomment next line to ignore bower_components |
|||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) |
|||
#bower_components/ |
|||
|
|||
# RIA/Silverlight projects |
|||
Generated_Code/ |
|||
|
|||
# Backup & report files from converting an old project file |
|||
# to a newer Visual Studio version. Backup files are not needed, |
|||
# because we have git ;-) |
|||
_UpgradeReport_Files/ |
|||
Backup*/ |
|||
UpgradeLog*.XML |
|||
UpgradeLog*.htm |
|||
|
|||
# SQL Server files |
|||
*.mdf |
|||
*.ldf |
|||
|
|||
# Business Intelligence projects |
|||
*.rdl.data |
|||
*.bim.layout |
|||
*.bim_*.settings |
|||
|
|||
# Microsoft Fakes |
|||
FakesAssemblies/ |
|||
|
|||
# GhostDoc plugin setting file |
|||
*.GhostDoc.xml |
|||
|
|||
# Node.js Tools for Visual Studio |
|||
.ntvs_analysis.dat |
|||
|
|||
# Visual Studio 6 build log |
|||
*.plg |
|||
|
|||
# Visual Studio 6 workspace options file |
|||
*.opt |
|||
|
|||
# Visual Studio LightSwitch build output |
|||
**/*.HTMLClient/GeneratedArtifacts |
|||
**/*.DesktopClient/GeneratedArtifacts |
|||
**/*.DesktopClient/ModelManifest.xml |
|||
**/*.Server/GeneratedArtifacts |
|||
**/*.Server/ModelManifest.xml |
|||
_Pvt_Extensions |
|||
|
|||
# Paket dependency manager |
|||
.paket/paket.exe |
|||
paket-files/ |
|||
|
|||
# FAKE - F# Make |
|||
.fake/ |
|||
|
|||
# JetBrains Rider |
|||
.idea/ |
|||
*.sln.iml |
|||
|
|||
# BookStore |
|||
src/BookStore.Web/Logs/* |
|||
src/BookStore.Web.Host/Logs/* |
|||
src/BookStore.IdentityServer/Logs/* |
|||
src/BookStore.HttpApi.Host/Logs/* |
|||
src/BookStore.HttpApi.Host/Logs/* |
|||
src/BookStore.DbMigrator/Logs/* |
|||
src/BookStore.Blazor.Server/Logs/* |
|||
src/BookStore.Blazor.Server.Tiered/Logs/* |
|||
@ -0,0 +1,5 @@ |
|||
{ |
|||
"singleQuote": true, |
|||
"useTabs": false, |
|||
"tabWidth": 4 |
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> |
|||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> |
|||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> |
|||
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish> |
|||
<PreserveCompilationReferences>true</PreserveCompilationReferences> |
|||
<UserSecretsId>BookStore-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId> |
|||
</PropertyGroup> |
|||
|
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" /> |
|||
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\modules\IdentityManagement\Lsw.Abp.IdentityManagement.Blazor.Server.AntDesignUI\Lsw.Abp.IdentityManagement.Blazor.Server.AntDesignUI.csproj" /> |
|||
<ProjectReference Include="..\..\..\modules\Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme\Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme.csproj" /> |
|||
<ProjectReference Include="..\..\..\modules\SettingManagement\Volo.Abp.SettingManagement.Blazor.Server.AntDesignUI\Volo.Abp.SettingManagement.Blazor.Server.AntDesignUI.csproj" /> |
|||
<ProjectReference Include="..\..\..\modules\TenantManagement\Lsw.Abp.TenantManagement.Blazor.Server.AntDesignUI\Lsw.Abp.TenantManagement.Blazor.Server.AntDesignUI.csproj" /> |
|||
<ProjectReference Include="..\src\BookStore.Application\BookStore.Application.csproj" /> |
|||
<ProjectReference Include="..\src\BookStore.HttpApi\BookStore.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\src\BookStore.EntityFrameworkCore\BookStore.EntityFrameworkCore.csproj" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic" Version="5.1.4" /> |
|||
<PackageReference Include="Volo.Abp.Autofac" Version="5.1.4" /> |
|||
<PackageReference Include="Volo.Abp.Swashbuckle" Version="5.1.4" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="5.1.4" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="5.1.4" /> |
|||
<PackageReference Include="Volo.Abp.Account.Web.IdentityServer" Version="5.1.4" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Remove="Logs\**" /> |
|||
<Content Remove="Logs\**" /> |
|||
<EmbeddedResource Remove="Logs\**" /> |
|||
<None Remove="Logs\**" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Update="Pages\**\*.js"> |
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|||
</None> |
|||
<None Update="Pages\**\*.css"> |
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|||
</None> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,240 @@ |
|||
using System; |
|||
using System.IO; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.OpenApi.Models; |
|||
using BookStore.Blazor.Menus; |
|||
using BookStore.EntityFrameworkCore; |
|||
using BookStore.Localization; |
|||
using BookStore.MultiTenancy; |
|||
using Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme.Bundling; |
|||
using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Routing; |
|||
using Lsw.Abp.IdentityManagement.Blazor.Server.AntDesignUI; |
|||
using Lsw.Abp.TenantManagement.Blazor.Server.AntDesignUI; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Account.Web; |
|||
using Volo.Abp.AspNetCore.Authentication.JwtBearer; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc.Localization; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling; |
|||
using Volo.Abp.AspNetCore.Serilog; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.AutoMapper; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.SettingManagement.Blazor.AntDesignUI; |
|||
using Volo.Abp.SettingManagement.Blazor.Server.AntDesignUI; |
|||
using Volo.Abp.Swashbuckle; |
|||
using Volo.Abp.UI.Navigation; |
|||
using Volo.Abp.UI.Navigation.Urls; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
|
|||
namespace BookStore.Blazor; |
|||
|
|||
[DependsOn( |
|||
typeof(BookStoreApplicationModule), |
|||
typeof(BookStoreEntityFrameworkCoreModule), |
|||
typeof(BookStoreHttpApiModule), |
|||
typeof(AbpAspNetCoreMvcUiBasicThemeModule), |
|||
typeof(AbpAutofacModule), |
|||
typeof(AbpSwashbuckleModule), |
|||
typeof(AbpAspNetCoreAuthenticationJwtBearerModule), |
|||
typeof(AbpAspNetCoreSerilogModule), |
|||
typeof(AbpAccountWebIdentityServerModule), |
|||
typeof(AbpIdentityBlazorServerAntDesignModule), |
|||
typeof(AbpTenantManagementBlazorServerAntDesignModule), |
|||
typeof(AbpSettingManagementBlazorAntDesignModule) |
|||
)] |
|||
public class BookStoreBlazorModule : AbpModule |
|||
{ |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options => |
|||
{ |
|||
options.AddAssemblyResource( |
|||
typeof(BookStoreResource), |
|||
typeof(BookStoreDomainModule).Assembly, |
|||
typeof(BookStoreDomainSharedModule).Assembly, |
|||
typeof(BookStoreApplicationModule).Assembly, |
|||
typeof(BookStoreApplicationContractsModule).Assembly, |
|||
typeof(BookStoreBlazorModule).Assembly |
|||
); |
|||
}); |
|||
} |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var hostingEnvironment = context.Services.GetHostingEnvironment(); |
|||
var configuration = context.Services.GetConfiguration(); |
|||
|
|||
ConfigureUrls(configuration); |
|||
ConfigureBundles(); |
|||
ConfigureAuthentication(context, configuration); |
|||
ConfigureAutoMapper(); |
|||
ConfigureLocalizationServices(); |
|||
ConfigureSwaggerServices(context.Services); |
|||
ConfigureAutoApiControllers(); |
|||
ConfigureRouter(context); |
|||
ConfigureMenu(context); |
|||
} |
|||
|
|||
private void ConfigureUrls(IConfiguration configuration) |
|||
{ |
|||
Configure<AppUrlOptions>(options => |
|||
{ |
|||
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; |
|||
options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"].Split(',')); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureBundles() |
|||
{ |
|||
Configure<AbpBundlingOptions>(options => |
|||
{ |
|||
// MVC UI
|
|||
options.StyleBundles.Configure( |
|||
BasicThemeBundles.Styles.Global, |
|||
bundle => |
|||
{ |
|||
bundle.AddFiles("/global-styles.css"); |
|||
} |
|||
); |
|||
|
|||
//BLAZOR UI
|
|||
options.StyleBundles.Configure( |
|||
BlazorAntDesignThemeBundles.Styles.Global, |
|||
bundle => |
|||
{ |
|||
bundle.AddFiles("/blazor-global-styles.css"); |
|||
//You can remove the following line if you don't use Blazor CSS isolation for components
|
|||
bundle.AddFiles("/BookStore.BlazorServer.styles.css"); |
|||
} |
|||
); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) |
|||
{ |
|||
context.Services.AddAuthentication() |
|||
.AddJwtBearer(options => |
|||
{ |
|||
options.Authority = configuration["AuthServer:Authority"]; |
|||
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); |
|||
options.Audience = "BookStore"; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureLocalizationServices() |
|||
{ |
|||
Configure<AbpLocalizationOptions>(options => |
|||
{ |
|||
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية")); |
|||
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); |
|||
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
|||
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)")); |
|||
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); |
|||
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); |
|||
options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); |
|||
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); |
|||
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is")); |
|||
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); |
|||
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português")); |
|||
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); |
|||
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский")); |
|||
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); |
|||
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); |
|||
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); |
|||
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); |
|||
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de")); |
|||
options.Languages.Add(new LanguageInfo("es", "es", "Español")); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureSwaggerServices(IServiceCollection services) |
|||
{ |
|||
services.AddAbpSwaggerGen( |
|||
options => |
|||
{ |
|||
options.SwaggerDoc("v1", new OpenApiInfo { Title = "BookStore API", Version = "v1" }); |
|||
options.DocInclusionPredicate((docName, description) => true); |
|||
options.CustomSchemaIds(type => type.FullName); |
|||
} |
|||
); |
|||
} |
|||
private void ConfigureMenu(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpNavigationOptions>(options => |
|||
{ |
|||
options.MenuContributors.Add(new BookStoreMenuContributor()); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureRouter(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpRouterOptions>(options => |
|||
{ |
|||
options.AppAssembly = typeof(BookStoreBlazorModule).Assembly; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureAutoApiControllers() |
|||
{ |
|||
Configure<AbpAspNetCoreMvcOptions>(options => |
|||
{ |
|||
options.ConventionalControllers.Create(typeof(BookStoreApplicationModule).Assembly); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureAutoMapper() |
|||
{ |
|||
Configure<AbpAutoMapperOptions>(options => |
|||
{ |
|||
options.AddMaps<BookStoreBlazorModule>(); |
|||
}); |
|||
} |
|||
|
|||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|||
{ |
|||
var env = context.GetEnvironment(); |
|||
var app = context.GetApplicationBuilder(); |
|||
|
|||
app.UseAbpRequestLocalization(); |
|||
|
|||
if (env.IsDevelopment()) |
|||
{ |
|||
app.UseDeveloperExceptionPage(); |
|||
} |
|||
else |
|||
{ |
|||
app.UseExceptionHandler("/Error"); |
|||
app.UseHsts(); |
|||
} |
|||
|
|||
app.UseHttpsRedirection(); |
|||
app.UseCorrelationId(); |
|||
app.UseStaticFiles(); |
|||
app.UseRouting(); |
|||
app.UseAuthentication(); |
|||
app.UseJwtTokenMiddleware(); |
|||
|
|||
if (MultiTenancyConsts.IsEnabled) |
|||
{ |
|||
app.UseMultiTenancy(); |
|||
} |
|||
|
|||
app.UseUnitOfWork(); |
|||
app.UseIdentityServer(); |
|||
app.UseAuthorization(); |
|||
app.UseSwagger(); |
|||
app.UseAbpSwaggerUI(options => |
|||
{ |
|||
options.SwaggerEndpoint("/swagger/v1/swagger.json", "BookStore API"); |
|||
}); |
|||
app.UseConfiguredEndpoints(); |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Ui.Branding; |
|||
|
|||
namespace BookStore.Blazor; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
public class BookStoreBrandingProvider : DefaultBrandingProvider |
|||
{ |
|||
public override string AppName => "BookStore"; |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using BookStore.Localization; |
|||
using Volo.Abp.AspNetCore.Components; |
|||
|
|||
namespace BookStore.Blazor; |
|||
|
|||
public abstract class BookStoreComponentBase : AbpComponentBase |
|||
{ |
|||
protected BookStoreComponentBase() |
|||
{ |
|||
LocalizationResource = typeof(BookStoreResource); |
|||
} |
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
using System.Threading.Tasks; |
|||
using AntDesign; |
|||
using BookStore.Localization; |
|||
using BookStore.MultiTenancy; |
|||
using Lsw.Abp.IdentityManagement.Blazor.AntDesignUI; |
|||
using Lsw.Abp.TenantManagement.Blazor.AntDesignUI; |
|||
using Volo.Abp.SettingManagement.Blazor.AntDesignUI; |
|||
using Volo.Abp.UI.Navigation; |
|||
|
|||
namespace BookStore.Blazor.Menus; |
|||
|
|||
public class BookStoreMenuContributor : IMenuContributor |
|||
{ |
|||
public async Task ConfigureMenuAsync(MenuConfigurationContext context) |
|||
{ |
|||
if (context.Menu.Name == StandardMenus.Main) |
|||
{ |
|||
await ConfigureMainMenuAsync(context); |
|||
} |
|||
} |
|||
|
|||
private Task ConfigureMainMenuAsync(MenuConfigurationContext context) |
|||
{ |
|||
var administration = context.Menu.GetAdministration(); |
|||
var l = context.GetLocalizer<BookStoreResource>(); |
|||
|
|||
context.Menu.Items.Insert( |
|||
0, |
|||
new ApplicationMenuItem( |
|||
BookStoreMenus.Home, |
|||
l["Menu:Home"], |
|||
"/", |
|||
icon: IconType.Outline.Home, |
|||
order: 0 |
|||
) |
|||
); |
|||
|
|||
if (MultiTenancyConsts.IsEnabled) |
|||
{ |
|||
administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1); |
|||
} |
|||
else |
|||
{ |
|||
administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName); |
|||
} |
|||
|
|||
administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2); |
|||
administration.SetSubItemOrder(SettingManagementMenus.GroupName, 3); |
|||
|
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue