mirror of https://github.com/abpframework/abp.git
31 changed files with 1133 additions and 62 deletions
@ -0,0 +1,8 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Abp.PermissionManagement; |
||||
|
|
||||
|
public class GetResourcePermissionDefinitionListResultDto |
||||
|
{ |
||||
|
public List<ResourcePermissionDefinitionDto> Permissions { get; set; } |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Abp.PermissionManagement; |
||||
|
|
||||
|
public class GetResourcePermissionWithProviderListResultDto |
||||
|
{ |
||||
|
public List<ResourcePermissionWithProdiverGrantInfoDto> Permissions { get; set; } |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
namespace Volo.Abp.PermissionManagement; |
||||
|
|
||||
|
public class ResourcePermissionDefinitionDto |
||||
|
{ |
||||
|
public string Name { get; set; } |
||||
|
|
||||
|
public string DisplayName { get; set; } |
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
namespace Volo.Abp.PermissionManagement; |
||||
|
|
||||
|
public class ResourcePermissionWithProdiverGrantInfoDto |
||||
|
{ |
||||
|
public string Name { get; set; } |
||||
|
|
||||
|
public string DisplayName { get; set; } |
||||
|
|
||||
|
public bool IsGranted { get; set; } |
||||
|
} |
||||
@ -1,18 +0,0 @@ |
|||||
using Volo.Abp.Authorization.Permissions; |
|
||||
using Volo.Abp.Localization; |
|
||||
using Volo.Abp.PermissionManagement.Localization; |
|
||||
|
|
||||
namespace Volo.Abp.PermissionManagement; |
|
||||
|
|
||||
public class TestPermissionDefinitionProvider : PermissionDefinitionProvider |
|
||||
{ |
|
||||
public override void Define(IPermissionDefinitionContext context) |
|
||||
{ |
|
||||
context.AddResourcePermission("AbpIdentity.Resource.ChangeName", "Volo.Abp.IdentityUser", L("OnlyProviderPermissons")); |
|
||||
} |
|
||||
|
|
||||
private static LocalizableString L(string name) |
|
||||
{ |
|
||||
return LocalizableString.Create<AbpPermissionManagementResource>(name); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,28 @@ |
|||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.PermissionManagement.Localization; |
||||
|
|
||||
|
namespace Volo.Abp.PermissionManagement; |
||||
|
|
||||
|
public class TestPermissionDefinitionProvider : PermissionDefinitionProvider |
||||
|
{ |
||||
|
public override void Define(IPermissionDefinitionContext context) |
||||
|
{ |
||||
|
context.AddResourcePermission("PR1", "Volo.Abp.Identity.IdentityRole", L("Role Resource Permission1")); |
||||
|
context.AddResourcePermission("PR2", "Volo.Abp.Identity.IdentityRole", L("Role Resource Permission2")); |
||||
|
context.AddResourcePermission("PR3", "Volo.Abp.Identity.IdentityRole", L("Role Resource Permission3")); |
||||
|
context.AddResourcePermission("PR4", "Volo.Abp.Identity.IdentityRole", L("Role Resource Permission4")); |
||||
|
context.AddResourcePermission("PR5", "Volo.Abp.Identity.IdentityRole", L("Role Resource Permission5")); |
||||
|
|
||||
|
context.AddResourcePermission("PU1", "Volo.Abp.Identity.IdentityUser", L("User Resource Permission1")); |
||||
|
context.AddResourcePermission("PU2", "Volo.Abp.Identity.IdentityUser", L("User Resource Permission2")); |
||||
|
context.AddResourcePermission("PU3", "Volo.Abp.Identity.IdentityUser", L("User Resource Permission3")); |
||||
|
context.AddResourcePermission("PU4", "Volo.Abp.Identity.IdentityUser", L("User Resource Permission4")); |
||||
|
context.AddResourcePermission("PU5", "VVolo.Abp.Identity.IdentityUser", L("User Resource Permission5")); |
||||
|
} |
||||
|
|
||||
|
private static LocalizableString L(string name) |
||||
|
{ |
||||
|
return LocalizableString.Create<AbpPermissionManagementResource>(name); |
||||
|
} |
||||
|
} |
||||
@ -1,12 +0,0 @@ |
|||||
namespace Volo.Abp.PermissionManagement; |
|
||||
|
|
||||
public class UpdateResourcePermissionDto |
|
||||
{ |
|
||||
public string ProviderName { get; set; } |
|
||||
|
|
||||
public string ProviderKey { get; set; } |
|
||||
|
|
||||
public string Name { get; set; } |
|
||||
|
|
||||
public bool IsGranted { get; set; } |
|
||||
} |
|
||||
@ -1,6 +1,12 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
namespace Volo.Abp.PermissionManagement; |
namespace Volo.Abp.PermissionManagement; |
||||
|
|
||||
public class UpdateResourcePermissionsDto |
public class UpdateResourcePermissionsDto |
||||
{ |
{ |
||||
public UpdateResourcePermissionDto[] Permissions { get; set; } |
public string ProviderName { get; set; } |
||||
|
|
||||
|
public string ProviderKey { get; set; } |
||||
|
|
||||
|
public List<string> Permissions { get; set; } |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,62 @@ |
|||||
|
@page |
||||
|
@using System.Web; |
||||
|
@using Microsoft.AspNetCore.Mvc.Localization |
||||
|
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
||||
|
@using Volo.Abp.Localization |
||||
|
@using Volo.Abp.PermissionManagement.Localization |
||||
|
@using Volo.Abp.PermissionManagement.Web.Pages.AbpPermissionManagement |
||||
|
@model AddResourcePermissionManagementModal |
||||
|
@inject IHtmlLocalizer<AbpPermissionManagementResource> L |
||||
|
|
||||
|
@{ |
||||
|
Layout = null; |
||||
|
} |
||||
|
|
||||
|
<script src="/client-proxies/permissionManagement-proxy.js"></script> |
||||
|
<script src="/Pages/AbpPermissionManagement/add-resource-permission-management-modal.js"></script> |
||||
|
|
||||
|
<form method="post" asp-page="/AbpPermissionManagement/AddResourcePermissionManagementModal"> |
||||
|
<abp-modal> |
||||
|
<abp-modal-header title="@(L["AddResourcePermissions"].Value)"></abp-modal-header> |
||||
|
<input asp-for="@Model.ResourceName" /> |
||||
|
<input asp-for="@Model.ResourceKey" /> |
||||
|
<input asp-for="@Model.ResourceDisplayName" /> |
||||
|
<abp-modal-body> |
||||
|
<div class="mb-3"> |
||||
|
<label class="form-label">Resource name:</label> |
||||
|
<p>@(HttpUtility.HtmlEncode(Model.ResourceDisplayName))</p> |
||||
|
</div> |
||||
|
<div class="mb-3"> |
||||
|
<label class="form-label">ProviderName:</label> |
||||
|
<div class="mb-1"> |
||||
|
<div class="form-check form-check-inline"> |
||||
|
<input class="form-check-input" type="radio" checked name="AddModel.ProviderName" id="UserProvider" value="U"> |
||||
|
<label class="form-check-label" for="UserProvider">User</label> |
||||
|
</div> |
||||
|
<div class="form-check form-check-inline"> |
||||
|
<input class="form-check-input" type="radio" name="AddModel.ProviderName" id="RoleProvider" value="R"> |
||||
|
<label class="form-check-label" for="RoleProvider">Role</label> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<abp-input asp-for="@Model.AddModel.ProviderKey"/> |
||||
|
<div class="mb-3" id="permissionList"> |
||||
|
<div class="mb-1 d-flex align-items-center justify-content-between"> |
||||
|
<label class="form-labe">Permissions:</label> |
||||
|
<div class="form-check form-switch"> |
||||
|
<input class="form-check-input" id="grantAllresourcePermissions" type="checkbox"> |
||||
|
<label class="form-check-label">Grant all</label> |
||||
|
</div> |
||||
|
</div> |
||||
|
@foreach (var permission in Model.ResourcePermissionDefinitions.Permissions) |
||||
|
{ |
||||
|
<div class="form-check"> |
||||
|
<input class="form-check-input" type="checkbox" name="AddModel.Permissions[]" value="@permission.Name"> |
||||
|
<label class="form-check-label">@permission.DisplayName</label> |
||||
|
</div> |
||||
|
} |
||||
|
</div> |
||||
|
</abp-modal-body> |
||||
|
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer> |
||||
|
</abp-modal> |
||||
|
</form> |
||||
@ -0,0 +1,76 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; |
||||
|
|
||||
|
namespace Volo.Abp.PermissionManagement.Web.Pages.AbpPermissionManagement; |
||||
|
|
||||
|
public class AddResourcePermissionManagementModal : AbpPageModel |
||||
|
{ |
||||
|
[Required] |
||||
|
[HiddenInput] |
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public string ResourceName { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
[HiddenInput] |
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public string ResourceKey { get; set; } |
||||
|
|
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
[HiddenInput] |
||||
|
public string ResourceDisplayName { get; set; } |
||||
|
|
||||
|
[BindProperty] |
||||
|
public ResourcePermissionViewModel AddModel { get; set; } |
||||
|
|
||||
|
public GetResourcePermissionDefinitionListResultDto ResourcePermissionDefinitions { get; set; } |
||||
|
|
||||
|
protected IPermissionAppService PermissionAppService { get; } |
||||
|
|
||||
|
public AddResourcePermissionManagementModal(IPermissionAppService permissionAppService) |
||||
|
{ |
||||
|
ObjectMapperContext = typeof(AbpPermissionManagementWebModule); |
||||
|
|
||||
|
PermissionAppService = permissionAppService; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<IActionResult> OnGetAsync() |
||||
|
{ |
||||
|
ValidateModel(); |
||||
|
|
||||
|
ResourcePermissionDefinitions = await PermissionAppService.GetResourceDefinitionsAsync(ResourceName); |
||||
|
|
||||
|
return Page(); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<IActionResult> OnPostAsync() |
||||
|
{ |
||||
|
ValidateModel(); |
||||
|
|
||||
|
await PermissionAppService.UpdateResourceAsync( |
||||
|
ResourceName, |
||||
|
ResourceKey, |
||||
|
new UpdateResourcePermissionsDto() |
||||
|
{ |
||||
|
ProviderName = AddModel.ProviderName, |
||||
|
ProviderKey = AddModel.ProviderKey, |
||||
|
Permissions = AddModel.Permissions ?? new List<string>() |
||||
|
} |
||||
|
); |
||||
|
|
||||
|
return NoContent(); |
||||
|
} |
||||
|
|
||||
|
public class ResourcePermissionViewModel |
||||
|
{ |
||||
|
[Required] |
||||
|
public string ProviderName { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
public string ProviderKey { get; set; } |
||||
|
|
||||
|
public List<string> Permissions { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
@page |
||||
|
@using System.Web; |
||||
|
@using Microsoft.AspNetCore.Mvc.Localization |
||||
|
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
||||
|
@using Volo.Abp.Localization |
||||
|
@using Volo.Abp.PermissionManagement.Localization |
||||
|
@using Volo.Abp.PermissionManagement.Web.Pages.AbpPermissionManagement |
||||
|
@model ResourcePermissionManagementModal |
||||
|
@inject IHtmlLocalizer<AbpPermissionManagementResource> L |
||||
|
|
||||
|
@{ |
||||
|
Layout = null; |
||||
|
} |
||||
|
|
||||
|
<script src="/client-proxies/permissionManagement-proxy.js"></script> |
||||
|
|
||||
|
<form method="post" asp-page="/AbpPermissionManagement/ResourcePermissionManagementModal"> |
||||
|
<abp-modal size="ExtraLarge"> |
||||
|
<abp-modal-header title="@(L["ResourcePermissions"].Value) - @(HttpUtility.HtmlEncode(Model.ResourceDisplayName))"></abp-modal-header> |
||||
|
<input asp-for="@Model.ResourceName" /> |
||||
|
<input asp-for="@Model.ResourceKey" /> |
||||
|
<input asp-for="@Model.ResourceDisplayName" /> |
||||
|
<abp-modal-body> |
||||
|
<div class="d-grid gap-2 mb-2 d-md-flex justify-content-md-end"> |
||||
|
<button class="btn btn-sm btn-primary" id="addPermission" type="button">Add Permission</button> |
||||
|
</div> |
||||
|
<abp-table id="resourcePermissionTable" class="nowrap"></abp-table> |
||||
|
</abp-modal-body> |
||||
|
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer> |
||||
|
</abp-modal> |
||||
|
</form> |
||||
@ -0,0 +1,58 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; |
||||
|
|
||||
|
namespace Volo.Abp.PermissionManagement.Web.Pages.AbpPermissionManagement; |
||||
|
|
||||
|
public class ResourcePermissionManagementModal : AbpPageModel |
||||
|
{ |
||||
|
[Required] |
||||
|
[HiddenInput] |
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public string ResourceName { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
[HiddenInput] |
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public string ResourceKey { get; set; } |
||||
|
|
||||
|
[HiddenInput] |
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public string ResourceDisplayName { get; set; } |
||||
|
|
||||
|
public GetResourcePermissionListResultDto ResourcePermissions { get; set; } |
||||
|
|
||||
|
protected IPermissionAppService PermissionAppService { get; } |
||||
|
|
||||
|
public ResourcePermissionManagementModal(IPermissionAppService permissionAppService) |
||||
|
{ |
||||
|
ObjectMapperContext = typeof(AbpPermissionManagementWebModule); |
||||
|
|
||||
|
PermissionAppService = permissionAppService; |
||||
|
} |
||||
|
|
||||
|
public virtual Task<IActionResult> OnGetAsync() |
||||
|
{ |
||||
|
ValidateModel(); |
||||
|
return Task.FromResult<IActionResult>(Page()); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<IActionResult> OnPostAsync() |
||||
|
{ |
||||
|
ValidateModel(); |
||||
|
|
||||
|
|
||||
|
return NoContent(); |
||||
|
} |
||||
|
|
||||
|
public class ResourcePermissionViewModel |
||||
|
{ |
||||
|
public string ProviderName { get; set; } |
||||
|
|
||||
|
public string ProviderKey { get; set; } |
||||
|
|
||||
|
public List<string> Permissions { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,49 @@ |
|||||
|
@page |
||||
|
@using System.Web; |
||||
|
@using Microsoft.AspNetCore.Mvc.Localization |
||||
|
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
||||
|
@using Volo.Abp.Localization |
||||
|
@using Volo.Abp.PermissionManagement.Localization |
||||
|
@using Volo.Abp.PermissionManagement.Web.Pages.AbpPermissionManagement |
||||
|
@model UpdateResourcePermissionManagementModal |
||||
|
@inject IHtmlLocalizer<AbpPermissionManagementResource> L |
||||
|
|
||||
|
@{ |
||||
|
Layout = null; |
||||
|
} |
||||
|
|
||||
|
<script src="/client-proxies/permissionManagement-proxy.js"></script> |
||||
|
<script src="/Pages/AbpPermissionManagement/update-resource-permission-management-modal.js"></script> |
||||
|
|
||||
|
<form method="post" asp-page="/AbpPermissionManagement/UpdateResourcePermissionManagementModal"> |
||||
|
<abp-modal> |
||||
|
<abp-modal-header title="@(L["UpdateResourcePermissions"].Value)"></abp-modal-header> |
||||
|
<input asp-for="@Model.ResourceName" /> |
||||
|
<input asp-for="@Model.ResourceKey" /> |
||||
|
<input asp-for="@Model.ProviderName" /> |
||||
|
<input asp-for="@Model.ProviderKey" /> |
||||
|
<abp-modal-body> |
||||
|
<div class="mb-3"> |
||||
|
<label class="form-label">Resource name:</label> |
||||
|
<p>@(HttpUtility.HtmlEncode(Model.ResourceDisplayName))</p> |
||||
|
</div> |
||||
|
<div class="mb-3" id="permissionList"> |
||||
|
<div class="mb-1 d-flex align-items-center justify-content-between"> |
||||
|
<label class="form-labe">Permissions:</label> |
||||
|
<div class="form-check form-switch"> |
||||
|
<input class="form-check-input" id="grantAllresourcePermissions" type="checkbox" checked="@Model.ResourcePermissions.Permissions.All(x => x.IsGranted)"> |
||||
|
<label class="form-check-label">Grant all</label> |
||||
|
</div> |
||||
|
</div> |
||||
|
@foreach (var permission in Model.ResourcePermissions.Permissions) |
||||
|
{ |
||||
|
<div class="form-check"> |
||||
|
<input class="form-check-input" type="checkbox" name="UpdateModel.Permissions[]" value="@permission.Name" checked="@permission.IsGranted"> |
||||
|
<label class="form-check-label">@permission.DisplayName</label> |
||||
|
</div> |
||||
|
} |
||||
|
</div> |
||||
|
</abp-modal-body> |
||||
|
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer> |
||||
|
</abp-modal> |
||||
|
</form> |
||||
@ -0,0 +1,79 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; |
||||
|
|
||||
|
namespace Volo.Abp.PermissionManagement.Web.Pages.AbpPermissionManagement; |
||||
|
|
||||
|
public class UpdateResourcePermissionManagementModal : AbpPageModel |
||||
|
{ |
||||
|
[Required] |
||||
|
[HiddenInput] |
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public string ResourceName { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
[HiddenInput] |
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public string ResourceKey { get; set; } |
||||
|
|
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public string ResourceDisplayName { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
[HiddenInput] |
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public string ProviderName { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
[HiddenInput] |
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public string ProviderKey { get; set; } |
||||
|
|
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public ResourcePermissionViewModel UpdateModel { get; set; } |
||||
|
|
||||
|
public GetResourcePermissionWithProviderListResultDto ResourcePermissions { get; set; } |
||||
|
|
||||
|
protected IPermissionAppService PermissionAppService { get; } |
||||
|
|
||||
|
public UpdateResourcePermissionManagementModal(IPermissionAppService permissionAppService) |
||||
|
{ |
||||
|
ObjectMapperContext = typeof(AbpPermissionManagementWebModule); |
||||
|
|
||||
|
PermissionAppService = permissionAppService; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<IActionResult> OnGetAsync() |
||||
|
{ |
||||
|
ValidateModel(); |
||||
|
|
||||
|
ResourcePermissions = await PermissionAppService.GetResourceByProviderAsync(ResourceName, ResourceKey, ProviderName, ProviderKey); |
||||
|
|
||||
|
return Page(); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<IActionResult> OnPostAsync() |
||||
|
{ |
||||
|
ValidateModel(); |
||||
|
|
||||
|
await PermissionAppService.UpdateResourceAsync( |
||||
|
ResourceName, |
||||
|
ResourceKey, |
||||
|
new UpdateResourcePermissionsDto() |
||||
|
{ |
||||
|
ProviderName = ProviderName, |
||||
|
ProviderKey = ProviderKey, |
||||
|
Permissions = UpdateModel.Permissions ?? new List<string>() |
||||
|
} |
||||
|
); |
||||
|
|
||||
|
return NoContent(); |
||||
|
} |
||||
|
|
||||
|
public class ResourcePermissionViewModel |
||||
|
{ |
||||
|
public List<string> Permissions { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
var abp = abp || {}; |
||||
|
(function ($) { |
||||
|
var $all = $("#grantAllresourcePermissions"); |
||||
|
var $items = $("#permissionList input[type='checkbox']").not("#grantAllresourcePermissions"); |
||||
|
$all.on("change", function () { |
||||
|
$items.prop("checked", this.checked); |
||||
|
}); |
||||
|
$items.on("change", function () { |
||||
|
$all.prop("checked", $items.length === $items.filter(":checked").length); |
||||
|
}); |
||||
|
})(jQuery); |
||||
@ -0,0 +1,126 @@ |
|||||
|
var abp = abp || {}; |
||||
|
(function ($) { |
||||
|
var l = abp.localization.getResource('AbpPermissionManagement'); |
||||
|
var _dataTable = null; |
||||
|
|
||||
|
abp.ui.extensions.entityActions.get('permissionManagement.resource').addContributor( |
||||
|
function (actionList) { |
||||
|
return actionList.addManyTail( |
||||
|
[ |
||||
|
{ |
||||
|
text: l('Edit'), |
||||
|
action: function (data) { |
||||
|
var _updateResourcePermissionsModal = new abp.ModalManager(abp.appPath + "AbpPermissionManagement/UpdateResourcePermissionManagementModal"); |
||||
|
_updateResourcePermissionsModal.open({ |
||||
|
resourceName: $("#ResourceName").val(), |
||||
|
resourceKey: $("#ResourceKey").val(), |
||||
|
resourceDisplayName: $("#ResourceDisplayName").val(), |
||||
|
providerName: data.record.providerName, |
||||
|
providerKey: data.record.providerKey |
||||
|
}); |
||||
|
_updateResourcePermissionsModal.onResult(function () { |
||||
|
_dataTable.ajax.reloadEx(); |
||||
|
}); |
||||
|
}, |
||||
|
}, |
||||
|
{ |
||||
|
text: l('Delete'), |
||||
|
confirmMessage: function (data) { |
||||
|
return l( |
||||
|
'ResourcePermissionDeletionConfirmationMessage', |
||||
|
data.record.name |
||||
|
); |
||||
|
}, |
||||
|
action: function (data) { |
||||
|
volo.abp.permissionManagement.permissions.deleteResource($("#ResourceName").val(), $("#ResourceKey").val(), data.record.providerName, data.record.providerKey).then(function () { |
||||
|
abp.notify.info(l('SuccessfullyDeleted')); |
||||
|
_dataTable.ajax.reloadEx(); |
||||
|
}); |
||||
|
}, |
||||
|
} |
||||
|
] |
||||
|
); |
||||
|
} |
||||
|
); |
||||
|
|
||||
|
abp.ui.extensions.tableColumns.get('permissionManagement.resource').addContributor( |
||||
|
function (columnList) { |
||||
|
columnList.addManyTail( |
||||
|
[ |
||||
|
{ |
||||
|
title: l("Actions"), |
||||
|
rowAction: { |
||||
|
items: abp.ui.extensions.entityActions.get('permissionManagement.resource').actions.toArray() |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
title: l("Target"), |
||||
|
data: 'providerName', |
||||
|
render: function (data, type, row) { |
||||
|
return row.providerName + ' (' + row.providerKey + ')'; |
||||
|
}, |
||||
|
}, |
||||
|
{ |
||||
|
title: l("Permissions"), |
||||
|
data: 'permissions', |
||||
|
render: function (data, type, row) { |
||||
|
var spans = ''; |
||||
|
for (var i = 0; i < row.permissions.length; i++) { |
||||
|
spans += '<span class="d-inline-block bg-light rounded-pill px-2 me-1 mb-1">' + row.permissions[i].name + '</span>'; |
||||
|
} |
||||
|
return spans; |
||||
|
}, |
||||
|
} |
||||
|
] |
||||
|
); |
||||
|
}, |
||||
|
0 //adds as the first contributor
|
||||
|
); |
||||
|
|
||||
|
abp.modals = abp.modals || {}; |
||||
|
|
||||
|
abp.modals.ResourcePermissionManagement = function () { |
||||
|
var initModal = function (publicApi, args) { |
||||
|
_dataTable = $('#resourcePermissionTable').DataTable( |
||||
|
abp.libs.datatables.normalizeConfiguration({ |
||||
|
order: [], |
||||
|
searching: false, |
||||
|
processing: true, |
||||
|
scrollX: true, |
||||
|
serverSide: true, |
||||
|
paging: true, |
||||
|
ajax: function () { |
||||
|
return function (requestData, callback, settings) { |
||||
|
if (callback) { |
||||
|
volo.abp.permissionManagement.permissions.getResource(args.resourceName, args.resourceKey).then(function (result) { |
||||
|
callback({ |
||||
|
recordsTotal: result.permissions.length, |
||||
|
recordsFiltered: result.permissions.length, |
||||
|
data: result.permissions |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
}(), |
||||
|
columnDefs: abp.ui.extensions.tableColumns.get('permissionManagement.resource').columns.toArray(), |
||||
|
}) |
||||
|
); |
||||
|
|
||||
|
$("#addPermission").click(function () { |
||||
|
var _addResourcePermissionsModal = new abp.ModalManager(abp.appPath + "AbpPermissionManagement/AddResourcePermissionManagementModal"); |
||||
|
_addResourcePermissionsModal.open({ |
||||
|
resourceName: $("#ResourceName").val(), |
||||
|
resourceKey: $("#ResourceKey").val(), |
||||
|
resourceDisplayName: $("#ResourceDisplayName").val() |
||||
|
}); |
||||
|
_addResourcePermissionsModal.onResult(function () { |
||||
|
_dataTable.ajax.reloadEx(); |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
return { |
||||
|
initModal: initModal, |
||||
|
}; |
||||
|
}; |
||||
|
})(jQuery); |
||||
@ -0,0 +1,11 @@ |
|||||
|
var abp = abp || {}; |
||||
|
(function ($) { |
||||
|
var $all = $("#grantAllresourcePermissions"); |
||||
|
var $items = $("#permissionList input[type='checkbox']").not("#grantAllresourcePermissions"); |
||||
|
$all.on("change", function () { |
||||
|
$items.prop("checked", this.checked); |
||||
|
}); |
||||
|
$items.on("change", function () { |
||||
|
$all.prop("checked", $items.length === $items.filter(":checked").length); |
||||
|
}); |
||||
|
})(jQuery); |
||||
Loading…
Reference in new issue