Browse Source

Merge pull request #2412 from abpframework/Identity-roles-paged

Identity roles paged
pull/2473/head
Halil İbrahim Kalkan 7 years ago
committed by GitHub
parent
commit
1405121698
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityRoleAppService.cs
  2. 10
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs
  3. 4
      modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs
  4. 7
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/index.js
  5. 6
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs
  6. 6
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs
  7. 6
      modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs
  8. 8
      npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts
  9. 51
      npm/ng-packs/packages/identity/src/lib/components/users/users.component.html
  10. 8
      npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts

2
modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityRoleAppService.cs

@ -8,7 +8,7 @@ namespace Volo.Abp.Identity
{
public interface IIdentityRoleAppService : IApplicationService
{
Task<ListResultDto<IdentityRoleDto>> GetListAsync();
Task<PagedResultDto<IdentityRoleDto>> GetListAsync(PagedAndSortedResultRequestDto input);
Task<IdentityRoleDto> CreateAsync(IdentityRoleCreateDto input);

10
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs

@ -28,11 +28,15 @@ namespace Volo.Abp.Identity
);
}
public virtual async Task<ListResultDto<IdentityRoleDto>> GetListAsync()
public virtual async Task<PagedResultDto<IdentityRoleDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{
var list = await _roleRepository.GetListAsync();
var list = await _roleRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount);
var totalCount = await _roleRepository.GetCountAsync();
return new ListResultDto<IdentityRoleDto>(ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(list));
return new PagedResultDto<IdentityRoleDto>(
totalCount,
ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(list)
);
}
[Authorize(IdentityPermissions.Roles.Create)]

4
modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs

@ -20,9 +20,9 @@ namespace Volo.Abp.Identity
}
[HttpGet]
public virtual Task<ListResultDto<IdentityRoleDto>> GetListAsync()
public virtual Task<PagedResultDto<IdentityRoleDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{
return _roleAppService.GetListAsync();
return _roleAppService.GetListAsync(input);
}
[HttpGet]

7
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/index.js

