@ -1,28 +1,12 @@
import { ListService , PagedResultDto } from '@abp/ng.core' ;
import {
GetIdentityUsersInput ,
IdentityRoleDto ,
IdentityUserDto ,
IdentityUserService ,
} from '@abp/ng.identity/proxy' ;
import { ePermissionManagementComponents } from '@abp/ng.permission-management' ;
import { Confirmation , ConfirmationService , ToasterService } from '@abp/ng.theme.shared' ;
import {
EXTENSIONS_IDENTIFIER ,
FormPropData ,
generateFormFromProps ,
} from '@abp/ng.theme.shared/extensions' ;
import {
Component ,
Injector ,
OnInit ,
TemplateRef ,
TrackByFunction ,
ViewChild ,
} from '@angular/core' ;
import { AbstractControl , UntypedFormArray , UntypedFormBuilder , UntypedFormGroup } from '@angular/forms' ;
import { finalize , switchMap , tap } from 'rxjs/operators' ;
import { eIdentityComponents } from '../../enums/components' ;
import { ListService , PagedResultDto } from "@abp/ng.core" ;
import { GetIdentityUsersInput , IdentityRoleDto , IdentityUserDto , IdentityUserService } from "@abp/ng.identity/proxy" ;
import { ePermissionManagementComponents } from "@abp/ng.permission-management" ;
import { Confirmation , ConfirmationService , ToasterService } from "@abp/ng.theme.shared" ;
import { EXTENSIONS_IDENTIFIER , FormPropData , generateFormFromProps } from "@abp/ng.theme.shared/extensions" ;
import { Component , Injector , OnInit , TemplateRef , TrackByFunction , ViewChild } from "@angular/core" ;
import { AbstractControl , UntypedFormArray , UntypedFormBuilder , UntypedFormGroup } from "@angular/forms" ;
import { finalize , switchMap , tap } from "rxjs/operators" ;
import { eIdentityComponents } from "../../enums/components" ;
@Component ( {
selector : 'abp-users' ,
@ -39,31 +23,31 @@ export class UsersComponent implements OnInit {
data : PagedResultDto < IdentityUserDto > = { items : [ ] , totalCount : 0 } ;
@ViewChild ( 'modalContent' , { static : false } )
modalContent : TemplateRef < any > ;
modalContent ! : TemplateRef < any > ;
form : UntypedFormGroup ;
form ! : UntypedFormGroup ;
selected : IdentityUserDto ;
selected? : IdentityUserDto ;
selectedUserRoles : IdentityRoleDto [ ] ;
selectedUserRoles? : IdentityRoleDto [ ] ;
roles : IdentityRoleDto [ ] ;
roles? : IdentityRoleDto [ ] ;
visiblePermissions = false ;
providerKey : string ;
providerKey? : string ;
isModalVisible : boolean ;
isModalVisible? : boolean ;
modalBusy = false ;
permissionManagementKey = ePermissionManagementComponents . PermissionManagement ;
entityDisplayName : string ;
entityDisplayName? : string ;
trackByFn : TrackByFunction < AbstractControl > = ( index , item ) = > Object . keys ( item ) [ 0 ] || index ;
onVisiblePermissionChange = event = > {
onVisiblePermissionChange = ( event : boolean ) = > {
this . visiblePermissions = event ;
} ;
@ -90,20 +74,22 @@ export class UsersComponent implements OnInit {
this . service . getAssignableRoles ( ) . subscribe ( ( { items } ) = > {
this . roles = items ;
this . form . addControl (
'roleNames' ,
this . fb . array (
this . roles . map ( role = >
this . fb . group ( {
[ role . name ] : [
this . selected . id
? ! ! this . selectedUserRoles ? . find ( userRole = > userRole . id === role . id )
: role . isDefault ,
] ,
} ) ,
if ( this . roles ) {
this . form . addControl (
'roleNames' ,
this . fb . array (
this . roles . map ( role = >
this . fb . group ( {
[ role . name as string ] : [
this . selected ? . id
? ! ! this . selectedUserRoles ? . find ( userRole = > userRole . id === role . id )
: role . isDefault ,
] ,
} ) ,
) ,
) ,
) ,
) ;
) ;
}
} ) ;
}
@ -137,10 +123,11 @@ export class UsersComponent implements OnInit {
const { roleNames = [ ] } = this . form . value ;
const mappedRoleNames =
roleNames . filter ( role = > ! ! role [ Object . keys ( role ) [ 0 ] ] ) . map ( role = > Object . keys ( role ) [ 0 ] ) ||
[ ] ;
roleNames
. filter ( ( role : { [ key : string ] : any } ) = > ! ! role [ Object . keys ( role ) [ 0 ] ] )
. map ( ( role : { [ key : string ] : any } ) = > Object . keys ( role ) [ 0 ] ) || [ ] ;
const { id } = this . selected ;
const { id } = this . selected || { } ;
( id
? this . service . update ( id , {
@ -166,12 +153,13 @@ export class UsersComponent implements OnInit {
if ( status === Confirmation . Status . confirm ) {
this . service . delete ( id ) . subscribe ( ( ) = > {
this . toasterService . success ( 'AbpUi::SuccessfullyDeleted' ) ;
this . list . get ( ) } ) ;
this . list . get ( ) ;
} ) ;
}
} ) ;
}
sort ( data ) {
sort ( data : any ) {
const { prop , dir } = data . sorts [ 0 ] ;
this . list . sortKey = prop ;
this . list . sortOrder = dir ;