rework complet des périodes d'essai

pull/19/head
Clement FERRERE 2 years ago
parent 066d6b879c
commit f3d7ea5b74
  1. 6
      Dockerfile
  2. 73
      src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.html
  3. 73
      src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.ts
  4. 24
      src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.html
  5. 64
      src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.ts
  6. 9
      src/app/components/periode-essai/periode-essai.component.html
  7. 92
      src/app/components/periode-essai/periode-essai.component.ts
  8. 20
      src/app/components/referencement/referencement-edit/referencement-edit.component.ts
  9. 2
      src/app/interfaces/periode-essai.ts
  10. 2
      src/app/interfaces/referencement.ts

@ -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

@ -7,7 +7,8 @@
<select class="form-select" formControlName="collaborateurId" id="collaborateur-select"
[ngClass]="{ 'is-invalid': submitted && f.collaborateurId.errors }">
<option value="" disabled selected>Choisissez le collaborateur concerné par cette période d'essai</option>
<option *ngFor="let collaborateur of collaborateurs" [ngValue]="collaborateur.id">{{collaborateur.name}}</option>
<option *ngFor="let collaborateur of collaborateurs"
[ngValue]="collaborateur.id">{{collaborateur.name}} {{collaborateur.firstName}}</option>
</select>
<div *ngIf="submitted && f.collaborateurId.errors" class="invalid-feedback">
<div *ngIf="f.collaborateurId.errors.required">Vous devez choisir le collaborateur concerné par cette période
@ -16,51 +17,55 @@
</div>
</div>
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3">
<label class="form-label">Date de début</label>
<input type="date" class="form-control" formControlName="startingDate" (change)="onStartingDateChange($event)"
[ngClass]="{ 'is-invalid': submitted && f.startingDate.errors }">
<div *ngIf="submitted && f.startingDate.errors" class="invalid-feedback">
<div *ngIf="f.startingDate.errors.required">La date de début d'une période d'essai est obligatoire</div>
<div class="row mb-2">
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3">
<label class="form-label">Date de début</label>
<input type="date" class="form-control" formControlName="startingDate" (change)="onStartingDateChange($event)"
[ngClass]="{ 'is-invalid': submitted && f.startingDate.errors }">
<div *ngIf="submitted && f.startingDate.errors" class="invalid-feedback">
<div *ngIf="f.startingDate.errors.required">La date de début d'une période d'essai est obligatoire</div>
</div>
</div>
</div>
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3">
<label class="form-label">Date de fin prévue</label>
<input type="date" class="form-control" formControlName="plannedEndingDate"
(change)="onPlannedEndingDateChange($event)"
[ngClass]="{ 'is-invalid': submitted && f.plannedEndingDate.errors }">
<div *ngIf="submitted && f.plannedEndingDate.errors" class="invalid-feedback">
<div *ngIf="f.plannedEndingDate.errors.required">La date de fin prévue d'une période d'essai est obligatoire</div>
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3">
<label class="form-label">Date de fin prévue</label>
<input type="date" class="form-control" formControlName="plannedEndingDate"
(change)="onPlannedEndingDateChange($event)"
[ngClass]="{ 'is-invalid': submitted && f.plannedEndingDate.errors }">
<div *ngIf="submitted && f.plannedEndingDate.errors" class="invalid-feedback">
<div *ngIf="f.plannedEndingDate.errors.required">La date de fin prévue d'une période d'essai est obligatoire
</div>
</div>
</div>
</div>
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3">
<label class="form-label">Date de fin réelle</label>
<input type="date" class="form-control" formControlName="realEndingDate" (change)="onRealEndingDateChange($event)"
[ngClass]="{ 'is-invalid': submitted && f.realEndingDate.errors }">
<div *ngIf="submitted && f.realEndingDate.errors" class="invalid-feedback">
<div *ngIf="f.realEndingDate.errors.required">La date de fin réelle d'une période d'essai est obligatoire</div>
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3">
<label class="form-label">Date de fin réelle</label>
<input type="date" class="form-control" formControlName="realEndingDate"
(change)="onRealEndingDateChange($event)">
</div>
</div>
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3 mb-2">
<label class="form-label">Commentaire</label>
<input class="form-control" formControlName="comment" [ngClass]="{ 'is-invalid': submitted && f.comment.errors }">
<div *ngIf="submitted && f.comment.errors" class="invalid-feedback">
<div *ngIf="f.comment.errors.required">Le commentaire d'une période d'essai est obligatoire</div>
<div class="row mb-2">
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3 mb-2">
<label class="form-label">Commentaire</label>
<input class="form-control" formControlName="comment" [ngClass]="{ 'is-invalid': submitted && f.comment.errors }">
</div>
</div>
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3 mb-2">
<label class="form-label">Issue</label>
<input class="form-control" formControlName="issue" [ngClass]="{ 'is-invalid': submitted && f.issue.errors }">
<div *ngIf="submitted && f.issue.errors" class="invalid-feedback">
<div *ngIf="f.issue.errors.required">L'issue d'une période d'essai est obligatoire</div>
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3 mb-2">
<label class="form-label">Issue</label>
<select class="form-select" formControlName="issue">
<option value="" disabled selected>Statut</option>
<option value="VALIDEE">Validée</option>
<option value="PROLONGEE_COLLAB">Prolongée par le collaborateur</option>
<option value="PROLONGEE_APSIDE">Prolongée par Apside</option>
<option value="ARRETEE_COLLAB">Arrêtée par le collaborateur</option>
<option value="ARRETEE_APSIDE">Arrêtée par Apside</option>
<option value="INDETERMINEE">Indéterminée</option>
</select>
</div>
</div>
<div>
<button type="submit">Créer la période d'essai</button>
<button type="reset" (click)="onReset()">Effacer</button>

