diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 01b8275..a91ed4f 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -5,6 +5,11 @@ import { HttpClientModule } from '@angular/common/http';
import { KeycloakAngularModule, KeycloakService } from 'keycloak-angular';
import { RouterModule } from '@angular/router';
+import { registerLocaleData } from '@angular/common';
+import localeFr from '@angular/common/locales/fr';
+registerLocaleData(localeFr, 'fr');
+
+
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
diff --git a/src/app/formations/details-formation/formation.component.html b/src/app/formations/details-formation/formation.component.html
index 4efbad6..bc66bd3 100644
--- a/src/app/formations/details-formation/formation.component.html
+++ b/src/app/formations/details-formation/formation.component.html
@@ -4,7 +4,7 @@
{{formation.intitule}}
Informations générales
-
+
Etat : {{formation.statut}}
{{dateTexte}} {{formation.dateDebut | date:'dd/MM/yyyy à hh:mm'}}
Origine : {{formation.origine}}
diff --git a/src/app/formations/details-formation/formation.component.ts b/src/app/formations/details-formation/formation.component.ts
index 526132c..b2b4b37 100644
--- a/src/app/formations/details-formation/formation.component.ts
+++ b/src/app/formations/details-formation/formation.component.ts
@@ -28,11 +28,12 @@ export class FormationComponent implements OnInit {
dataSource : MatTableDataSource;
displayedColumns: string[]= ["agence", "collaborateur", "dateinscription", "ep"];
+ id:any
constructor(private service:FormationsService,private route:ActivatedRoute) {}
ngOnInit() {
- let id = this.route.snapshot.paramMap.get('id');
- this.formationSubscription = this.service.getFormationById(id).subscribe(
+ this.id = this.route.snapshot.paramMap.get('id');
+ this.formationSubscription = this.service.getFormationById(this.id).subscribe(
formation => this.initFormation(formation)
);
}
@@ -72,26 +73,6 @@ export class FormationComponent implements OnInit {
this.dataSource = new MatTableDataSource(this.participationsDisplay);
}
- /*
- 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.formationSubscription != undefined) {
this.formationSubscription.unsubscribe();
diff --git a/src/app/formations/edit-formation/edit-formation.component.css b/src/app/formations/edit-formation/edit-formation.component.css
new file mode 100644
index 0000000..d42a102
--- /dev/null
+++ b/src/app/formations/edit-formation/edit-formation.component.css
@@ -0,0 +1,16 @@
+div {
+ margin-left: 5%;
+ margin-bottom: 1%;
+}
+
+.input{
+ width: 30%;
+}
+
+.input2 {
+ width: 14%;
+}
+
+.moveright {
+ margin-left: 2%;
+}
diff --git a/src/app/formations/edit-formation/edit-formation.component.html b/src/app/formations/edit-formation/edit-formation.component.html
index 7ca389a..a2a5331 100644
--- a/src/app/formations/edit-formation/edit-formation.component.html
+++ b/src/app/formations/edit-formation/edit-formation.component.html
@@ -1,2 +1,83 @@
- Edit formation
+ Modifier une formation
+
+
+
+
+
diff --git a/src/app/formations/edit-formation/edit-formation.component.ts b/src/app/formations/edit-formation/edit-formation.component.ts
index 1418e17..369744c 100644
--- a/src/app/formations/edit-formation/edit-formation.component.ts
+++ b/src/app/formations/edit-formation/edit-formation.component.ts
@@ -1,15 +1,88 @@
import { Component, OnInit } from '@angular/core';
+import { Observable, Subscription } from 'rxjs';
+import { Router, ActivatedRoute } from '@angular/router';
+import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms';
+
+
+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 { FormationsService } from '@shared/api-swagger/api/api';
+
/**
*/
@Component({
selector: 'app-edit-formation',
- templateUrl: './edit-formation.component.html'
+ templateUrl: './edit-formation.component.html',
+ styleUrls: ["edit-formation.component.css"]
})
export class EditFormationComponent implements OnInit {
+ formation:FormationModel;
+ formationSubscription: Subscription;
+ formationForm: FormGroup;
+ id :any;
+ statuts = FormationModel.StatutEnum;
+ modes = FormationModel.ModeEnum;
+ types = FormationModel.TypeEnum;
+ keysStatuts: any[];
+ keysModes: any[];
+ keysTypes: any[];
- constructor() {}
+ constructor(private service: FormationsService, private fb: FormBuilder,
+ private activatedRoute:ActivatedRoute, private router: Router) {}
ngOnInit() {
+ this.id = this.activatedRoute.snapshot.paramMap.get('id');
+ this.formationSubscription = this.service.getFormationById(this.id).subscribe(
+ formation => this.initFormation(formation)
+ );
+ this.keysStatuts = Object.keys(this.statuts).filter(String);
+ this.keysModes = Object.keys(this.modes).filter(String);
+ this.keysTypes = Object.keys(this.types).filter(String);
+ }
+
+ initFormation(formation:FormationModel) {
+ this.formation = formation;
+ this.formationForm= this.fb.group(
+ {
+
+ intitule: [this.formation.intitule],
+ origine: [this.formation.origine],
+ statut : [this.formation.statut],
+ dateDebut: [new Date(this.formation.dateDebut)],
+ dateFin: [new Date(this.formation.dateFin)],
+ heure: [this.formation.heure],
+ jour: [this.formation.jour],
+ organisme: [this.formation.organisme],
+ mode: [this.formation.mode],
+ type: [this.formation.type],
+ estCertifie: [this.formation.estCertifie]
+ });
+ }
+
+ updateFormation() {
+ this.formation = this.formationForm.value;
+ this.formation.id = this.id;
+ this.formationSubscription = this.service.updateFormation(this.formation).subscribe(
+ response => {
+ this.router.navigate(['/formations',this.id]);
+ }
+ );
+ }
+
+ supprimerFormation() {
+ this.formationSubscription = this.service.deleteFormation(this.formation.id).subscribe(
+ response => this.router.navigate([""])
+ );
+ }
+
+ ngOnDestroy() {
+ if(this.formationSubscription != undefined) {
+ this.formationSubscription.unsubscribe();
+ }
}
}
diff --git a/src/app/formations/new-formation/new-formation.component.html b/src/app/formations/new-formation/new-formation.component.html
index fc0137d..55d8f07 100644
--- a/src/app/formations/new-formation/new-formation.component.html
+++ b/src/app/formations/new-formation/new-formation.component.html
@@ -48,17 +48,15 @@
Type formation
-
- Interne
- Externe
+
+ {{types[key]}}
Mode formation
- Présentiel
- Conférence
+ {{modes[key]}}
@@ -67,6 +65,6 @@
Certifiée
-
+
diff --git a/src/app/formations/new-formation/new-formation.component.ts b/src/app/formations/new-formation/new-formation.component.ts
index 875e019..a4e0eab 100644
--- a/src/app/formations/new-formation/new-formation.component.ts
+++ b/src/app/formations/new-formation/new-formation.component.ts
@@ -32,10 +32,16 @@ export class NewFormationComponent implements OnInit {
estCertifie: [""]
}
);
+ modes = FormationModel.ModeEnum;
+ types = FormationModel.TypeEnum;
+ keysModes: any[];
+ keysTypes: any[];
constructor(private fb: FormBuilder, private service:FormationsService, private router: Router) { }
ngOnInit() {
+ this.keysModes = Object.keys(this.modes).filter(String);
+ this.keysTypes = Object.keys(this.types).filter(String);
}
ajouterFormation() {
@@ -46,4 +52,10 @@ export class NewFormationComponent implements OnInit {
}
);
}
+
+ ngOnDestroy() {
+ if(this.formationSubscription != undefined) {
+ this.formationSubscription.unsubscribe();
+ }
+ }
}
diff --git a/src/app/shared/api-swagger/api/formations.service.ts b/src/app/shared/api-swagger/api/formations.service.ts
index 86bae6c..6dff875 100644
--- a/src/app/shared/api-swagger/api/formations.service.ts
+++ b/src/app/shared/api-swagger/api/formations.service.ts
@@ -63,46 +63,46 @@ 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 deleteFormation(idFormation: string, observe?: 'body', reportProgress?: boolean): Observable;
- public deleteFormation(idFormation: string, observe?: 'response', reportProgress?: boolean): Observable>;
- public deleteFormation(idFormation: string, observe?: 'events', reportProgress?: boolean): Observable>;
- public deleteFormation(idFormation: string, observe: any = 'body', reportProgress: boolean = false ): Observable {
-
- if (idFormation === null || idFormation === undefined) {
- throw new Error('Required parameter idFormation was null or undefined when calling deleteFormation.');
- }
-
- let headers = this.defaultHeaders;
-
- // authentication (bearerAuth) required
- if (this.configuration.accessToken) {
- const accessToken = typeof this.configuration.accessToken === 'function'
- ? this.configuration.accessToken()
- : this.configuration.accessToken;
- headers = headers.set('Authorization', 'Bearer ' + accessToken);
- }
- // to determine the Accept header
- let httpHeaderAccepts: string[] = [
- 'application/json'
- ];
- const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
- if (httpHeaderAcceptSelected != undefined) {
- headers = headers.set('Accept', httpHeaderAcceptSelected);
- }
-
- // to determine the Content-Type header
- const consumes: string[] = [
- ];
-
- return this.httpClient.request('delete',`${this.basePath}/formations/${encodeURIComponent(String(idFormation))}`,
- {
- withCredentials: this.configuration.withCredentials,
- headers: headers,
- observe: observe,
- reportProgress: reportProgress
- }
- );
- }
+ public deleteFormation(idFormation: number, observe?: 'body', reportProgress?: boolean): Observable;
+ public deleteFormation(idFormation: number, observe?: 'response', reportProgress?: boolean): Observable>;
+ public deleteFormation(idFormation: number, observe?: 'events', reportProgress?: boolean): Observable>;
+ public deleteFormation(idFormation: number, observe: any = 'body', reportProgress: boolean = false ): Observable {
+
+ if (idFormation === null || idFormation === undefined) {
+ throw new Error('Required parameter idFormation was null or undefined when calling deleteFormation.');
+ }
+
+ let headers = this.defaultHeaders;
+
+ // authentication (bearerAuth) required
+ if (this.configuration.accessToken) {
+ const accessToken = typeof this.configuration.accessToken === 'function'
+ ? this.configuration.accessToken()
+ : this.configuration.accessToken;
+ headers = headers.set('Authorization', 'Bearer ' + accessToken);
+ }
+ // to determine the Accept header
+ let httpHeaderAccepts: string[] = [
+ 'application/json'
+ ];
+ const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
+ if (httpHeaderAcceptSelected != undefined) {
+ headers = headers.set('Accept', httpHeaderAcceptSelected);
+ }
+
+ // to determine the Content-Type header
+ const consumes: string[] = [
+ ];
+
+ return this.httpClient.request('delete',`${this.basePath}/formations/${encodeURIComponent(String(idFormation))}`,
+ {
+ withCredentials: this.configuration.withCredentials,
+ headers: headers,
+ observe: observe,
+ reportProgress: reportProgress
+ }
+ );
+ }
/**
*
@@ -165,46 +165,46 @@ 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 getFormationById(idFormation: string, observe?: 'body', reportProgress?: boolean): Observable;
- public getFormationById(idFormation: string, observe?: 'response', reportProgress?: boolean): Observable>;
- public getFormationById(idFormation: string, observe?: 'events', reportProgress?: boolean): Observable>;
- public getFormationById(idFormation: string, observe: any = 'body', reportProgress: boolean = false ): Observable {
-
- if (idFormation === null || idFormation === undefined) {
- throw new Error('Required parameter idFormation was null or undefined when calling getFormationById.');
- }
-
- let headers = this.defaultHeaders;
-
- // authentication (bearerAuth) required
- if (this.configuration.accessToken) {
- const accessToken = typeof this.configuration.accessToken === 'function'
- ? this.configuration.accessToken()
- : this.configuration.accessToken;
- headers = headers.set('Authorization', 'Bearer ' + accessToken);
- }
- // to determine the Accept header
- let httpHeaderAccepts: string[] = [
- 'application/json'
- ];
- const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
- if (httpHeaderAcceptSelected != undefined) {
- headers = headers.set('Accept', httpHeaderAcceptSelected);
- }
-
- // to determine the Content-Type header
- const consumes: string[] = [
- ];
-
- return this.httpClient.request('get',`${this.basePath}/formations/${encodeURIComponent(String(idFormation))}`,
- {
- withCredentials: this.configuration.withCredentials,
- headers: headers,
- observe: observe,
- reportProgress: reportProgress
- }
- );
- }
+ public getFormationById(idFormation: number, observe?: 'body', reportProgress?: boolean): Observable;
+ public getFormationById(idFormation: number, observe?: 'response', reportProgress?: boolean): Observable>;
+ public getFormationById(idFormation: number, observe?: 'events', reportProgress?: boolean): Observable>;
+ public getFormationById(idFormation: number, observe: any = 'body', reportProgress: boolean = false ): Observable {
+
+ if (idFormation === null || idFormation === undefined) {
+ throw new Error('Required parameter idFormation was null or undefined when calling getFormationById.');
+ }
+
+ let headers = this.defaultHeaders;
+
+ // authentication (bearerAuth) required
+ if (this.configuration.accessToken) {
+ const accessToken = typeof this.configuration.accessToken === 'function'
+ ? this.configuration.accessToken()
+ : this.configuration.accessToken;
+ headers = headers.set('Authorization', 'Bearer ' + accessToken);
+ }
+ // to determine the Accept header
+ let httpHeaderAccepts: string[] = [
+ 'application/json'
+ ];
+ const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
+ if (httpHeaderAcceptSelected != undefined) {
+ headers = headers.set('Accept', httpHeaderAcceptSelected);
+ }
+
+ // to determine the Content-Type header
+ const consumes: string[] = [
+ ];
+
+ return this.httpClient.request('get',`${this.basePath}/formations/${encodeURIComponent(String(idFormation))}`,
+ {
+ withCredentials: this.configuration.withCredentials,
+ headers: headers,
+ observe: observe,
+ reportProgress: reportProgress
+ }
+ );
+ }
/**
*
diff --git a/src/app/shared/api-swagger/model/formationModel.ts b/src/app/shared/api-swagger/model/formationModel.ts
index 627cbed..affb04c 100644
--- a/src/app/shared/api-swagger/model/formationModel.ts
+++ b/src/app/shared/api-swagger/model/formationModel.ts
@@ -34,6 +34,11 @@ export namespace FormationModel {
Realise: 'Réalisée' as StatutEnum,
Annule: 'Annulée' as StatutEnum
};
+ export type ModeEnum = 'Présentiel' | 'Visioconférence';
+ export const ModeEnum = {
+ Presentiel: 'Présentiel' as ModeEnum,
+ Visioconference: 'Visioconférence' as ModeEnum
+ };
export type TypeEnum = 'Externe' | 'Interne';
export const TypeEnum = {
Externe: 'Externe' as TypeEnum,