|
|
|
@ -1,6 +1,6 @@ |
|
|
|
import { Component, TemplateRef, ViewChild } from '@angular/core'; |
|
|
|
import { Component, TemplateRef, ViewChild, OnInit } from '@angular/core'; |
|
|
|
import { Select, Store } from '@ngxs/store'; |
|
|
|
import { Observable } from 'rxjs'; |
|
|
|
import { Observable, Subject } from 'rxjs'; |
|
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; |
|
|
|
import { IdentityState } from '../../states/identity.state'; |
|
|
|
import { Identity } from '../../models/identity'; |
|
|
|
@ -9,17 +9,22 @@ import { |
|
|
|
IdentityAddRole, |
|
|
|
IdentityDeleteRole, |
|
|
|
IdentityGetRoleById, |
|
|
|
IdentityGetRoles, |
|
|
|
} from '../../actions/identity.actions'; |
|
|
|
import { pluck } from 'rxjs/operators'; |
|
|
|
import { pluck, debounceTime, finalize } from 'rxjs/operators'; |
|
|
|
import { ConfirmationService, Toaster } from '@abp/ng.theme.shared'; |
|
|
|
import { ABP } from '@abp/ng.core'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'abp-roles', |
|
|
|
templateUrl: './roles.component.html', |
|
|
|
}) |
|
|
|
export class RolesComponent { |
|
|
|
export class RolesComponent implements OnInit { |
|
|
|
@Select(IdentityState.getRoles) |
|
|
|
roles$: Observable<Identity.RoleItem[]>; |
|
|
|
data$: Observable<Identity.RoleItem[]>; |
|
|
|
|
|
|
|
@Select(IdentityState.getRolesTotalCount) |
|
|
|
totalCount$: Observable<number>; |
|
|
|
|
|
|
|
form: FormGroup; |
|
|
|
|
|
|
|
@ -31,11 +36,26 @@ export class RolesComponent { |
|
|
|
|
|
|
|
providerKey: string; |
|
|
|
|
|
|
|
pageQuery: ABP.PageQueryParams = { |
|
|
|
sorting: 'name', |
|
|
|
}; |
|
|
|
|
|
|
|
loading: boolean = false; |
|
|
|
|
|
|
|
search$ = new Subject<string>(); |
|
|
|
|
|
|
|
@ViewChild('modalContent', { static: false }) |
|
|
|
modalContent: TemplateRef<any>; |
|
|
|
|
|
|
|
constructor(private confirmationService: ConfirmationService, private fb: FormBuilder, private store: Store) {} |
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
this.search$.pipe(debounceTime(300)).subscribe(value => { |
|
|
|
this.pageQuery.filter = value; |
|
|
|
this.get(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
createForm() { |
|
|
|
this.form = this.fb.group({ |
|
|
|
name: [this.selected.name || '', [Validators.required, Validators.maxLength(256)]], |
|
|
|
@ -89,4 +109,20 @@ export class RolesComponent { |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
onPageChange(data) { |
|
|
|
this.pageQuery.skipCount = data.first; |
|
|
|
this.pageQuery.maxResultCount = data.rows; |
|
|
|
|
|
|
|
this.get(); |
|
|
|
} |
|
|
|
|
|
|
|
get() { |
|
|
|
this.loading = true; |
|
|
|
console.warn(this.pageQuery); |
|
|
|
this.store |
|
|
|
.dispatch(new IdentityGetRoles(this.pageQuery)) |
|
|
|
.pipe(finalize(() => (this.loading = false))) |
|
|
|
.subscribe(); |
|
|
|
} |
|
|
|
} |
|
|
|
|