diff --git a/Dockerfile b/Dockerfile
index d1fa907..fed4ab6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,4 @@
-# Stage 1
-
+# Stage 1 : Building the application
FROM node:16-alpine3.14 as build-step
RUN mkdir -p /app
@@ -12,8 +11,7 @@ RUN npm install
RUN npm run build --prod
-# Stage 2
-
+# Stage 2 : Deploying the application on Nginx
FROM nginx:1.17.1-alpine
RUN rm -rf /usr/share/nginx/html/* && rm -rf /etc/nginx/nginx.conf
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 8327538..8edcc44 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -13,6 +13,7 @@ import {CollaborateurAddComponent} from "./components/collaborateur/collaborateu
import {ReferencementComponent} from "./components/referencement/referencement.component";
import {ReferencementAddComponent} from "./components/referencement/referencement-add/referencement-add.component";
import {ReferencementEditComponent} from "./components/referencement/referencement-edit/referencement-edit.component";
+import {PeriodeEssaiAddComponent} from "./components/periode-essai/periode-essai-add/periode-essai-add.component";
const routes : Routes = [
{path:'', redirectTo:'/home', pathMatch:'full'},
@@ -28,6 +29,7 @@ const routes : Routes = [
{ path:'businessunits',component:BusinessunitComponent, data:{title:'BusinessUnits'} },
{ path: 'businessunits/:id', component: BusinessunitEditComponent, data:{title:'BusinessUnits'} },
{ path:'periodeessais',component:PeriodeEssaiComponent, data:{title:'Periodes d\'Essai'} },
+ { path: 'periodeessais/add', component: PeriodeEssaiAddComponent, data:{title:'Periodes d\'Essai'} },
{ path: 'periodeessais/:id', component: PeriodeEssaiEditComponent, data:{title:'Periodes d\'Essai'} },
];
diff --git a/src/app/app.component.html b/src/app/app.component.html
index 043d823..103354d 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -24,9 +24,15 @@
-
+
+
+
+
+
+
+
+
+
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 28d735c..8cd2d58 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -21,6 +21,7 @@ import { ToastrModule } from 'ngx-toastr';
import { ReferencementComponent } from './components/referencement/referencement.component';
import { ReferencementAddComponent } from './components/referencement/referencement-add/referencement-add.component';
import { ReferencementEditComponent } from './components/referencement/referencement-edit/referencement-edit.component';
+import { PeriodeEssaiAddComponent } from './components/periode-essai/periode-essai-add/periode-essai-add.component';
@NgModule({
declarations: [
@@ -38,6 +39,7 @@ import { ReferencementEditComponent } from './components/referencement/reference
ReferencementComponent,
ReferencementAddComponent,
ReferencementEditComponent,
+ PeriodeEssaiAddComponent,
],
imports: [
diff --git a/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.html b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.html
new file mode 100644
index 0000000..29cd394
--- /dev/null
+++ b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.html
@@ -0,0 +1,73 @@
+
Ajouter une Période d'essai :
+
+
diff --git a/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.scss b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.ts b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.ts
new file mode 100644
index 0000000..0d7fd04
--- /dev/null
+++ b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.ts
@@ -0,0 +1,109 @@
+import {Component, OnInit} from '@angular/core';
+import {Collaborateur} from "../../../interfaces/collaborateur";
+import {PeriodeEssai} from "../../../interfaces/periode-essai";
+import {FormBuilder, FormGroup, Validators} from "@angular/forms";
+import {HttpClient} from "@angular/common/http";
+import {CollaborateurService} from "../../../services/collaborateur.service";
+import {PeriodeEssaiService} from "../../../services/periode-essai.service";
+import {ToastrService} from "ngx-toastr";
+
+@Component({
+ selector: 'app-periode-essai-add',
+ templateUrl: './periode-essai-add.component.html',
+ styleUrls: ['./periode-essai-add.component.scss']
+})
+export class PeriodeEssaiAddComponent implements OnInit {
+
+ collaborateurs: Collaborateur[] = [];
+ collaborateur = {} as Collaborateur;
+ periodeEssai = {} as PeriodeEssai;
+
+ registerForm!: FormGroup;
+ submitted = false;
+
+ constructor(
+ private http: HttpClient,
+ private collaborateurService: CollaborateurService,
+ private periodeEssaiService: PeriodeEssaiService,
+ private formBuilder: FormBuilder,
+ private toastr: ToastrService
+ ) {
+ }
+
+ get f() {
+ return this.registerForm.controls;
+ }
+
+ ngOnInit(): void {
+ this.getCollaborateurs();
+ this.registerForm = this.formBuilder.group({
+ comment: [],
+ collaborateurId: ['', Validators.required],
+ issue: [],
+ plannedEndingDate: ['', Validators.required],
+ realEndingDate: [],
+ startingDate: ['', Validators.required]
+ });
+ }
+
+ getCollaborateurs(): void {
+ this.collaborateurService.getCollaborateurs()
+ .subscribe(collaborateurs => this.collaborateurs = collaborateurs);
+ }
+
+ onSubmit() {
+ this.submitted = true;
+ if (this.registerForm.invalid) {
+ return;
+ }
+
+ this.periodeEssai.comment = this.registerForm.value.comment;
+ this.periodeEssai.collaborateurId = this.registerForm.value.collaborateurId;
+ if (this.registerForm.value.issue == undefined) {
+ this.periodeEssai.issue = "INDETERMINEE";
+ } else {
+ this.periodeEssai.issue = this.registerForm.value.issue;
+ }
+ if (this.registerForm.value.realEndingDate == undefined) {
+ this.periodeEssai.realEndingDate = new Date();
+ } else {
+ this.periodeEssai.realEndingDate = this.registerForm.value.realEndingDate;
+ }
+ this.periodeEssai.plannedEndingDate = this.registerForm.value.plannedEndingDate;
+ this.periodeEssai.startingDate = this.registerForm.value.startingDate;
+
+ this.periodeEssaiService.addPeriodeEssai(this.periodeEssai)
+ .subscribe(() => {
+ this.showSuccess();
+ },
+ () => {
+ this.showError()
+ });
+ }
+
+ onReset() {
+ this.submitted = false;
+ this.registerForm.reset();
+ }
+
+ onStartingDateChange($event: any): void {
+ this.periodeEssai.startingDate = new Date($event.target.value);
+ }
+
+ onPlannedEndingDateChange($event: any): void {
+ this.periodeEssai.plannedEndingDate = new Date($event.target.value);
+ }
+
+ onRealEndingDateChange($event: any): void {
+ this.periodeEssai.realEndingDate = new Date($event.target.value);
+ }
+
+ showSuccess() {
+ this.toastr.success('Création réussie', 'Période d\'essai');
+ }
+
+ showError() {
+ this.toastr.error('Création échouée', 'Période d\'essai');
+ }
+
+}
diff --git a/src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.html b/src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.html
index 964cc0a..65199e1 100644
--- a/src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.html
+++ b/src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.html
@@ -45,27 +45,25 @@
diff --git a/src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.ts b/src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.ts
index c540b68..4421e23 100644
--- a/src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.ts
+++ b/src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit } from '@angular/core';
+import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {PeriodeEssai} from "../../../interfaces/periode-essai";
import {Collaborateur} from "../../../interfaces/collaborateur";
@@ -17,13 +17,13 @@ import {ToastrService} from "ngx-toastr";
})
export class PeriodeEssaiEditComponent implements OnInit {
- periodeEssaiObservable! : Observable
;
+ periodeEssaiObservable!: Observable;
id: number;
- collaborateurs : Collaborateur[] = [];
+ collaborateurs: Collaborateur[] = [];
collaborateur = {} as Collaborateur;
- periodeEssais : PeriodeEssai[] = [];
+ periodeEssais: PeriodeEssai[] = [];
periodeEssai = {} as PeriodeEssai;
registerForm!: FormGroup;
@@ -40,22 +40,26 @@ export class PeriodeEssaiEditComponent implements OnInit {
this.id = Number(this.route.snapshot.paramMap.get('id'))
}
+ get f() {
+ return this.registerForm.controls;
+ }
+
async ngOnInit() {
this.getCollaborateurs();
this.getPeriodeEssais();
this.registerForm = this.formBuilder.group({
- comment: ['', Validators.required],
- collaborateurId: ['',Validators.required],
- issue: ['',Validators.required],
- plannedEndingDate: ['',Validators.required],
- realEndingDate: ['',Validators.required],
- startingDate: ['',Validators.required]
+ comment: [],
+ collaborateurId: ['', Validators.required],
+ issue: [],
+ plannedEndingDate: ['', Validators.required],
+ realEndingDate: [],
+ startingDate: ['', Validators.required]
});
this.periodeEssaiObservable = this.periodeEssaiService.getPeriodeEssai(this.id).pipe(tap(pe => this.registerForm.patchValue(pe)))
this.periodeEssai = await this.periodeEssaiObservable.pipe(take(1)).toPromise()
}
- getCollaborateurs():void {
+ getCollaborateurs(): void {
this.collaborateurService.getCollaborateurs()
.subscribe(collaborateurs => this.collaborateurs = collaborateurs);
}
@@ -69,10 +73,10 @@ export class PeriodeEssaiEditComponent implements OnInit {
this.location.back();
}
- delete():void {
- if (this.periodeEssai){
+ delete(): void {
+ if (this.periodeEssai) {
this.periodeEssaiService.deletePeriodeEssai(this.periodeEssai)
- .subscribe(()=>this.goBack());
+ .subscribe(() => this.goBack());
}
}
@@ -82,17 +86,23 @@ export class PeriodeEssaiEditComponent implements OnInit {
if (this.registerForm.invalid) {
return;
}
- this.periodeEssai.comment = this.registerForm.value.comment
- this.periodeEssai.collaborateurId = this.registerForm.value.collaborateurId
- this.periodeEssai.issue = this.registerForm.value.issue
- this.periodeEssai.realEndingDate = this.registerForm.value.realEndingDate
- this.periodeEssai.startingDate = this.registerForm.value.startingDate
-
- if (this.registerForm.value.plannedEndingDate == undefined) {
- this.periodeEssai.plannedEndingDate = new Date();
+
+ this.periodeEssai.comment = this.registerForm.value.comment;
+ this.periodeEssai.collaborateurId = this.registerForm.value.collaborateurId;
+ if (this.registerForm.value.issue == undefined) {
+ this.periodeEssai.issue = "INDETERMINEE";
+ } else {
+ this.periodeEssai.issue = this.registerForm.value.issue;
}
+ if (this.registerForm.value.realEndingDate == undefined || this.registerForm.value.realEndingDate == '') {
+ this.periodeEssai.realEndingDate = null;
+ } else {
+ this.periodeEssai.realEndingDate = this.registerForm.value.realEndingDate;
+ }
+ this.periodeEssai.plannedEndingDate = this.registerForm.value.plannedEndingDate;
+ this.periodeEssai.startingDate = this.registerForm.value.startingDate;
- if (this.periodeEssai){
+ if (this.periodeEssai) {
this.periodeEssaiService.updatePeriodeEssai(this.periodeEssai)
.subscribe(() => {
this.showSuccess();
@@ -103,22 +113,20 @@ export class PeriodeEssaiEditComponent implements OnInit {
}
}
- get f() { return this.registerForm.controls; }
-
onReset() {
this.submitted = false;
this.registerForm.reset();
}
- onStartingDateChange($event: any):void {
+ onStartingDateChange($event: any): void {
this.periodeEssai.startingDate = new Date($event.target.value);
}
- onPlannedEndingDateChange($event: any):void {
+ onPlannedEndingDateChange($event: any): void {
this.periodeEssai.plannedEndingDate = new Date($event.target.value);
}
- onRealEndingDateChange($event: any):void {
+ onRealEndingDateChange($event: any): void {
this.periodeEssai.realEndingDate = new Date($event.target.value);
}
diff --git a/src/app/components/periode-essai/periode-essai.component.html b/src/app/components/periode-essai/periode-essai.component.html
index ab4f869..42f1e41 100644
--- a/src/app/components/periode-essai/periode-essai.component.html
+++ b/src/app/components/periode-essai/periode-essai.component.html
@@ -1,92 +1,30 @@
-
Ajouter une Période d'Essai :
+
Périodes d'essai
-
-
-
Périodes d'essai
+
+
Pour ajouter une nouvelle période d'essai, cliquez ici :
+
+
ID |
- Collaborateur ID |
+ Collaborateur |
Issue |
{{periodeEssai.id}} |
- {{periodeEssai.collaborateurId}} |
+ {{getCollaborateurById(periodeEssai.collaborateurId).name}} {{getCollaborateurById(periodeEssai.collaborateurId).firstName}} |
{{periodeEssai.issue}} |
- Modifier |
+ Modifier |
-
-
-
diff --git a/src/app/components/periode-essai/periode-essai.component.ts b/src/app/components/periode-essai/periode-essai.component.ts
index 877fd5b..8d34044 100644
--- a/src/app/components/periode-essai/periode-essai.component.ts
+++ b/src/app/components/periode-essai/periode-essai.component.ts
@@ -1,11 +1,9 @@
-import { Component, OnInit } from '@angular/core';
+import {Component, OnInit} from '@angular/core';
import {HttpClient} from "@angular/common/http";
-import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {PeriodeEssai} from "../../interfaces/periode-essai";
import {Collaborateur} from "../../interfaces/collaborateur";
import {CollaborateurService} from "../../services/collaborateur.service";
import {PeriodeEssaiService} from "../../services/periode-essai.service";
-import {ToastrService} from "ngx-toastr";
@Component({
selector: 'app-periode-essai',
@@ -14,93 +12,41 @@ import {ToastrService} from "ngx-toastr";
})
export class PeriodeEssaiComponent implements OnInit {
- collaborateurs : Collaborateur[] = [];
- collaborateur = {} as Collaborateur;
-
- periodeEssais : PeriodeEssai[] = [];
- periodeEssai = {} as PeriodeEssai;
-
- registerForm!: FormGroup;
- submitted = false;
+ collaborateurs: Collaborateur[] = [];
+ periodeEssais: PeriodeEssai[] = [];
constructor(
- private http : HttpClient,
+ private http: HttpClient,
private collaborateurService: CollaborateurService,
private periodeEssaiService: PeriodeEssaiService,
- private formBuilder: FormBuilder,
- private toastr: ToastrService
- ) { }
+ ) {
+ }
ngOnInit(): void {
this.getCollaborateurs();
this.getPeriodeEssais();
- this.registerForm = this.formBuilder.group({
- comment: ['', Validators.required],
- collaborateurId: ['',Validators.required],
- issue: ['',Validators.required],
- plannedEndingDate: ['',Validators.required],
- realEndingDate: ['',Validators.required],
- startingDate: ['',Validators.required]
- });
}
- getCollaborateurs():void {
+ getCollaborateurs(): void {
this.collaborateurService.getCollaborateurs()
.subscribe(collaborateurs => this.collaborateurs = collaborateurs);
}
- getPeriodeEssais() {
- this.periodeEssaiService.getPeriodeEssais()
- .subscribe(periodeEssais => this.periodeEssais = periodeEssais);
- }
-
- add(periodeEssai: PeriodeEssai): void {
- this.periodeEssaiService.addPeriodeEssai(periodeEssai)
- .subscribe(periodeEssai => {
- this.periodeEssais.push(periodeEssai);
- });
- }
-
- onSubmit() {
- this.submitted = true;
- if (this.registerForm.invalid) {
- return;
- }
- this.periodeEssai.comment = this.registerForm.value.comment
- this.periodeEssai.collaborateurId = this.registerForm.value.collaborateurId
- this.periodeEssai.issue = this.registerForm.value.issue
- this.periodeEssai.plannedEndingDate = this.registerForm.value.plannedEndingDate
- this.periodeEssai.realEndingDate = this.registerForm.value.realEndingDate
- this.periodeEssai.startingDate = this.registerForm.value.startingDate
- this.add(this.periodeEssai)
- }
-
- get f() { return this.registerForm.controls; }
-
- onReset() {
- this.submitted = false;
- this.registerForm.reset();
- }
-
- onStartingDateChange($event: any):void {
- this.periodeEssai.startingDate = new Date($event.target.value);
- }
-
- onPlannedEndingDateChange($event: any):void {
- this.periodeEssai.plannedEndingDate = new Date($event.target.value);
- }
+ getCollaborateurById(id : number) : Collaborateur{
+ let collab = {} as Collaborateur;
+ this.collaborateurs.forEach(c => {
+ if (c.id==id){
+ collab= c;
+ return;
+ }
+ });
- onRealEndingDateChange($event: any):void {
- this.periodeEssai.realEndingDate = new Date($event.target.value);
+ return collab;
}
-
-
- showSuccess() {
- this.toastr.success('Création réussie', 'Collaborateur');
+ getPeriodeEssais() {
+ this.periodeEssaiService.getPeriodeEssais()
+ .subscribe(periodeEssais => this.periodeEssais = periodeEssais);
}
- showError() {
- this.toastr.error('Création échouée', 'Collaborateur');
- }
}
diff --git a/src/app/components/referencement/referencement-add/referencement-add.component.html b/src/app/components/referencement/referencement-add/referencement-add.component.html
index 6708dcf..e1cbb0f 100644
--- a/src/app/components/referencement/referencement-add/referencement-add.component.html
+++ b/src/app/components/referencement/referencement-add/referencement-add.component.html
@@ -1,4 +1,4 @@
-Ajouter un collaborateur :
+Ajouter un référencement :