Browse Source

Manage Host features.

pull/5259/head
maliming 6 years ago
parent
commit
7b09b7e592
  1. 16
      modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/FeatureManagementPermissions.cs
  2. 28
      modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/FeaturePermissionDefinitionProvider.cs
  3. 8
      modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/IFeatureAppService.cs
  4. 46
      modules/feature-management/src/Volo.Abp.FeatureManagement.Application/Volo/Abp/FeatureManagement/FeatureAppService.cs
  5. 7
      modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/en.json
  6. 7
      modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/tr.json
  7. 7
      modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/zh-Hans.json
  8. 7
      modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/zh-Hant.json
  9. 16
      modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi/Volo/Abp/FeatureManagement/FeaturesController.cs
  10. 18
      modules/feature-management/src/Volo.Abp.FeatureManagement.Web/Pages/FeatureManagement/FeatureManagementModal.cshtml.cs
  11. 7
      modules/tenant-management/src/Volo.Abp.TenantManagement.Domain.Shared/Volo/Abp/TenantManagement/Localization/Resources/en.json
  12. 3
      modules/tenant-management/src/Volo.Abp.TenantManagement.Domain.Shared/Volo/Abp/TenantManagement/Localization/Resources/tr.json
  13. 3
      modules/tenant-management/src/Volo.Abp.TenantManagement.Domain.Shared/Volo/Abp/TenantManagement/Localization/Resources/zh-Hans.json
  14. 3
      modules/tenant-management/src/Volo.Abp.TenantManagement.Domain.Shared/Volo/Abp/TenantManagement/Localization/Resources/zh-Hant.json
  15. 9
      modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Pages/TenantManagement/Tenants/Index.cshtml
  16. 10
      modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Pages/TenantManagement/Tenants/Index.js

16
modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/FeatureManagementPermissions.cs

@ -0,0 +1,16 @@
using Volo.Abp.Reflection;
namespace Volo.Abp.FeatureManagement
{
public class FeatureManagementPermissions
{
public const string GroupName = "FeatureManagement";
public const string ManageHostFeatures = GroupName + ".ManageHostFeatures";
public static string[] GetAll()
{
return ReflectionHelper.GetPublicConstantsRecursively(typeof(FeatureManagementPermissions));
}
}
}

28
modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/FeaturePermissionDefinitionProvider.cs

@ -0,0 +1,28 @@
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.FeatureManagement.Localization;
using Volo.Abp.Localization;
using Volo.Abp.MultiTenancy;
namespace Volo.Abp.FeatureManagement
{
public class FeaturePermissionDefinitionProvider : PermissionDefinitionProvider
{
public override void Define(IPermissionDefinitionContext context)
{
var featureManagementGroup = context.AddGroup(
FeatureManagementPermissions.GroupName,
L("Permission:FeatureManagement"),
multiTenancySide: MultiTenancySides.Host);
featureManagementGroup.AddPermission(
FeatureManagementPermissions.ManageHostFeatures,
L("Permission:FeatureManagement.ManageHostFeatures"),
multiTenancySide: MultiTenancySides.Host);
}
private static LocalizableString L(string name)
{
return LocalizableString.Create<AbpFeatureManagementResource>(name);
}
}
}

8
modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/IFeatureAppService.cs

@ -6,8 +6,12 @@ namespace Volo.Abp.FeatureManagement
{
public interface IFeatureAppService : IApplicationService
{
Task<FeatureListDto> GetAsync([NotNull] string providerName, [NotNull] string providerKey);
Task<FeatureListDto> GetAsync([NotNull] string providerName, [NotNull] string providerKey);
Task UpdateAsync([NotNull] string providerName, [NotNull] string providerKey, UpdateFeaturesDto input);
Task UpdateAsync([NotNull] string providerName, [NotNull] string providerKey, UpdateFeaturesDto input);
Task<FeatureListDto> GetHostAsync();
Task UpdateHostAsync(UpdateFeaturesDto input);
}
}

