|
|
|
@ -6,6 +6,7 @@ import {MatTableDataSource} from '@angular/material/table'; |
|
|
|
|
import {MatPaginator} from '@angular/material/paginator'; |
|
|
|
|
import {MatSort} from '@angular/material/sort'; |
|
|
|
|
|
|
|
|
|
import { CollaborateurDTO } from '@shared/api-swagger/model/models' |
|
|
|
|
import { CollaborateursService } from "@shared/api-swagger/api/api"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -20,19 +21,22 @@ import { CollaborateursService } from "@shared/api-swagger/api/api"; |
|
|
|
|
}) |
|
|
|
|
export class CollaborateursComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
collaborateursDisponibles : DisplayCollaborateur[]; |
|
|
|
|
collaborateursFiltre : DisplayCollaborateur[]; |
|
|
|
|
asc = true; |
|
|
|
|
numPage = 1; |
|
|
|
|
parPage = 5; |
|
|
|
|
roles : string[] = ["collaborateur"]; |
|
|
|
|
|
|
|
|
|
private collaborateursDisponiblesSubscription : Subscription; |
|
|
|
|
|
|
|
|
|
displayedColumns : string[] = ["agence", "collaborateur", "dateembauche", "referent"]; |
|
|
|
|
|
|
|
|
|
dataSource : MatTableDataSource<DisplayCollaborateur>; |
|
|
|
|
dataSource : MatTableDataSource<CollaborateurDTO>; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* contenu de la recherche. |
|
|
|
|
*/ |
|
|
|
|
search = ""; |
|
|
|
|
|
|
|
|
|
tri = ""; |
|
|
|
|
/** |
|
|
|
|
* Pagination du tableau. |
|
|
|
|
*/ |
|
|
|
@ -50,34 +54,17 @@ export class CollaborateursComponent implements OnInit { |
|
|
|
|
constructor(private service: CollaborateursService) {} |
|
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
|
this. collaborateursDisponiblesSubscription = this.service.getCollaborateurs(undefined,undefined,undefined,1).subscribe( |
|
|
|
|
collaborateurs => { |
|
|
|
|
this.initCollaborateur(collaborateurs) |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
this.updateDataSource(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
initCollaborateur(collaborateurs:CollaborateurModel[]) { |
|
|
|
|
this.collaborateursDisponibles = []; |
|
|
|
|
let collaborateurDisplay : DisplayCollaborateur; |
|
|
|
|
let today = new Date(); |
|
|
|
|
console.log(collaborateurs); |
|
|
|
|
for(let c of collaborateurs) { |
|
|
|
|
collaborateurDisplay = new DisplayCollaborateur(); |
|
|
|
|
collaborateurDisplay.id = c.id; |
|
|
|
|
collaborateurDisplay.prenom = c.prenom; |
|
|
|
|
collaborateurDisplay.nom = c.nom; |
|
|
|
|
collaborateurDisplay.agence = c.businessUnit.nom; |
|
|
|
|
collaborateurDisplay.embauche = c.dateArrivee; |
|
|
|
|
collaborateurDisplay.anciennete = this.setAnciennete(new Date(c.dateArrivee), today); |
|
|
|
|
collaborateurDisplay.annee = Math.floor(collaborateurDisplay.anciennete / 31536000000); |
|
|
|
|
collaborateurDisplay.mois = Math.floor(collaborateurDisplay.anciennete / 2629800000 % 12); |
|
|
|
|
this.collaborateursDisponibles.push(collaborateurDisplay); |
|
|
|
|
} |
|
|
|
|
this.collaborateursFiltre = this.collaborateursDisponibles; |
|
|
|
|
this.dataSource = new MatTableDataSource(this.collaborateursFiltre); |
|
|
|
|
this.dataSource.paginator = this.paginator; |
|
|
|
|
this.dataSource.sort = this.sort; |
|
|
|
|
updateDataSource() { |
|
|
|
|
this.collaborateursDisponiblesSubscription = this.service.getCollaborateurs(this.asc, this.numPage, this.parPage, this.roles, 1, undefined, this.search, this.tri).subscribe( |
|
|
|
|
collaborateurs => this.dataSource = new MatTableDataSource(collaborateurs), |
|
|
|
|
err => console.log(err) |
|
|
|
|
); |
|
|
|
|
//this.dataSource.paginator = this.paginator;
|
|
|
|
|
//this.dataSource.sort = this.sort;
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|