1
|
import { RtaUser } from './../../../shared/models/rta-user.interface';
|
2
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
3
|
import { SearchUser } from '../../../shared/models/request/search-user.interface';
|
4
|
import { SearchUserComponent } from './search-user/search-user.component';
|
5
|
import { SearchResponse } from 'src/app/shared/models/search-response.interface';
|
6
|
import { UsersService } from 'src/app/shared/services/roles-users-management/user.service';
|
7
|
import { Page } from 'src/app/shared/models/paging/page.interface';
|
8
|
|
9
|
@Component({
|
10
|
selector: 'app-roles-per-user',
|
11
|
templateUrl: './roles-per-user.component.html',
|
12
|
styleUrls: ['./roles-per-user.component.scss']
|
13
|
})
|
14
|
export class RolesPerUserComponent implements OnInit {
|
15
|
searchRequest: SearchUser;
|
16
|
users: SearchResponse<RtaUser>;
|
17
|
loading: boolean;
|
18
|
selectedUser: RtaUser;
|
19
|
paginationEventRequest: { page: number, offset: number };
|
20
|
|
21
|
|
22
|
constructor(private userservice: UsersService) { }
|
23
|
|
24
|
|
25
|
@ViewChild(SearchUserComponent, { static: false })
|
26
|
searchUserComponent: SearchUserComponent;
|
27
|
|
28
|
|
29
|
|
30
|
ngOnInit(): void {
|
31
|
}
|
32
|
|
33
|
lastSearchCriteria: {
|
34
|
userCode: string,
|
35
|
name: string,
|
36
|
surname: string,
|
37
|
email: string,
|
38
|
status: string
|
39
|
};
|
40
|
|
41
|
searchByCriteria(pageNumber = 0, pageSize = 10): void {
|
42
|
// this.searchInitiated.emit(true);
|
43
|
this.loading = true;
|
44
|
this.searchRequest = this.searchUserComponent.searchCriteriaForm.value;
|
45
|
this.userservice.searchByCriteriaPaged(pageNumber, pageSize,this.searchRequest,'search').subscribe((result: Page<RtaUser>) => {
|
46
|
this.users = result;
|
47
|
console.log(this.users);
|
48
|
this.loading = false;
|
49
|
},
|
50
|
error => {
|
51
|
this.loading = false;
|
52
|
});
|
53
|
}
|
54
|
|
55
|
public passData(user: RtaUser): void {
|
56
|
this.selectedUser = user;
|
57
|
}
|
58
|
|
59
|
paginationEvent(paginationEvent) {
|
60
|
this.paginationEventRequest = paginationEvent;
|
61
|
this.searchByCriteria(this.paginationEventRequest.page, this.paginationEventRequest.offset);
|
62
|
}
|
63
|
|
64
|
passEvent(passEvent ) {
|
65
|
if(passEvent){
|
66
|
if(this.paginationEventRequest != undefined){
|
67
|
this.searchByCriteria(this.paginationEventRequest.page, this.paginationEventRequest.offset);
|
68
|
}else{
|
69
|
this.searchByCriteria(0, 10);
|
70
|
}
|
71
|
}
|
72
|
}
|
73
|
|
74
|
clear() {
|
75
|
this.searchUserComponent.resetForm();
|
76
|
}
|
77
|
|
78
|
|
79
|
|
80
|
}
|