@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {Collaborateur} from "../../../interfaces/collaborateur";
import {PeriodeEssai} from "../../../interfaces/periode-essai";
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
@ -14,7 +14,7 @@ import {ToastrService} from "ngx-toastr";
})
export class PeriodeEssaiAddComponent implements OnInit {
collaborateurs : Collaborateur[] = [];
collaborateurs: Collaborateur[] = [];
collaborateur = {} as Collaborateur;
periodeEssai = {} as PeriodeEssai;
@ -22,26 +22,31 @@ export class PeriodeEssaiAddComponent implements OnInit {
submitted = false;
constructor(
private http : HttpClient,
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: ['', 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]
});
}
getCollaborateurs():void {
getCollaborateurs(): void {
this.collaborateurService.getCollaborateurs()
.subscribe(collaborateurs => this.collaborateurs = collaborateurs);
}
@ -51,46 +56,54 @@ export class PeriodeEssaiAddComponent 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.plannedEndingDate = this.registerForm.value.plannedEndingDate
this.periodeEssai.realEndingDate = this.registerForm.value.realEndingDate
this.periodeEssai.startingDate = this.registerForm.value.startingDate
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()
});
.subscribe(() => {
this.showSuccess();
},
() => {
this.showError()
});
}
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);
}
showSuccess() {
this.toastr.success('Création réussie', 'Collaborateur');
this.toastr.success('Création réussie', 'Période d\'essai');
}
showError() {
this.toastr.error('Création échouée', 'Collaborateur');
this.toastr.error('Création échouée', 'Période d\'essai');
}
}

