From ce3b6d78ebf975a83b56d83a470bd34fc066fb60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yana=C3=ABl=20GRETTE?= Date: Wed, 5 Aug 2020 16:03:18 +0200 Subject: [PATCH] =?UTF-8?q?Impl=C3=A9mentation=20du=20nav-menu,=20du=20hom?= =?UTF-8?q?e=20et=20de=20l'affichage=20de=20la=20liste=20des=20formations?= =?UTF-8?q?=20c=C3=B4t=C3=A9=20RH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../collaborateurs.component.ts | 2 +- .../collaborateurs.routing.module.ts | 4 +- .../details-collaborateur.component.ts | 2 +- .../demandes-formation.routing.module.ts | 5 +- src/app/formations/formations.component.html | 30 ++++++ src/app/formations/formations.component.ts | 96 +++++++++++++++++- .../formations/formations.routing.module.ts | 2 +- .../home-assistante.component.ts | 2 +- src/app/home/home-rh/home-rh.component.html | 30 ++++++ src/app/home/home-rh/home-rh.component.ts | 99 ++++++++++++++++++- .../details-referent.component.ts | 2 +- src/app/referents/referents.component.ts | 2 +- .../api-swagger/api/formations.service.ts | 8 +- .../api-swagger/model/formationModel.ts | 19 ++-- .../nav-menu-rh/nav-menu-rh.component.html | 13 ++- .../shared/nav-menu/nav-menu.component.html | 2 + 16 files changed, 289 insertions(+), 29 deletions(-) diff --git a/src/app/collaborateurs/collaborateurs.component.ts b/src/app/collaborateurs/collaborateurs.component.ts index f9dc960..5ae3060 100644 --- a/src/app/collaborateurs/collaborateurs.component.ts +++ b/src/app/collaborateurs/collaborateurs.component.ts @@ -9,7 +9,7 @@ import {MatSort} from '@angular/material/sort'; import { CollaborateursService } from "@shared/api-swagger/api/api"; import { CollaborateurModel } from "@shared/api-swagger/model/models"; -import { DisplayCollaborateur } from "@shared/displayInfo/displayCollaborateur"; +import { DisplayCollaborateur } from "@shared/displayInfo/displays"; /** * Composant qui sert à l'affichage de la liste des collaborateurs en fonction de l'agence de son utilitateur. diff --git a/src/app/collaborateurs/collaborateurs.routing.module.ts b/src/app/collaborateurs/collaborateurs.routing.module.ts index 8d37fca..1237b4f 100644 --- a/src/app/collaborateurs/collaborateurs.routing.module.ts +++ b/src/app/collaborateurs/collaborateurs.routing.module.ts @@ -15,10 +15,10 @@ import { KeycloakGuard } from '@shared/guards/keycloakguard'; const routes: Routes = [ { path:'', component: CollaborateursComponent, pathMatch: 'full', canActivate: [KeycloakGuard] }, - { path:paths_collaborateurs.get, component: DetailsCollaborateurComponent, canActivate: [KeycloakGuard] }, { path:paths_collaborateurs.formations, component: FormationsCollaboateurComponent, canActivate: [KeycloakGuard] }, { path:paths_collaborateurs.evaluation, component: EvaluationComponent, canActivate: [KeycloakGuard] }, - { path:paths_collaborateurs.edit, component: EditEvaluationComponent, canActivate: [KeycloakGuard] } + { path:paths_collaborateurs.edit, component: EditEvaluationComponent, canActivate: [KeycloakGuard] }, + { path:paths_collaborateurs.get, component: DetailsCollaborateurComponent, canActivate: [KeycloakGuard] } ]; diff --git a/src/app/collaborateurs/details-collaborateur/details-collaborateur.component.ts b/src/app/collaborateurs/details-collaborateur/details-collaborateur.component.ts index 10c7091..12e9320 100644 --- a/src/app/collaborateurs/details-collaborateur/details-collaborateur.component.ts +++ b/src/app/collaborateurs/details-collaborateur/details-collaborateur.component.ts @@ -11,7 +11,7 @@ import { CollaborateursService, EpService } from "@shared/api-swagger/api/api"; import { CollaborateurModel } from "@shared/api-swagger/model/collaborateurModel"; import { EpModel } from "@shared/api-swagger/model/epModel"; -import { DisplayEP } from "@shared/displayInfo/displayEP"; +import { DisplayEP } from "@shared/displayInfo/displays"; /** */ diff --git a/src/app/demandes-formation/demandes-formation.routing.module.ts b/src/app/demandes-formation/demandes-formation.routing.module.ts index 6fba0a6..6bcc84a 100644 --- a/src/app/demandes-formation/demandes-formation.routing.module.ts +++ b/src/app/demandes-formation/demandes-formation.routing.module.ts @@ -12,8 +12,9 @@ import { paths_demandes_formation } from "@shared/utils/paths"; const routes: Routes = [ { path:'', component: DemandesFormationComponent, pathMatch: 'full', canActivate: [KeycloakGuard] }, - { path:paths_demandes_formation.get, component: DemandeFormationComponent, canActivate: [KeycloakGuard] }, - { path:paths_demandes_formation.new, component: NewDemandeFormationComponent, canActivate: [KeycloakGuard] } + { path:paths_demandes_formation.new, component: NewDemandeFormationComponent, canActivate: [KeycloakGuard] }, + { path:paths_demandes_formation.get, component: DemandeFormationComponent, canActivate: [KeycloakGuard] } + ]; @NgModule({ diff --git a/src/app/formations/formations.component.html b/src/app/formations/formations.component.html index f59a99b..8ac0558 100644 --- a/src/app/formations/formations.component.html +++ b/src/app/formations/formations.component.html @@ -1,2 +1,32 @@

