|
|
|
@ -1,4 +1,15 @@ |
|
|
|
|
import {Component, OnInit} from '@angular/core'; |
|
|
|
|
import {Collaborateur} from "../../interfaces/collaborateur"; |
|
|
|
|
import {PeriodeEssai} from "../../interfaces/periode-essai"; |
|
|
|
|
import {HttpClient} from "@angular/common/http"; |
|
|
|
|
import {CollaborateurService} from "../../services/collaborateur.service"; |
|
|
|
|
import {PeriodeEssaiService} from "../../services/periode-essai.service"; |
|
|
|
|
import {Referencement} from "../../interfaces/referencement"; |
|
|
|
|
import {ReferencementService} from "../../services/referencement.service"; |
|
|
|
|
import {Businessunit} from "../../interfaces/businessunit"; |
|
|
|
|
import {Agence} from "../../interfaces/agence"; |
|
|
|
|
import {BusinessunitService} from "../../services/businessunit.service"; |
|
|
|
|
import {AgenceService} from "../../services/agence.service"; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-home', |
|
|
|
@ -7,10 +18,100 @@ import {Component, OnInit} from '@angular/core'; |
|
|
|
|
}) |
|
|
|
|
export class HomeComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
|
|
businessUnits: Businessunit[] = []; |
|
|
|
|
agences: Agence[] = []; |
|
|
|
|
collaborateurs: Collaborateur[] = []; |
|
|
|
|
referencements: Referencement[] = []; |
|
|
|
|
periodeEssais: PeriodeEssai[] = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
collaborateursSansRef: Collaborateur[] = []; |
|
|
|
|
idReferredTab: number[] = []; |
|
|
|
|
|
|
|
|
|
periodeEssaisEnCours: PeriodeEssai[] = []; |
|
|
|
|
|
|
|
|
|
isShown: boolean = false; |
|
|
|
|
|
|
|
|
|
constructor( |
|
|
|
|
private http: HttpClient, |
|
|
|
|
private businessUnitService: BusinessunitService, |
|
|
|
|
private agenceService: AgenceService, |
|
|
|
|
private collaborateurService: CollaborateurService, |
|
|
|
|
private periodeEssaiService: PeriodeEssaiService, |
|
|
|
|
private referencementService: ReferencementService, |
|
|
|
|
) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static getNextWeek() { |
|
|
|
|
let result = new Date(); |
|
|
|
|
result.setDate(new Date().getDate() + 7); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.collaborateurService.getCollaborateurs() |
|
|
|
|
.subscribe(collaborateurs => { |
|
|
|
|
this.collaborateurs = collaborateurs; |
|
|
|
|
this.referencementService.getReferencements() |
|
|
|
|
.subscribe(referencements => { |
|
|
|
|
this.referencements = referencements; |
|
|
|
|
this.referencements.forEach(ref => { |
|
|
|
|
|
|
|
|
|
if (this.idReferredTab.find(id => ref.id == id) == undefined) { |
|
|
|
|
this.idReferredTab.push(ref.referredId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
this.collaborateurs.forEach(collab => { |
|
|
|
|
if (this.idReferredTab.find(id => collab.id == id) == undefined) { |
|
|
|
|
this.collaborateursSansRef.push(collab); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
this.getPeriodeEssais(); |
|
|
|
|
this.businessUnitService.getBusinessunits().subscribe( |
|
|
|
|
businessUnits => { |
|
|
|
|
this.businessUnits = businessUnits |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
this.agenceService.getAgences().subscribe( |
|
|
|
|
agences => { |
|
|
|
|
this.agences = agences |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getCollaborateurById(id: number): Collaborateur { |
|
|
|
|
let collab = {} as Collaborateur; |
|
|
|
|
this.collaborateurs.forEach(c => { |
|
|
|
|
if (c.id == id) { |
|
|
|
|
collab = c; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return collab; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getPeriodeEssais() { |
|
|
|
|
this.periodeEssaiService.getPeriodeEssais() |
|
|
|
|
.subscribe(periodeEssais => { |
|
|
|
|
this.periodeEssais = periodeEssais; |
|
|
|
|
periodeEssais.forEach(pe => { |
|
|
|
|
if (new Date(pe.plannedEndingDate).getTime() > new Date().getTime() && new Date(pe.plannedEndingDate).getTime() < HomeComponent.getNextWeek().getTime()) { |
|
|
|
|
this.periodeEssaisEnCours.push(pe); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
this.periodeEssaisEnCours.sort((b, a) => new Date(b.plannedEndingDate).getTime() - new Date(a.plannedEndingDate).getTime()); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getSplitDate(date: string | undefined): string { |
|
|
|
|
if (date == undefined) { |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
return date.split('T')[0]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|