mirror of https://github.com/abpframework/abp.git
committed by
GitHub
21 changed files with 429 additions and 15 deletions
@ -0,0 +1,32 @@ |
|||
@page |
|||
@using Microsoft.Extensions.Localization |
|||
@using Volo.Abp.Identity.Web.Localization.Resources.AbpIdentity |
|||
@model Volo.Abp.Identity.Web.Pages.Identity.Roles.CreateModalModel |
|||
@inject IStringLocalizer<IdentityResource> L |
|||
@{ |
|||
Layout = null; |
|||
} |
|||
|
|||
<form method="post" asp-page="/Identity/Roles/CreateModal"> |
|||
|
|||
<abp-modal> |
|||
|
|||
<abp-modal-header title="@L["NewRole"]"></abp-modal-header> |
|||
|
|||
<abp-modal-body> |
|||
|
|||
<div class="form-group"> |
|||
<label asp-for="RoleModel.Name"></label> |
|||
<input asp-for="RoleModel.Name" class="form-control"/> |
|||
<span asp-validation-for="RoleModel.Name" class="text-danger"></span> |
|||
</div> |
|||
|
|||
<div asp-validation-summary="All" class="text-danger"></div> |
|||
|
|||
</abp-modal-body> |
|||
|
|||
<abp-modal-footer></abp-modal-footer> |
|||
|
|||
</abp-modal> |
|||
|
|||
</form> |
|||
@ -0,0 +1,30 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc.RazorPages; |
|||
|
|||
namespace Volo.Abp.Identity.Web.Pages.Identity.Roles |
|||
{ |
|||
public class CreateModalModel : AbpPageModel |
|||
{ |
|||
[BindProperty] |
|||
public CreateRoleInfoModel RoleModel { get; set; } |
|||
|
|||
private readonly IIdentityRoleAppService _identityRoleAppService; |
|||
|
|||
public CreateModalModel(IIdentityRoleAppService identityRoleAppService) |
|||
{ |
|||
_identityRoleAppService = identityRoleAppService; |
|||
RoleModel = new CreateRoleInfoModel(); |
|||
} |
|||
|
|||
public async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
ValidateModel(); |
|||
|
|||
var input = ObjectMapper.Map<CreateRoleInfoModel, IdentityRoleCreateDto>(RoleModel); |
|||
await _identityRoleAppService.CreateAsync(input); |
|||
|
|||
return NoContent(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Volo.Abp.Identity.Web.Pages.Identity.Roles |
|||
{ |
|||
public class CreateRoleInfoModel |
|||
{ |
|||
[Required] |
|||
[StringLength(IdentityRoleConsts.MaxNameLength)] |
|||
[Display(Name = "RoleName")] |
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
@page |
|||
@using Microsoft.Extensions.Localization |
|||
@using Volo.Abp.Identity.Web.Localization.Resources.AbpIdentity |
|||
@model Volo.Abp.Identity.Web.Pages.Identity.Roles.EditModalModel |
|||
@inject IStringLocalizer<IdentityResource> L |
|||
@{ |
|||
Layout = null; |
|||
} |
|||
|
|||
<form method="post" asp-page="/Identity/Roles/EditModal" autocomplete="off"> |
|||
|
|||
<abp-modal> |
|||
|
|||
<abp-modal-header title="@L["Edit"]"></abp-modal-header> |
|||
|
|||
<abp-modal-body> |
|||
|
|||
<input asp-for="RoleInfo.Id" /> |
|||
|
|||
<div class="form-group"> |
|||
<label asp-for="RoleInfo.Name"></label> |
|||
<input asp-for="RoleInfo.Name" class="form-control"/> |
|||
<span asp-validation-for="RoleInfo.Name" class="text-danger"></span> |
|||
</div> |
|||
|
|||
<div asp-validation-summary="All" class="text-danger"></div> |
|||
|
|||
</abp-modal-body> |
|||
|
|||
<abp-modal-footer></abp-modal-footer> |
|||
|
|||
</abp-modal> |
|||
|
|||
</form> |
|||
@ -0,0 +1,37 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc.RazorPages; |
|||
|
|||
namespace Volo.Abp.Identity.Web.Pages.Identity.Roles |
|||
{ |
|||
public class EditModalModel : AbpPageModel |
|||
{ |
|||
[BindProperty] |
|||
public RoleInfoModel RoleInfo { get; set; } |
|||
|
|||
private readonly IIdentityRoleAppService _identityRoleAppService; |
|||
|
|||
public EditModalModel(IIdentityRoleAppService identityRoleAppService) |
|||
{ |
|||
_identityRoleAppService = identityRoleAppService; |
|||
} |
|||
|
|||
public async Task OnGetAsync(Guid id) |
|||
{ |
|||
RoleInfo = ObjectMapper.Map<IdentityRoleDto, RoleInfoModel>( |
|||
await _identityRoleAppService.GetAsync(id) |
|||
); |
|||
} |
|||
|
|||
public async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
ValidateModel(); |
|||
|
|||
var input = ObjectMapper.Map<RoleInfoModel, IdentityRoleUpdateDto>(RoleInfo); |
|||
await _identityRoleAppService.UpdateAsync(RoleInfo.Id, input); |
|||
|
|||
return NoContent(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
@page |
|||
@model Volo.Abp.Identity.Web.Pages.Identity.Roles.IndexModel |
|||
@using Microsoft.AspNetCore.Mvc.Localization |
|||
@using Volo.Abp.Identity.Web.Localization.Resources.AbpIdentity |
|||
@inject IHtmlLocalizer<IdentityResource> L |
|||
@section styles { |
|||
<link rel="stylesheet" type="text/css" href="~/modules/identity/views/roles/index.css" /> |
|||
} |
|||
|
|||
@section scripts { |
|||
<script type="text/javascript" src="~/modules/identity/helpers/jquery.js"></script> |
|||
<script type="text/javascript" src="~/modules/identity/helpers/datatables.extensions.js"></script> |
|||
<script type="text/javascript" src="~/modules/identity/helpers/ResourceLoader.js"></script> |
|||
<script type="text/javascript" src="~/modules/identity/helpers/ModalManager.js"></script> |
|||
<script type="text/javascript" src="~/modules/identity/views/roles/index.js"></script> |
|||
} |
|||
|
|||
<abp-card id="IdentityRolesWrapper"> |
|||
<abp-card-header> |
|||
<div class="row"> |
|||
<div class="col-md-6"> |
|||
<h2>@L["Roles"]</h2> |
|||
</div> |
|||
<div class="col-md-6 text-right"> |
|||
<button type="button" class="btn btn-primary" v-on:click="openCreateModal"> |
|||
<i class="fa fa-plus" aria-hidden="true"></i> |
|||
@L["NewRole"] |
|||
</button> |
|||
</div> |
|||
</div> |
|||
</abp-card-header> |
|||
<abp-card-body> |
|||
<table class="table table-striped nowrap"> |
|||
<thead> |
|||
<tr> |
|||
<th>@L["Actions"]</th> |
|||
<th>@L["RoleName"]</th> |
|||
</tr> |
|||
</thead> |
|||
</table> |
|||
</abp-card-body> |
|||
</abp-card> |
|||
@ -0,0 +1,11 @@ |
|||
using Volo.Abp.AspNetCore.Mvc.RazorPages; |
|||
|
|||
namespace Volo.Abp.Identity.Web.Pages.Identity.Roles |
|||
{ |
|||
public class IndexModel : AbpPageModel |
|||
{ |
|||
public void OnGet() |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
|
|||
namespace Volo.Abp.Identity.Web.Pages.Identity.Roles |
|||
{ |
|||
public class RoleInfoModel |
|||
{ |
|||
[HiddenInput] |
|||
public Guid Id { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(IdentityRoleConsts.MaxNameLength)] |
|||
[Display(Name = "RoleName")] |
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
.dataTable { |
|||
width: 100% !important; |
|||
border-spacing: 0 !important; |
|||
} |
|||
.table td, |
|||
.table th { |
|||
padding: 8px 10px; |
|||
} |
|||
.dataTable tbody tr td button { |
|||
cursor: pointer; |
|||
} |
|||
.dataTable tbody tr td div.dropdown ul.dropdown-menu li { |
|||
cursor: pointer; |
|||
padding: 5px; |
|||
} |
|||
.dataTable tbody tr td div.dropdown ul.dropdown-menu li a { |
|||
display: block; |
|||
} |
|||
.dataTable tbody tr td div.dropdown ul.dropdown-menu li:hover { |
|||
background: #f4f5f8; |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
'use strict'; |
|||
|
|||
$(function () { |
|||
$('#IdentityUsersTable').DataTable(); |
|||
}); |
|||
|
|||
@ -0,0 +1 @@ |
|||
"use strict";$(function(){$("#IdentityUsersTable").DataTable()}); |
|||
@ -0,0 +1,87 @@ |
|||
(function () { |
|||
|
|||
var l = abp.localization.getResource('AbpIdentity'); |
|||
var _identityRoleAppService = volo.abp.identity.identityRole; |
|||
|
|||
var _editModal = new abp.ModalManager({ |
|||
viewUrl: abp.appPath + 'Identity/Roles/EditModal' |
|||
}); |
|||
|
|||
var _createModal = new abp.ModalManager({ |
|||
viewUrl: abp.appPath + 'Identity/Roles/CreateModal' |
|||
}); |
|||
|
|||
var app = new Vue({ |
|||
el: '#IdentityRolesWrapper', |
|||
methods: { |
|||
openCreateModal: function () { |
|||
_createModal.open(); |
|||
} |
|||
} |
|||
}); |
|||
|
|||
$(function () { |
|||
|
|||
var _$wrapper = $('#IdentityRolesWrapper'); |
|||
var _$table = _$wrapper.find('table'); |
|||
|
|||
var _dataTable = _$table.DataTable({ |
|||
order: [[1, "asc"]], |
|||
ajax: abp.libs.datatables.createAjax(_identityRoleAppService.getList), |
|||
columnDefs: [ |
|||
{ |
|||
targets: 0, |
|||
data: null, |
|||
orderable: false, |
|||
autoWidth: false, |
|||
defaultContent: '', |
|||
rowAction: { |
|||
text: '<i class="fa fa-cog"></i> ' + l('Actions') + ' <span class="caret"></span>', |
|||
items: |
|||
[ |
|||
{ |
|||
text: l('Edit'), |
|||
visible: function () { |
|||
return true; |
|||
}, |
|||
action: function (data) { |
|||
_editModal.open({ |
|||
id: data.record.id |
|||
}); |
|||
} |
|||
}, |
|||
{ |
|||
text: l('Delete'), |
|||
visible: function () { |
|||
return true; |
|||
}, |
|||
action: function (data) { |
|||
if (confirm(l('UserDeletionConfirmationMessage', data.record.name))) { |
|||
_identityRoleAppService |
|||
.delete(data.record.id) |
|||
.then(function () { |
|||
_dataTable.ajax.reload(); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
] |
|||
} |
|||
}, |
|||
{ |
|||
targets: 1, |
|||
data: "name" |
|||
} |
|||
] |
|||
}); |
|||
|
|||
_createModal.onResult(function () { |
|||
_dataTable.ajax.reload(); |
|||
}); |
|||
|
|||
_editModal.onResult(function () { |
|||
_dataTable.ajax.reload(); |
|||
}); |
|||
}); |
|||
|
|||
})(); |
|||
@ -0,0 +1,38 @@ |
|||
.dataTable { |
|||
width: 100% !important; |
|||
border-spacing: 0 !important; |
|||
} |
|||
|
|||
.table td, .table th { |
|||
padding: 8px 10px; |
|||
} |
|||
|
|||
.dataTable { |
|||
tbody { |
|||
tr { |
|||
td { |
|||
|
|||
button { |
|||
cursor: pointer; |
|||
} |
|||
|
|||
div.dropdown { |
|||
ul.dropdown-menu { |
|||
li { |
|||
cursor: pointer; |
|||
padding: 5px; |
|||
|
|||
a { |
|||
display: block; |
|||
} |
|||
} |
|||
|
|||
li:hover { |
|||
background: #f4f5f8; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
.dataTable{width:100% !important;border-spacing:0 !important;}.table td,.table th{padding:8px 10px;}.dataTable tbody tr td button{cursor:pointer;}.dataTable tbody tr td div.dropdown ul.dropdown-menu li{cursor:pointer;padding:5px;}.dataTable tbody tr td div.dropdown ul.dropdown-menu li a{display:block;}.dataTable tbody tr td div.dropdown ul.dropdown-menu li:hover{background:#f4f5f8;} |
|||
Loading…
Reference in new issue