periode-essai works!
+
+
+
diff --git a/src/app/components/periode-essai/periode-essai.component.ts b/src/app/components/periode-essai/periode-essai.component.ts
index 20fab35..22ec458 100644
--- a/src/app/components/periode-essai/periode-essai.component.ts
+++ b/src/app/components/periode-essai/periode-essai.component.ts
@@ -1,4 +1,10 @@
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";
@Component({
selector: 'app-periode-essai',
@@ -7,9 +13,91 @@ import { Component, OnInit } from '@angular/core';
})
export class PeriodeEssaiComponent implements OnInit {
- constructor() { }
+ collaborateurs : Collaborateur[] = [];
+ collaborateur = {} as Collaborateur;
+
+ periodeEssais : PeriodeEssai[] = [];
+ periodeEssai = {} as PeriodeEssai;
+
+ registerForm!: FormGroup;
+ submitted = false;
+
+ startingDate : String = "";
+ plannedEndingDate : String = "";
+ realEndingDate : String = "";
+
+ constructor(
+ private http : HttpClient,
+ private collaborateurService: CollaborateurService,
+ private periodeEssaiService: PeriodeEssaiService,
+ private formBuilder: FormBuilder
+ ) { }
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]
+ });
+ if (this.periodeEssai.startingDate) {
+ this.startingDate = new Date(this.periodeEssai.startingDate).toISOString().split('T')[0];
+ }
+ if (this.periodeEssai.plannedEndingDate) {
+ this.plannedEndingDate = new Date(this.periodeEssai.plannedEndingDate).toISOString().split('T')[0];
+ }
+ if (this.periodeEssai.realEndingDate) {
+ this.realEndingDate = new Date(this.periodeEssai.realEndingDate).toISOString().split('T')[0];
+ }
+ }
+
+ getCollaborateurs():void {
+ this.collaborateurService.getCollaborateurs()
+ .subscribe(collaborateurs => this.collaborateurs = collaborateurs);
+ }
+
+ 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);
+ }
+
+ onRealEndingDateChange($event: any):void {
+ this.periodeEssai.realEndingDate = new Date($event.target.value);
}
}
diff --git a/src/app/interfaces/periode-essai.ts b/src/app/interfaces/periode-essai.ts
new file mode 100644
index 0000000..7ffc318
--- /dev/null
+++ b/src/app/interfaces/periode-essai.ts
@@ -0,0 +1,9 @@
+export interface PeriodeEssai {
+ id: number;
+ collaborateurId : number;
+ startingDate : Date;
+ plannedEndingDate : Date;
+ realEndingDate : Date;
+ comment : string;
+ issue : string;
+}
diff --git a/src/app/services/periode-essai.service.ts b/src/app/services/periode-essai.service.ts
new file mode 100644
index 0000000..eb177e4
--- /dev/null
+++ b/src/app/services/periode-essai.service.ts
@@ -0,0 +1,37 @@
+import { Injectable } from '@angular/core';
+import {HttpClient, HttpHeaders} from "@angular/common/http";
+import {Observable} from "rxjs";
+import {periodeessaisUrl} from "../../ressources/routes/routesPreprod";
+import {PeriodeEssai} from "../interfaces/periode-essai";
+
+
+@Injectable({
+ providedIn: 'root'
+})
+export class PeriodeEssaiService{
+ private periodeessaisUrl = periodeessaisUrl;
+
+ httpOptions = {
+ headers: new HttpHeaders({ 'Content-Type': 'application/json' })
+ };
+
+ constructor(private http: HttpClient) { }
+
+ getPeriodeEssais():ObservableAjouter une Période d'Essai :
+ + + +Périodes d'essai
+ +
+
+
+
+
+
+
+
+
+ID | +Collaborateur ID | +Issue | +|
---|---|---|---|
{{periodeEssai.id}} | +{{periodeEssai.collaborateurId}} | ++ | Modifier | +