@ -14,9 +14,10 @@
var _dataTable = _$table.DataTable(abp.libs.datatables.normalizeConfiguration({
order: [[1, "asc"]],
searching:false,
paging:false,
info:false,
searching: false,
processing: true,
serverSide: true,
paging: true,
ajax: abp.libs.datatables.createAjax(_identityRoleAppService.getList),
columnDefs: [
{

6
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Application.Dtos;
namespace Volo.Abp.Identity.Web.Pages.Identity.Users
{
@ -27,7 +28,10 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users
{
UserInfo = new UserInfoViewModel();
var roleDtoList = await _identityRoleAppService.GetListAsync();
var roleDtoList = await _identityRoleAppService.GetListAsync(new PagedAndSortedResultRequestDto
{
MaxResultCount = int.MaxValue
});
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>(roleDtoList.Items);

6
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs

@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities;
namespace Volo.Abp.Identity.Web.Pages.Identity.Users
@ -30,7 +31,10 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users
UserInfo = ObjectMapper.Map<IdentityUserDto, UserInfoViewModel>(await _identityUserAppService.GetAsync(id));
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>(
(await _identityRoleAppService.GetListAsync()).Items
(await _identityRoleAppService.GetListAsync(new PagedAndSortedResultRequestDto
{
MaxResultCount = int.MaxValue
})).Items
);
var userRoleNames = (await _identityUserAppService.GetRolesAsync(UserInfo.Id)).Items.Select(r => r.Name).ToList();

6
modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs

@ -3,6 +3,7 @@ using System.Linq;
using System.Threading.Tasks;
using Xunit;
using Shouldly;
using Volo.Abp.Application.Dtos;
namespace Volo.Abp.Identity
{
@ -38,7 +39,10 @@ namespace Volo.Abp.Identity
{
//Act
var result = await _roleAppService.GetListAsync();
var result = await _roleAppService.GetListAsync(new PagedAndSortedResultRequestDto
{
MaxResultCount = int.MaxValue
});
//Assert

8
npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts

@ -1,7 +1,7 @@
import { ABP } from '@abp/ng.core';
import { ConfirmationService, Toaster } from '@abp/ng.theme.shared';
import { Component, TemplateRef, ViewChild, OnInit, ContentChild, ElementRef } from '@angular/core';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { Select, Store } from '@ngxs/store';
import { Observable } from 'rxjs';
import { finalize, pluck } from 'rxjs/operators';
@ -59,7 +59,7 @@ export class RolesComponent implements OnInit {
this.get();
}
createForm() {
buildForm() {
this.form = this.fb.group({
name: new FormControl({ value: this.selected.name || '', disabled: this.selected.isStatic }, [
Validators.required,
@ -71,7 +71,7 @@ export class RolesComponent implements OnInit {
}
openModal() {
this.createForm();
this.buildForm();
this.isModalVisible = true;
}

51
npm/ng-packs/packages/identity/src/lib/components/users/users.component.html

@ -12,7 +12,8 @@
type="button"
(click)="add()"
>
<i class="fa fa-plus mr-1"></i> <span>{{ 'AbpIdentity::NewUser' | abpLocalization }}</span>
<i class="fa fa-plus mr-1"></i>
<span>{{ 'AbpIdentity::NewUser' | abpLocalization }}</span>
</button>
</div>
</div>
@ -59,12 +60,21 @@
<th>{{ 'AbpIdentity::Actions' | abpLocalization }}</th>
<th pResizableColumn (click)="sortOrderIcon.sort('userName')">
{{ 'AbpIdentity::UserName' | abpLocalization }}
<abp-sort-order-icon #sortOrderIcon key="userName" [(selectedKey)]="sortKey" [(order)]="sortOrder">
<abp-sort-order-icon
#sortOrderIcon
key="userName"
[(selectedKey)]="sortKey"
[(order)]="sortOrder"
>
</abp-sort-order-icon>
</th>
<th pResizableColumn (click)="sortOrderIcon.sort('email')">
{{ 'AbpIdentity::EmailAddress' | abpLocalization }}
<abp-sort-order-icon key="email" [(selectedKey)]="sortKey" [(order)]="sortOrder"></abp-sort-order-icon>
<abp-sort-order-icon
key="email"
[(selectedKey)]="sortKey"
[(order)]="sortOrder"
></abp-sort-order-icon>
</th>
<th pResizableColumn (click)="sortOrderIcon.sort('phoneNumber')">
{{ 'AbpIdentity::PhoneNumber' | abpLocalization }}
@ -86,7 +96,11 @@
<i class="fa fa-cog mr-1"></i>{{ 'AbpIdentity::Actions' | abpLocalization }}
</button>
<div ngbDropdownMenu>
<button *abpPermission="'AbpIdentity.Users.Update'" ngbDropdownItem (click)="edit(data.id)">
<button
*abpPermission="'AbpIdentity.Users.Update'"
ngbDropdownItem
(click)="edit(data.id)"
>
{{ 'AbpIdentity::Edit' | abpLocalization }}
</button>
<button
@ -133,7 +147,13 @@
<div class="form-group">
<label for="user-name">{{ 'AbpIdentity::UserName' | abpLocalization }}</label
><span> * </span>
<input type="text" id="user-name" class="form-control" formControlName="userName" autofocus />
<input
type="text"
id="user-name"
class="form-control"
formControlName="userName"
autofocus
/>
</div>
<div class="form-group">
@ -142,7 +162,9 @@
</div>
<div class="form-group">
<label for="surname">{{ 'AbpIdentity::DisplayName:Surname' | abpLocalization }}</label>
<label for="surname">{{
'AbpIdentity::DisplayName:Surname' | abpLocalization
}}</label>
<input type="text" id="surname" class="form-control" formControlName="surname" />
</div>
@ -166,7 +188,12 @@
<div class="form-group">
<label for="phone-number">{{ 'AbpIdentity::PhoneNumber' | abpLocalization }}</label>
<input type="text" id="phone-number" class="form-control" formControlName="phoneNumber" />
<input
type="text"
id="phone-number"
class="form-control"
formControlName="phoneNumber"
/>
</div>
<div class="custom-checkbox custom-control mb-2">
@ -210,7 +237,9 @@
[attr.id]="'roles-' + i"
[formControl]="roleGroup.controls[roles[i].name]"
/>
<label class="custom-control-label" [attr.for]="'roles-' + i">{{ roles[i].name }}</label>
<label class="custom-control-label" [attr.for]="'roles-' + i">{{
roles[i].name
}}</label>
</div>
</div>
</ng-template>
@ -229,5 +258,9 @@
</ng-template>
</abp-modal>
<abp-permission-management [(visible)]="visiblePermissions" providerName="U" [providerKey]="providerKey">
<abp-permission-management
[(visible)]="visiblePermissions"
providerName="U"
[providerKey]="providerKey"
>
</abp-permission-management>

8
npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts

@ -1,14 +1,15 @@
import { ABP, ConfigState } from '@abp/ng.core';
import { ConfirmationService, Toaster } from '@abp/ng.theme.shared';
import { Component, TemplateRef, TrackByFunction, ViewChild, OnInit } from '@angular/core';
import { Component, OnInit, TemplateRef, TrackByFunction, ViewChild } from '@angular/core';
import {
AbstractControl,
FormArray,
FormBuilder,
FormControl,
FormGroup,
Validators,
FormControl,
} from '@angular/forms';
import { PasswordRules, validatePassword } from '@ngx-validate/core';
import { Select, Store } from '@ngxs/store';
import { Observable } from 'rxjs';
import { finalize, pluck, switchMap, take } from 'rxjs/operators';
@ -16,15 +17,14 @@ import snq from 'snq';
import {
CreateUser,
DeleteUser,
GetRoles,
GetUserById,
GetUserRoles,
GetUsers,
UpdateUser,
GetRoles,
} from '../../actions/identity.actions';
import { Identity } from '../../models/identity';
import { IdentityState } from '../../states/identity.state';
import { PasswordRules, validatePassword } from '@ngx-validate/core';
@Component({
selector: 'abp-users',
templateUrl: './users.component.html',

Loading…
Cancel
Save