Liste des formations

+ + + + Intitulé + {{ row.intitule }} + + + + Nb participants + {{ row.nbParticipants }} + + + + Date prévisionnelle + {{ row.datePrevu }} + + + + + + Statut + {{ getStatut(row.statut) }} + + + + + diff --git a/src/app/formations/formations.component.ts b/src/app/formations/formations.component.ts index 71df05e..1554a0f 100644 --- a/src/app/formations/formations.component.ts +++ b/src/app/formations/formations.component.ts @@ -1,4 +1,14 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild } from '@angular/core'; + +import { Observable, Subscription } from 'rxjs'; + +import {MatTableDataSource} from '@angular/material/table'; +import {MatPaginator} from '@angular/material/paginator'; +import {MatSort} from '@angular/material/sort'; + +import { FormationModel } from "@shared/api-swagger/model/models"; +import { DisplayFormation } from "@shared/displayInfo/displays"; +import { FormationsService } from "@shared/api-swagger/api/api"; /** */ @@ -7,9 +17,91 @@ import { Component, OnInit } from '@angular/core'; templateUrl: './formations.component.html' }) export class FormationsComponent implements OnInit { + formationsDisponibles : DisplayFormation[]; + formationsFiltres : DisplayFormation[]; + private formationsDisponiblesSubscription : Subscription; + + //displayedColumns: string[] = ["intitule", "participants", "date", "origine", "statut"] + displayedColumns: string[] = ["intitule", "participants", "date", "statut"] + + /** + * source pour l'affichage des formations dans le tableau qui est affichée. + */ + dataSource : MatTableDataSource; - constructor() {} + /** + * contenu de la recherche. + */ + search = ""; + + /** + * Pagination du tableau. + */ + @ViewChild(MatPaginator) paginator: MatPaginator; + + /** + * Tri par les éléments du tableau selon la colonne choisie. + */ + @ViewChild(MatSort) sort: MatSort; + + /** + * Spécifie si la liste des EP est en cours de chargement et d'écriture dans le tableau. + */ + chargement = true; + constructor(private service:FormationsService) { + } ngOnInit() { + this.formationsDisponiblesSubscription = this.service.getFormations(undefined, 1).subscribe( + formations => this.initFormations(formations) + ); + } + + initFormations(formations:FormationModel[]) { + this.formationsDisponibles = []; + console.log(formations); + let formationDisplay : DisplayFormation; + for(let formation of formations) { + formationDisplay = new DisplayFormation(); + formationDisplay.id = formation.id; + formationDisplay.intitule = formation.intitule; + formationDisplay.nbParticipants = formation.participantsFormation.length; + formationDisplay.datePrevu = formation.dateDebut; + formationDisplay.origine = formation.origine; + formationDisplay.statut = formation.statut; + this.formationsDisponibles.push(formationDisplay); + } + this.formationsFiltres = this.formationsDisponibles; + this.dataSource = new MatTableDataSource(this.formationsFiltres); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + } + + + getStatut(statut:number) { + + let value =""; + switch(statut) { + case 0: + value = "Plannifiée"; + break; + case 1: + value = "Replannifiée"; + break; + case 2: + value = "Réalisée"; + break; + case 3: + value = "Annulée"; + break; + } + return value; + } + + + ngOnDestroy() { + if(this.formationsDisponiblesSubscription != undefined) { + this.formationsDisponiblesSubscription.unsubscribe(); + } } } diff --git a/src/app/formations/formations.routing.module.ts b/src/app/formations/formations.routing.module.ts index 87c882d..d74f439 100644 --- a/src/app/formations/formations.routing.module.ts +++ b/src/app/formations/formations.routing.module.ts @@ -13,9 +13,9 @@ import { paths_formation } from "@shared/utils/paths"; const routes: Routes = [ { path:'', component: FormationsComponent, pathMatch: 'full', canActivate: [KeycloakGuard] }, - { path:paths_formation.get, component: FormationComponent, canActivate: [KeycloakGuard] }, { path:paths_formation.edit, component: EditFormationComponent, canActivate: [KeycloakGuard] }, { path:paths_formation.new, component: NewFormationComponent, canActivate: [KeycloakGuard] }, + { path:paths_formation.get, component: FormationComponent, canActivate: [KeycloakGuard] } ]; diff --git a/src/app/home/home-assistante/home-assistante.component.ts b/src/app/home/home-assistante/home-assistante.component.ts index c7c89ed..97ed266 100644 --- a/src/app/home/home-assistante/home-assistante.component.ts +++ b/src/app/home/home-assistante/home-assistante.component.ts @@ -9,7 +9,7 @@ import {MatSort} from '@angular/material/sort'; import { CollaborateurModel } from "@shared/api-swagger/model/collaborateurModel"; import { EpModel } from "@shared/api-swagger/model/epModel"; -import { DisplayEP } from "@shared/displayInfo/displayEP"; +import { DisplayEP } from "@shared/displayInfo/displays"; import { EpService } from "@shared/api-swagger/api/api"; diff --git a/src/app/home/home-rh/home-rh.component.html b/src/app/home/home-rh/home-rh.component.html index b9efd22..701bbdf 100644 --- a/src/app/home/home-rh/home-rh.component.html +++ b/src/app/home/home-rh/home-rh.component.html @@ -1 +1,31 @@

Page RH

+ + + + Intitulé + {{ row.intitule }} + + + + Nb participants + {{ row.nbParticipants }} + + + + Date prévisionnelle + {{ row.datePrevu }} + + + + + + Statut + {{ getStatut(row.statut) }} + + + + + diff --git a/src/app/home/home-rh/home-rh.component.ts b/src/app/home/home-rh/home-rh.component.ts index 5905b6b..e0a74a1 100644 --- a/src/app/home/home-rh/home-rh.component.ts +++ b/src/app/home/home-rh/home-rh.component.ts @@ -1,4 +1,15 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild } from '@angular/core'; + +import { Observable, Subscription } from 'rxjs'; + +import {MatTableDataSource} from '@angular/material/table'; +import {MatPaginator} from '@angular/material/paginator'; +import {MatSort} from '@angular/material/sort'; + +import { FormationModel } from "@shared/api-swagger/model/models"; +import { DisplayFormation } from "@shared/displayInfo/displays"; +import { FormationsService } from "@shared/api-swagger/api/api"; + /** * Le composant home qui sera affiché pour les RH. @@ -11,9 +22,93 @@ import { Component, OnInit } from '@angular/core'; templateUrl : 'home-rh.component.html' }) export class HomeRHComponent implements OnInit { - constructor() { + + + formationsDisponibles : DisplayFormation[]; + formationsFiltres : DisplayFormation[]; + private formationsDisponiblesSubscription : Subscription; + + //displayedColumns: string[] = ["intitule", "participants", "date", "origine", "statut"] + displayedColumns: string[] = ["intitule", "participants", "date", "statut"] + + /** + * source pour l'affichage des formations dans le tableau qui est affichée. + */ + dataSource : MatTableDataSource; + + /** + * contenu de la recherche. + */ + search = ""; + + /** + * Pagination du tableau. + */ + @ViewChild(MatPaginator) paginator: MatPaginator; + + /** + * Tri par les éléments du tableau selon la colonne choisie. + */ + @ViewChild(MatSort) sort: MatSort; + + /** + * Spécifie si la liste des EP est en cours de chargement et d'écriture dans le tableau. + */ + chargement = true; + constructor(private service:FormationsService) { } ngOnInit() { + this.formationsDisponiblesSubscription = this.service.getFormations(undefined, 1).subscribe( + formations => this.initFormations(formations) + ); + } + + initFormations(formations:FormationModel[]) { + this.formationsDisponibles = []; + console.log(formations); + let formationDisplay : DisplayFormation; + for(let formation of formations) { + formationDisplay = new DisplayFormation(); + formationDisplay.id = formation.id; + formationDisplay.intitule = formation.intitule; + formationDisplay.nbParticipants = formation.participantsFormation.length; + formationDisplay.datePrevu = formation.dateDebut; + formationDisplay.origine = formation.origine; + formationDisplay.statut = formation.statut; + this.formationsDisponibles.push(formationDisplay); + } + this.formationsFiltres = this.formationsDisponibles; + this.dataSource = new MatTableDataSource(this.formationsFiltres); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + } + + + getStatut(statut:number) { + + let value =""; + switch(statut) { + case 0: + value = "Plannifiée"; + break; + case 1: + value = "Replannifiée"; + break; + case 2: + value = "Réalisée"; + break; + case 3: + value = "Annulée"; + break; + } + return value; + } + + + ngOnDestroy() { + if(this.formationsDisponiblesSubscription != undefined) { + this.formationsDisponiblesSubscription.unsubscribe(); + } } } diff --git a/src/app/referents/details-referent/details-referent.component.ts b/src/app/referents/details-referent/details-referent.component.ts index feb94cb..26d7fab 100644 --- a/src/app/referents/details-referent/details-referent.component.ts +++ b/src/app/referents/details-referent/details-referent.component.ts @@ -11,7 +11,7 @@ import { ReferentsService } from "@shared/api-swagger/api/api"; import { CollaborateurModel } from "@shared/api-swagger/model/collaborateurModel"; import { EpModel } from "@shared/api-swagger/model/epModel"; -import { DisplayEP } from "@shared/displayInfo/displayEP"; +import { DisplayEP } from "@shared/displayInfo/displays"; /** */ diff --git a/src/app/referents/referents.component.ts b/src/app/referents/referents.component.ts index f864b2e..9a07bd3 100644 --- a/src/app/referents/referents.component.ts +++ b/src/app/referents/referents.component.ts @@ -9,7 +9,7 @@ import {MatSort} from '@angular/material/sort'; import { ReferentsService } from "@shared/api-swagger/api/api"; import { CollaborateurModel } from "@shared/api-swagger/model/collaborateurModel"; -import { DisplayCollaborateur } from "@shared/displayInfo/displayCollaborateur"; +import { DisplayCollaborateur } from "@shared/displayInfo/displays"; /** diff --git a/src/app/shared/api-swagger/api/formations.service.ts b/src/app/shared/api-swagger/api/formations.service.ts index 59ae1be..ea21cb3 100644 --- a/src/app/shared/api-swagger/api/formations.service.ts +++ b/src/app/shared/api-swagger/api/formations.service.ts @@ -214,10 +214,10 @@ export class FormationsService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public getListeFormations(idBu?: number, idAgence?: number, observe?: 'body', reportProgress?: boolean): Observable>; - public getListeFormations(idBu?: number, idAgence?: number, observe?: 'response', reportProgress?: boolean): Observable>>; - public getListeFormations(idBu?: number, idAgence?: number, observe?: 'events', reportProgress?: boolean): Observable>>; - public getListeFormations(idBu?: number, idAgence?: number, observe: any = 'body', reportProgress: boolean = false ): Observable { + public getFormations(idBu?: number, idAgence?: number, observe?: 'body', reportProgress?: boolean): Observable>; + public getFormations(idBu?: number, idAgence?: number, observe?: 'response', reportProgress?: boolean): Observable>>; + public getFormations(idBu?: number, idAgence?: number, observe?: 'events', reportProgress?: boolean): Observable>>; + public getFormations(idBu?: number, idAgence?: number, observe: any = 'body', reportProgress: boolean = false ): Observable { diff --git a/src/app/shared/api-swagger/model/formationModel.ts b/src/app/shared/api-swagger/model/formationModel.ts index 847b259..bc37ae3 100644 --- a/src/app/shared/api-swagger/model/formationModel.ts +++ b/src/app/shared/api-swagger/model/formationModel.ts @@ -3,7 +3,7 @@ * API qui sra utilisée afin de faire communiquer le client et le serveur ainsi que le serveur et la boîte noire. * * OpenAPI spec version: 1.1.0 - * + * * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -11,15 +11,16 @@ */ import { ParticipationFormationModel } from './participationFormationModel'; -export interface FormationModel { +export interface FormationModel { id: number; intitule: string; dateDebut: Date; dateFin: Date; - status: FormationModel.StatusEnum; + statut: FormationModel.StatusEnum; lieu: string; duree: number; jours?: number; + origine: string; organisme: string; nomFormateur: string; participantsFormation?: Array; @@ -27,11 +28,11 @@ export interface FormationModel { typeFormation?: string; } export namespace FormationModel { - export type StatusEnum = 'Planifiée' | 'Replanifiée' | 'Annulée' | 'Réalisée'; + export type StatusEnum = 0 | 1 | 2 | 3; export const StatusEnum = { - Planifie: 'Planifiée' as StatusEnum, - Replanifie: 'Replanifiée' as StatusEnum, - Annule: 'Annulée' as StatusEnum, - Ralise: 'Réalisée' as StatusEnum + Planifie: 0 as StatusEnum, + Replanifie: 1 as StatusEnum, + Realise: 2 as StatusEnum, + Annule: 3 as StatusEnum }; -} \ No newline at end of file +} diff --git a/src/app/shared/nav-menu/nav-menu-rh/nav-menu-rh.component.html b/src/app/shared/nav-menu/nav-menu-rh/nav-menu-rh.component.html index 212e9eb..db09976 100644 --- a/src/app/shared/nav-menu/nav-menu-rh/nav-menu-rh.component.html +++ b/src/app/shared/nav-menu/nav-menu-rh/nav-menu-rh.component.html @@ -3,7 +3,7 @@ more_vert - + - + + + + + + + diff --git a/src/app/shared/nav-menu/nav-menu.component.html b/src/app/shared/nav-menu/nav-menu.component.html index 9f8d5b0..badc595 100644 --- a/src/app/shared/nav-menu/nav-menu.component.html +++ b/src/app/shared/nav-menu/nav-menu.component.html @@ -16,6 +16,8 @@ more_vert + +