|
|
@ -2,6 +2,8 @@ import { Injectable } from "@angular/core"; |
|
|
|
import { HttpClient } from "@angular/common/http"; |
|
|
|
import { HttpClient } from "@angular/common/http"; |
|
|
|
import { Observable } from "rxjs"; |
|
|
|
import { Observable } from "rxjs"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { KeycloakService } from 'keycloak-angular'; |
|
|
|
|
|
|
|
|
|
|
|
import {FormationModel, DemandeFormationModel, EvaluationFormationModel, ThemeModel } from "../modeles/modele-formation"; |
|
|
|
import {FormationModel, DemandeFormationModel, EvaluationFormationModel, ThemeModel } from "../modeles/modele-formation"; |
|
|
|
import { urlsFormation } from "../utils/path-values-formations"; |
|
|
|
import { urlsFormation } from "../utils/path-values-formations"; |
|
|
|
|
|
|
|
|
|
|
@ -9,53 +11,79 @@ import { urlsFormation } from "../utils/path-values-formations"; |
|
|
|
providedIn : 'root' |
|
|
|
providedIn : 'root' |
|
|
|
}) |
|
|
|
}) |
|
|
|
export class ServiceFormation { |
|
|
|
export class ServiceFormation { |
|
|
|
constructor(private http: HttpClient) { |
|
|
|
constructor(private http: HttpClient, private keycloakService : KeycloakService) {} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listeFormations() : Observable<FormationModel[]> { |
|
|
|
listeFormations() : Observable<FormationModel[]> { |
|
|
|
return this.http.get<FormationModel[]>(urlsFormation.urlFormation); |
|
|
|
let token = this.keycloakService.getKeycloakInstance().token; |
|
|
|
|
|
|
|
const headers = { Authorization: "Bearer "+token }; |
|
|
|
|
|
|
|
return this.http.get<FormationModel[]>(urlsFormation.urlFormation, {headers}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listeFormationsCollaborateur(id) : Observable<FormationModel[]> { |
|
|
|
listeFormationsCollaborateur(id) : Observable<FormationModel[]> { |
|
|
|
|
|
|
|
let token = this.keycloakService.getKeycloakInstance().token; |
|
|
|
|
|
|
|
const headers = { Authorization: "Bearer "+token }; |
|
|
|
let params = { idCollab : id }; |
|
|
|
let params = { idCollab : id }; |
|
|
|
return this.http.get<FormationModel[]>(urlsFormation.urlFormation, { params }); |
|
|
|
return this.http.get<FormationModel[]>(urlsFormation.urlFormation, { params, headers }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
nouvelleFormation(formation) : Observable<FormationModel> { |
|
|
|
nouvelleFormation(formation) : Observable<FormationModel> { |
|
|
|
return this.http.post<FormationModel>(urlsFormation.newFormation, formation); |
|
|
|
let token = this.keycloakService.getKeycloakInstance().token; |
|
|
|
|
|
|
|
const headers = { |
|
|
|
|
|
|
|
Authorization: "Bearer "+token, |
|
|
|
|
|
|
|
ContentType: "application/json" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
return this.http.post<FormationModel>(urlsFormation.newFormation, formation, {headers}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
updateFormation(formation) : Observable<FormationModel> { |
|
|
|
updateFormation(formation) : Observable<FormationModel> { |
|
|
|
return this.http.post<FormationModel>(urlsFormation.newFormation, formation); |
|
|
|
let token = this.keycloakService.getKeycloakInstance().token; |
|
|
|
|
|
|
|
const headers = { |
|
|
|
|
|
|
|
Authorization: "Bearer "+token, |
|
|
|
|
|
|
|
ContentType: "application/json" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
return this.http.put<FormationModel>(urlsFormation.newFormation, formation, {headers}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
deleteFormation(id) { |
|
|
|
deleteFormation(id) { |
|
|
|
|
|
|
|
let token = this.keycloakService.getKeycloakInstance().token; |
|
|
|
|
|
|
|
const headers = { Authorization: "Bearer "+token }; |
|
|
|
let params = { idFormation : id }; |
|
|
|
let params = { idFormation : id }; |
|
|
|
return this.http.delete(urlsFormation.urlFormation); |
|
|
|
return this.http.delete(urlsFormation.urlFormation, {headers, params}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
evaluationsFormation(id) : Observable<EvaluationFormationModel[]> { |
|
|
|
evaluationsFormation(id) : Observable<EvaluationFormationModel[]> { |
|
|
|
|
|
|
|
let token = this.keycloakService.getKeycloakInstance().token; |
|
|
|
|
|
|
|
const headers = { Authorization: "Bearer "+token }; |
|
|
|
let params = { idFormation : id }; |
|
|
|
let params = { idFormation : id }; |
|
|
|
return this.http.get<EvaluationFormationModel[]>(urlsFormation.evaluationsFormation); |
|
|
|
return this.http.get<EvaluationFormationModel[]>(urlsFormation.evaluationsFormation, {headers, params}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
evaluerFormation(evaluation) { |
|
|
|
evaluerFormation(evaluation) { |
|
|
|
return this.http.post<EvaluationFormationModel>(urlsFormation.evaluerFormation, evaluation); |
|
|
|
let token = this.keycloakService.getKeycloakInstance().token; |
|
|
|
|
|
|
|
const headers = { |
|
|
|
|
|
|
|
Authorization: "Bearer "+token, |
|
|
|
|
|
|
|
ContentType: "application/json" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
return this.http.post<EvaluationFormationModel>(urlsFormation.evaluerFormation, evaluation, {headers}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
listeDemandesFormation() : Observable<DemandeFormationModel[]> { |
|
|
|
listeDemandesFormation() : Observable<DemandeFormationModel[]> { |
|
|
|
return this.http.get<DemandeFormationModel[]>(urlsFormation.urlDemandesFormation); |
|
|
|
let token = this.keycloakService.getKeycloakInstance().token; |
|
|
|
|
|
|
|
const headers = { Authorization: "Bearer "+token }; |
|
|
|
|
|
|
|
return this.http.get<DemandeFormationModel[]>(urlsFormation.urlDemandesFormation, {headers}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
reponseDemandeFormation(demandeFormation) { |
|
|
|
reponseDemandeFormation(demandeFormation) { |
|
|
|
return this.http.post<DemandeFormationModel>(urlsFormation.urlDemandesFormation, demandeFormation); |
|
|
|
let token = this.keycloakService.getKeycloakInstance().token; |
|
|
|
|
|
|
|
const headers = { Authorization: "Bearer "+token }; |
|
|
|
|
|
|
|
return this.http.post<DemandeFormationModel>(urlsFormation.urlDemandesFormation, demandeFormation, {headers}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
listeTheme() : Observable<ThemeModel[]> { |
|
|
|
listeTheme() : Observable<ThemeModel[]> { |
|
|
|
return this.http.get<ThemeModel[]>(urlsFormation.urlTheme); |
|
|
|
let token = this.keycloakService.getKeycloakInstance().token; |
|
|
|
|
|
|
|
const headers = { Authorization: "Bearer "+token }; |
|
|
|
|
|
|
|
return this.http.get<ThemeModel[]>(urlsFormation.urlTheme, {headers}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|