@ -45,27 +45,25 @@
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3">
<label class="form-label">Date de fin réelle</label>
<input type="date" [value]="periodeEssai.realEndingDate | date:'yyyy-MM-dd'" class="form-control"
formControlName="realEndingDate" (change)="onRealEndingDateChange($event)"
[ngClass]="{ 'is-invalid': submitted && f.realEndingDate.errors }">
<div *ngIf="submitted && f.realEndingDate.errors" class="invalid-feedback">
<div *ngIf="f.realEndingDate.errors.required">La date de fin réelle d'une période d'essai est obligatoire</div>
</div>
formControlName="realEndingDate" (change)="onRealEndingDateChange($event)">
</div>
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3 mb-2">
<label class="form-label">Commentaire</label>
<input class="form-control" formControlName="comment" [ngClass]="{ 'is-invalid': submitted && f.comment.errors }">
<div *ngIf="submitted && f.comment.errors" class="invalid-feedback">
<div *ngIf="f.comment.errors.required">Le commentaire d'une période d'essai est obligatoire</div>
</div>
<input class="form-control" formControlName="comment">
</div>
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3 mb-2">
<label class="form-label">Issue</label>
<input class="form-control" formControlName="issue" [ngClass]="{ 'is-invalid': submitted && f.issue.errors }">
<div *ngIf="submitted && f.issue.errors" class="invalid-feedback">
<div *ngIf="f.issue.errors.required">L'issue d'une période d'essai est obligatoire</div>
</div>
<select class="form-select" formControlName="issue">
<option value="" disabled selected>Statut</option>
<option value="VALIDEE">Validée</option>
<option value="PROLONGEE_COLLAB">Prolongée par le collaborateur</option>
<option value="PROLONGEE_APSIDE">Prolongée par Apside</option>
<option value="ARRETEE_COLLAB">Arrêtée par le collaborateur</option>
<option value="ARRETEE_APSIDE">Arrêtée par Apside</option>
<option value="INDETERMINEE">Indéterminée</option>
</select>
</div>
<div>

@ -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<PeriodeEssai>;
periodeEssaiObservable!: Observable<PeriodeEssai>;
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);
}

@ -2,19 +2,24 @@
<h2 class=mb-4>Périodes d'essai</h2>
<div style="display: flex">
<p style="margin: 10px 0 10px 0">Pour ajouter une nouvelle période d'essai, cliquez ici : </p>
<button routerLink="/periodeessais/add">Ajouter</button>
</div>
<div style="overflow-x:auto;" class="mb-5 col-12">
<table class="table">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Collaborateur ID</th>
<th scope="col">Collaborateur</th>
<th scope="col">Issue</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let periodeEssai of periodeEssais">
<th scope="row">{{periodeEssai.id}}</th>
<td> {{periodeEssai.collaborateurId}} </td>
<td> {{getCollaborateurById(periodeEssai.collaborateurId).name}} {{getCollaborateurById(periodeEssai.collaborateurId).firstName}} </td>
<td> {{periodeEssai.issue}}</td>
<td><a routerLink="{{periodeEssai.id}}"> Modifier </a></td>
</tr>

@ -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');
}
}

@ -40,6 +40,10 @@ export class ReferencementEditComponent implements OnInit {
this.id = Number(this.route.snapshot.paramMap.get('id'))
}
get form() {
return this.registerForm.controls;
}
async ngOnInit() {
this.getCollaborateurs();
this.registerForm = this.formBuilder.group({
@ -65,12 +69,14 @@ export class ReferencementEditComponent implements OnInit {
return;
}
this.referencement.referredId = this.registerForm.value.referredId
this.referencement.referrerId = this.registerForm.value.referrerId
this.referencement.startingDate = this.registerForm.value.startingDate
this.referencement.referredId = this.registerForm.value.referredId;
this.referencement.referrerId = this.registerForm.value.referrerId;
this.referencement.startingDate = this.registerForm.value.startingDate;
if (this.registerForm.value.endingDate == undefined) {
this.referencement.endingDate = new Date()
if (this.registerForm.value.endingDate == undefined || this.registerForm.value.endingDate == '') {
this.referencement.endingDate = null;
} else {
this.referencement.endingDate = this.registerForm.value.endingDate;
}
if (this.referencement) {
@ -84,10 +90,6 @@ export class ReferencementEditComponent implements OnInit {
}
}
get form() {
return this.registerForm.controls;
}
onReset() {
this.submitted = false;
this.registerForm.reset();

@ -3,7 +3,7 @@ export interface PeriodeEssai {
collaborateurId : number;
startingDate : Date;
plannedEndingDate : Date;
realEndingDate : Date;
realEndingDate : Date | null;
comment : string;
issue : string;
}

@ -1,7 +1,7 @@
export interface Referencement {
id: number;
startingDate : Date;
endingDate? : Date;
endingDate : Date | null;
referredId : number;
referrerId : number;
}

Loading…
Cancel
Save