46
modules/feature-management/src/Volo.Abp.FeatureManagement.Application/Volo/Abp/FeatureManagement/FeatureAppService.cs

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Authorization;
@ -65,6 +66,51 @@ namespace Volo.Abp.FeatureManagement
}
}
[Authorize(FeatureManagementPermissions.ManageHostFeatures)]
public async Task<FeatureListDto> GetHostAsync()
{
var featureDefinitions = FeatureDefinitionManager.GetAll().Where(x => x.IsAvailableToHost);
var features = new List<FeatureDto>();
foreach (var featureDefinition in featureDefinitions)
{
var feature = await FeatureManager.GetOrNullWithProviderAsync(featureDefinition.Name, HostFeatureValueProvider.ProviderName, null);
features.Add(new FeatureDto
{
Name = featureDefinition.Name,
DisplayName = featureDefinition.DisplayName?.Localize(StringLocalizerFactory),
ValueType = featureDefinition.ValueType,
Description = featureDefinition.Description?.Localize(StringLocalizerFactory),
ParentName = featureDefinition.Parent?.Name,
Value = feature.Value,
Provider = new FeatureProviderDto
{
Name = feature.Provider?.Name,
Key = feature.Provider?.Key
}
});
}
SetFeatureDepth(features, HostFeatureValueProvider.ProviderName, null);
return new FeatureListDto { Features = features };
}
[Authorize(FeatureManagementPermissions.ManageHostFeatures)]
public async Task UpdateHostAsync(UpdateFeaturesDto input)
{
foreach (var feature in input.Features)
{
var featureDefinition = FeatureDefinitionManager.GetOrNull(feature.Name);
if (featureDefinition == null || !featureDefinition.IsAvailableToHost)
{
throw new UserFriendlyException(L["FeatureNotAvailable"]);
}
await FeatureManager.SetAsync(feature.Name, feature.Value, HostFeatureValueProvider.ProviderName, null);
}
}
protected virtual void SetFeatureDepth(List<FeatureDto> features, string providerName, string providerKey,
FeatureDto parentFeature = null, int depth = 0)
{

7
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/en.json

@ -2,6 +2,9 @@
"culture": "en",
"texts": {
"Features": "Features",
"NoFeatureFoundMessage": "There isn't any available feature."
"NoFeatureFoundMessage": "There isn't any available feature.",
"FeatureNotAvailable": "Feature not available.",
"Permission:FeatureManagement": "Feature management",
"Permission:FeatureManagement.ManageHostFeatures": "Manage Host features"
}
}
}

7
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/tr.json

@ -2,6 +2,9 @@
"culture": "tr",
"texts": {
"Features": "Özellikler",
"NoFeatureFoundMessage": "Hiç özellik yok."
"NoFeatureFoundMessage": "Hiç özellik yok.",
"FeatureNotAvailable": "özelliği mevcut değil.",
"Permission:FeatureManagement": "Özellik yönetimi",
"Permission:FeatureManagement.ManageHostFeatures": "Yönetilen Ana Bilgisayar özellikleri"
}
}
}

7
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/zh-Hans.json

@ -2,6 +2,9 @@
"culture": "zh-Hans",
"texts": {
"Features": "功能",
"NoFeatureFoundMessage": "没有可用的功能."
"NoFeatureFoundMessage": "没有可用的功能.",
"FeatureNotAvailable": "功能不可用.",
"Permission:FeatureManagement": "特性管理",
"Permission:FeatureManagement.ManageHostFeatures": "管理Host特性"
}
}
}

7
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/zh-Hant.json

@ -2,6 +2,9 @@
"culture": "zh-Hant",
"texts": {
"Features": "功能",
"NoFeatureFoundMessage": "沒有可用的功能."
"NoFeatureFoundMessage": "沒有可用的功能.",
"FeatureNotAvailable": "功能不可用.",
"Permission:FeatureManagement": "功能管理",
"Permission:FeatureManagement.ManageHostFeatures": "管理Host功能"
}
}
}

16
modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi/Volo/Abp/FeatureManagement/FeaturesController.cs

@ -27,5 +27,19 @@ namespace Volo.Abp.FeatureManagement
{
return FeatureAppService.UpdateAsync(providerName, providerKey, input);
}
[HttpGet]
[Route("host")]
public virtual Task<FeatureListDto> GetHostAsync()
{
return FeatureAppService.GetHostAsync();
}
[HttpPut]
[Route("host")]
public virtual Task UpdateHostAsync(UpdateFeaturesDto input)
{
return FeatureAppService.UpdateHostAsync(input);
}
}
}
}

18
modules/feature-management/src/Volo.Abp.FeatureManagement.Web/Pages/FeatureManagement/FeatureManagementModal.cshtml.cs

@ -37,7 +37,14 @@ namespace Volo.Abp.FeatureManagement.Web.Pages.FeatureManagement
public virtual async Task OnGetAsync()
{
FeatureListDto = await FeatureAppService.GetAsync(ProviderName, ProviderKey);
if (ProviderName == HostFeatureValueProvider.ProviderName)
{
FeatureListDto = await FeatureAppService.GetHostAsync();
}
else
{
FeatureListDto = await FeatureAppService.GetAsync(ProviderName, ProviderKey);
}
}
public virtual async Task<IActionResult> OnPostAsync()
@ -51,7 +58,14 @@ namespace Volo.Abp.FeatureManagement.Web.Pages.FeatureManagement
}).ToList()
};
await FeatureAppService.UpdateAsync(ProviderName, ProviderKey, features);
if (ProviderName == HostFeatureValueProvider.ProviderName)
{
await FeatureAppService.UpdateHostAsync(features);
}
else
{
await FeatureAppService.UpdateAsync(ProviderName, ProviderKey, features);
}
return NoContent();
}

7
modules/tenant-management/src/Volo.Abp.TenantManagement.Domain.Shared/Volo/Abp/TenantManagement/Localization/Resources/en.json

