|
|
|
@ -1,4 +1,8 @@ |
|
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
|
import { Router } from '@angular/router'; |
|
|
|
|
import { affichageStatut, CollaborateurDTO, EpInformationDTO, EpService, StatutEp } from '@shared/api-swagger'; |
|
|
|
|
import { cles, epTypeRecherche } from '@shared/utils/cles'; |
|
|
|
|
import { Subscription } from 'rxjs'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -12,9 +16,75 @@ import { Component, OnInit } from '@angular/core'; |
|
|
|
|
templateUrl : 'home-collaborateur.component.html' |
|
|
|
|
}) |
|
|
|
|
export class HomeCollaborateurComponent implements OnInit { |
|
|
|
|
constructor() { |
|
|
|
|
|
|
|
|
|
statutEP: any = StatutEp; |
|
|
|
|
|
|
|
|
|
chargement: boolean = true; |
|
|
|
|
|
|
|
|
|
collaborateurConnecte: CollaborateurDTO; |
|
|
|
|
ep: EpInformationDTO; |
|
|
|
|
|
|
|
|
|
prochainEPSubscription: Subscription; |
|
|
|
|
|
|
|
|
|
countEPReferent: Subscription; |
|
|
|
|
|
|
|
|
|
estReferentEPEnCours: boolean = false; |
|
|
|
|
|
|
|
|
|
displayedColumns : string[] = ["agence", "collaborateur", "datearrivee", "typeep", "statutep", "dateentretien", "consultation" ]; |
|
|
|
|
|
|
|
|
|
epTypeRecherche : any = epTypeRecherche; |
|
|
|
|
|
|
|
|
|
constructor(private epService: EpService, private router: Router) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
|
this.setCollaborateurConnecte(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setCollaborateurConnecte() { |
|
|
|
|
if(sessionStorage.getItem(cles.sessionKeyConnectee) == undefined) { |
|
|
|
|
setTimeout( () => this.setCollaborateurConnecte(), 1000); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
this.collaborateurConnecte = JSON.parse(sessionStorage.getItem(cles.sessionKeyConnectee)); |
|
|
|
|
this.getProchainEP(); |
|
|
|
|
this.checkEPReferent(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getProchainEP() { |
|
|
|
|
this.prochainEPSubscription = this.epService.getProchainEPCollaborateur(this.collaborateurConnecte.id).subscribe( |
|
|
|
|
ep => { |
|
|
|
|
this.ep = ep; |
|
|
|
|
this.chargement = false; |
|
|
|
|
}, |
|
|
|
|
err => console.log(err) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
checkEPReferent() { |
|
|
|
|
this.countEPReferent = this.epService.getEPEnCoursReferentCount(this.collaborateurConnecte.id, true, 1, 15, "", "", true, undefined, undefined).subscribe( |
|
|
|
|
count => this.estReferentEPEnCours = count > 0, |
|
|
|
|
err => console.log(err) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
afficherStatutEP(statut: StatutEp) { |
|
|
|
|
return affichageStatut(statut); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ouvrirEP(event) { |
|
|
|
|
if(event.type == "ep") |
|
|
|
|
this.router.navigate(["/ep", event.ep.id]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ngDestroy() { |
|
|
|
|
if(this.prochainEPSubscription != undefined)
|
|
|
|
|
this.prochainEPSubscription.unsubscribe(); |
|
|
|
|
if(this.countEPReferent != undefined) |
|
|
|
|
this.countEPReferent.unsubscribe(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|