ajout des stats

pull/26/head
Clement FERRERE 2 years ago
parent 96d56cf5bd
commit 56be2bafe2
  1. 49
      src/app/components/home/home.component.html
  2. 37
      src/app/components/home/home.component.ts

@ -1,8 +1,6 @@
<h2>Services Collaborateurs EPA</h2>
<h2 class="mb-4">Services Collaborateurs EPA</h2>
<h4 class=mb-4></h4>
<div style="display: flex;">
<div class="mb-5" style="display: flex;">
<mat-card class="home-card">
<mat-card-title class="title-center">Fins de périodes d'essai</mat-card-title>
@ -17,7 +15,7 @@
</tr>
</thead>
<tbody>
<tr *ngFor="let periodeEssai of periodeEssais | slice:0:5;">
<tr *ngFor="let periodeEssai of periodeEssaisEnCours | slice:0:5;">
<td>{{getCollaborateurById(periodeEssai.collaborateurId).name}} {{getCollaborateurById(periodeEssai.collaborateurId).firstName}}</td>
<td> {{getSplitDate(periodeEssai.plannedEndingDate.toString())}}</td>
</tr>
@ -97,6 +95,45 @@
</mat-card-content>
</mat-card>
<mat-card class="home-card">
<mat-card-title class="title-center">Statistiques</mat-card-title>
<mat-card-content>
<div class="col-12">
<table class="table">
<thead>
<tr>
<th scope="col">Entité</th>
<th scope="col">Total</th>
</tr>
</thead>
<tbody>
<tr>
<td>Business Units</td>
<td>{{businessUnits.length}}</td>
</tr>
<tr>
<td>Agences</td>
<td>{{agences.length}}</td>
</tr>
<tr>
<td>Collaborateur</td>
<td>{{collaborateurs.length}}</td>
</tr>
<tr>
<td>Référencements</td>
<td>{{referencements.length}}</td>
</tr>
<tr>
<td>Périodes d'essai</td>
<td>{{periodeEssais.length}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</mat-card-content>
<mat-card-actions>
</mat-card-actions>
</mat-card>
</div>

@ -6,6 +6,10 @@ 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',
@ -14,18 +18,24 @@ import {ReferencementService} from "../../services/referencement.service";
})
export class HomeComponent implements OnInit {
businessUnits: Businessunit[] = [];
agences: Agence[] = [];
collaborateurs: Collaborateur[] = [];
referencements: Referencement[] = [];
periodeEssais: PeriodeEssai[] = [];
collaborateursSansRef: Collaborateur[] = [];
idReferredTab: number[] = [];
collaborateurs: Collaborateur[] = [];
periodeEssais: PeriodeEssai[] = [];
periodeEssaisEnCours: PeriodeEssai[] = [];
isShown : boolean = false;
isShown: boolean = false;
constructor(
private http: HttpClient,
private businessUnitService: BusinessunitService,
private agenceService: AgenceService,
private collaborateurService: CollaborateurService,
private periodeEssaiService: PeriodeEssaiService,
private referencementService: ReferencementService,
@ -42,10 +52,8 @@ export class HomeComponent implements OnInit {
this.collaborateurService.getCollaborateurs()
.subscribe(collaborateurs => {
this.collaborateurs = collaborateurs;
this.referencementService.getReferencements()
.subscribe(referencements => {
this.referencements = referencements;
this.referencements.forEach(ref => {
@ -54,7 +62,6 @@ export class HomeComponent implements OnInit {
}
});
this.collaborateurs.forEach(collab => {
if (this.idReferredTab.find(id => collab.id == id) == undefined) {
this.collaborateursSansRef.push(collab);
@ -63,12 +70,16 @@ export class HomeComponent implements OnInit {
});
});
this.getPeriodeEssais();
}
getCollaborateurs(): void {
this.collaborateurService.getCollaborateurs()
.subscribe(collaborateurs => this.collaborateurs = collaborateurs);
this.businessUnitService.getBusinessunits().subscribe(
businessUnits => {
this.businessUnits = businessUnits
}
)
this.agenceService.getAgences().subscribe(
agences => {
this.agences = agences
}
)
}
getCollaborateurById(id: number): Collaborateur {
@ -86,13 +97,13 @@ export class HomeComponent implements OnInit {
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());
this.periodeEssais = this.periodeEssaisEnCours;
});
}

Loading…
Cancel
Save