@ -10,13 +10,14 @@
"ConnectionStrings": "Connection Strings",
"DisplayName:DefaultConnectionString": "Default Connection String",
"DisplayName:UseSharedDatabase": "Use the Shared Database",
"ManageHostFeatures": "Manage Host features",
"Permission:TenantManagement": "Tenant management",
"Permission:Create": "Create",
"Permission:Edit": "Edit",
"Permission:Delete": "Delete",
"Permission:ManageConnectionStrings": "Manage connection strings",
"Permission:ManageFeatures": "Manage features",
"DisplayName:AdminEmailAddress": "Admin Email Address",
"DisplayName:AdminPassword": "Admin Password"
"DisplayName:AdminEmailAddress": "Admin Email Address",
"DisplayName:AdminPassword": "Admin Password"
}
}
}

3
modules/tenant-management/src/Volo.Abp.TenantManagement.Domain.Shared/Volo/Abp/TenantManagement/Localization/Resources/tr.json

@ -10,6 +10,7 @@
"ConnectionStrings": "Bağlantı cümlesi",
"DisplayName:DefaultConnectionString": "Varsayılan bağlantı cümlesi",
"DisplayName:UseSharedDatabase": "Paylaşılan veritabanını kullan",
"ManageHostFeatures": "Toplantı Sahibi özelliklerini yönetin",
"Permission:TenantManagement": "Müşteri yönetimi",
"Permission:Create": "Oluşturma",
"Permission:Edit": "Düzenleme",
@ -19,4 +20,4 @@
"DisplayName:AdminEmailAddress": "Admin Eposta Adresi",
"DisplayName:AdminPassword": "Admin Şifresi"
}
}
}

3
modules/tenant-management/src/Volo.Abp.TenantManagement.Domain.Shared/Volo/Abp/TenantManagement/Localization/Resources/zh-Hans.json

@ -10,6 +10,7 @@
"ConnectionStrings": "连接字符串",
"DisplayName:DefaultConnectionString": "默认连接字符串",
"DisplayName:UseSharedDatabase": "使用共享数据库",
"ManageHostFeatures": "管理Host特性",
"Permission:TenantManagement": "租户管理",
"Permission:Create": "创建",
"Permission:Edit": "编辑",
@ -17,4 +18,4 @@
"Permission:ManageConnectionStrings": "管理连接字符串",
"Permission:ManageFeatures": "管理功能"
}
}
}

3
modules/tenant-management/src/Volo.Abp.TenantManagement.Domain.Shared/Volo/Abp/TenantManagement/Localization/Resources/zh-Hant.json

@ -10,13 +10,14 @@
"ConnectionStrings": "資料庫連線字串",
"DisplayName:DefaultConnectionString": "預設資料庫連線字串",
"DisplayName:UseSharedDatabase": "使用共用資料庫",
"ManageHostFeatures": "管理Host功能",
"Permission:TenantManagement": "租戶管理",
"Permission:Create": "新增",
"Permission:Edit": "編輯",
"Permission:Delete": "刪除",
"Permission:ManageConnectionStrings": "管理資料庫連線字串",
"Permission:ManageFeatures": "管理功能",
"DisplayName:AdminEmailAddress": "管理者信箱",
"DisplayName:AdminEmailAddress": "管理者信箱",
"DisplayName:AdminPassword": "管理者密碼"
}
}

9
modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Pages/TenantManagement/Tenants/Index.cshtml

@ -2,6 +2,7 @@
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Layout
@using Volo.Abp.FeatureManagement
@using Volo.Abp.TenantManagement
@using Volo.Abp.TenantManagement.Localization
@using Volo.Abp.TenantManagement.Web.Navigation
@ -29,9 +30,13 @@
<abp-card-title>@L["Tenants"]</abp-card-title>
</abp-column>
<abp-column size-md="_6" class="text-right">
@if (await Authorization.IsGrantedAsync(FeatureManagementPermissions.ManageHostFeatures))
{
<abp-button button-type="Primary" name="ManageHostFeatures" icon="cog" text="@L["ManageHostFeatures"].Value" />
}
@if (await Authorization.IsGrantedAsync(TenantManagementPermissions.Tenants.Create))
{
<abp-button button-type="Primary" name="CreateTenant" icon="plus" text="@L["NewTenant"].Value" />
<abp-button button-type="Primary" name="CreateTenant" icon="plus" text="@L["NewTenant"].Value"/>
}
</abp-column>
</abp-row>
@ -39,4 +44,4 @@
<abp-card-body>
<abp-table striped-rows="true" class="nowrap"></abp-table>
</abp-card-body>
</abp-card>
</abp-card>

10
modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Pages/TenantManagement/Tenants/Index.js

@ -100,7 +100,7 @@
},
0 //adds as the first contributor
);
$(function () {
var _$wrapper = $('#TenantsWrapper');
@ -128,5 +128,13 @@
e.preventDefault();
_createModal.open();
});
_$wrapper.find('button[name=ManageHostFeatures]').click(function (e) {
e.preventDefault();
_featuresModal.open({
providerName: 'H',
providerKey: 'H'
});
});
});
})();

Loading…
Cancel
Save