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 class="mb-5" style="display: flex;">
<div style="display: flex;">
<mat-card class="home-card"> <mat-card class="home-card">
<mat-card-title class="title-center">Fins de périodes d'essai</mat-card-title> <mat-card-title class="title-center">Fins de périodes d'essai</mat-card-title>
@ -17,7 +15,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <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>{{getCollaborateurById(periodeEssai.collaborateurId).name}} {{getCollaborateurById(periodeEssai.collaborateurId).firstName}}</td>
<td> {{getSplitDate(periodeEssai.plannedEndingDate.toString())}}</td> <td> {{getSplitDate(periodeEssai.plannedEndingDate.toString())}}</td>
</tr> </tr>
@ -97,6 +95,45 @@
</mat-card-content> </mat-card-content>
</mat-card> </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 {PeriodeEssaiService} from "../../services/periode-essai.service";
import {Referencement} from "../../interfaces/referencement"; import {Referencement} from "../../interfaces/referencement";
import {ReferencementService} from "../../services/referencement.service"; 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({ @Component({
selector: 'app-home', selector: 'app-home',
@ -14,18 +18,24 @@ import {ReferencementService} from "../../services/referencement.service";
}) })
export class HomeComponent implements OnInit { export class HomeComponent implements OnInit {
businessUnits: Businessunit[] = [];
agences: Agence[] = [];
collaborateurs: Collaborateur[] = [];
referencements: Referencement[] = []; referencements: Referencement[] = [];
periodeEssais: PeriodeEssai[] = [];
collaborateursSansRef: Collaborateur[] = []; collaborateursSansRef: Collaborateur[] = [];
idReferredTab: number[] = []; idReferredTab: number[] = [];
collaborateurs: Collaborateur[] = [];
periodeEssais: PeriodeEssai[] = [];
periodeEssaisEnCours: PeriodeEssai[] = []; periodeEssaisEnCours: PeriodeEssai[] = [];
isShown : boolean = false; isShown: boolean = false;
constructor( constructor(
private http: HttpClient, private http: HttpClient,
private businessUnitService: BusinessunitService,
private agenceService: AgenceService,
private collaborateurService: CollaborateurService, private collaborateurService: CollaborateurService,
private periodeEssaiService: PeriodeEssaiService, private periodeEssaiService: PeriodeEssaiService,
private referencementService: ReferencementService, private referencementService: ReferencementService,
@ -42,10 +52,8 @@ export class HomeComponent implements OnInit {
this.collaborateurService.getCollaborateurs() this.collaborateurService.getCollaborateurs()
.subscribe(collaborateurs => { .subscribe(collaborateurs => {
this.collaborateurs = collaborateurs; this.collaborateurs = collaborateurs;
this.referencementService.getReferencements() this.referencementService.getReferencements()
.subscribe(referencements => { .subscribe(referencements => {
this.referencements = referencements; this.referencements = referencements;
this.referencements.forEach(ref => { this.referencements.forEach(ref => {
@ -54,7 +62,6 @@ export class HomeComponent implements OnInit {
} }
}); });
this.collaborateurs.forEach(collab => { this.collaborateurs.forEach(collab => {
if (this.idReferredTab.find(id => collab.id == id) == undefined) { if (this.idReferredTab.find(id => collab.id == id) == undefined) {
this.collaborateursSansRef.push(collab); this.collaborateursSansRef.push(collab);
@ -63,12 +70,16 @@ export class HomeComponent implements OnInit {
}); });
}); });
this.getPeriodeEssais(); this.getPeriodeEssais();
this.businessUnitService.getBusinessunits().subscribe(
} businessUnits => {
this.businessUnits = businessUnits
getCollaborateurs(): void { }
this.collaborateurService.getCollaborateurs() )
.subscribe(collaborateurs => this.collaborateurs = collaborateurs); this.agenceService.getAgences().subscribe(
agences => {
this.agences = agences
}
)
} }
getCollaborateurById(id: number): Collaborateur { getCollaborateurById(id: number): Collaborateur {
@ -86,13 +97,13 @@ export class HomeComponent implements OnInit {
getPeriodeEssais() { getPeriodeEssais() {
this.periodeEssaiService.getPeriodeEssais() this.periodeEssaiService.getPeriodeEssais()
.subscribe(periodeEssais => { .subscribe(periodeEssais => {
this.periodeEssais = periodeEssais;
periodeEssais.forEach(pe => { periodeEssais.forEach(pe => {
if (new Date(pe.plannedEndingDate).getTime() > new Date().getTime() && new Date(pe.plannedEndingDate).getTime() < HomeComponent.getNextWeek().getTime()) { if (new Date(pe.plannedEndingDate).getTime() > new Date().getTime() && new Date(pe.plannedEndingDate).getTime() < HomeComponent.getNextWeek().getTime()) {
this.periodeEssaisEnCours.push(pe); this.periodeEssaisEnCours.push(pe);
} }
}) })
this.periodeEssaisEnCours.sort((b, a) => new Date(b.plannedEndingDate).getTime() - new Date(a.plannedEndingDate).getTime()); this.periodeEssaisEnCours.sort((b, a) => new Date(b.plannedEndingDate).getTime() - new Date(a.plannedEndingDate).getTime());
this.periodeEssais = this.periodeEssaisEnCours;
}); });
} }

Loading…
Cancel
Save