119 lines
3.1 KiB
TypeScript
119 lines
3.1 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
|
import { Observable } from 'rxjs';
|
|
import { environment } from '../../../environments/environment';
|
|
import { Utilisateur } from '../../models/utilisateur.model';
|
|
import { Parameters } from '../../models/parameters.model';
|
|
import { Scheduler } from '../../models/scheduler.model';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class BackendService {
|
|
constructor(private http:HttpClient) {}
|
|
|
|
loginUser(val:any):Observable<any> {
|
|
let host=environment.host;
|
|
const options = {
|
|
headers: new HttpHeaders({
|
|
'Content-Type' : 'application/json',
|
|
'Authorization' : 'Basic ' + btoa(val['login'] + ':' + val['password']),
|
|
}),
|
|
withCredentials: true
|
|
};
|
|
|
|
return this.http.post<any>(host+"/api/configurateur/login", {}, options);
|
|
}
|
|
|
|
isConnected():Observable<any> {
|
|
let host=environment.host;
|
|
const options = {
|
|
headers: new HttpHeaders({
|
|
'Content-Type' : 'application/json',
|
|
}),
|
|
withCredentials: true
|
|
};
|
|
return this.http.get<any>(host+"/api/configurateur/userConnected", options);
|
|
}
|
|
|
|
logoutUser():Observable<any> {
|
|
let host=environment.host;
|
|
const options = {
|
|
headers: new HttpHeaders({
|
|
'Content-Type' : 'application/json',
|
|
}),
|
|
withCredentials: true
|
|
};
|
|
return this.http.post<any>(host+"/api/configurateur/logout", {}, options);
|
|
}
|
|
|
|
getCurrentUser():Observable<Utilisateur> {
|
|
let host=environment.host;
|
|
const options = {
|
|
headers: new HttpHeaders({
|
|
'Content-Type' : 'application/json',
|
|
}),
|
|
withCredentials: true
|
|
};
|
|
return this.http.get<Utilisateur>(host+"/api/configurateur/current", options);
|
|
}
|
|
|
|
updatePasswd(val:any):Observable<any> {
|
|
let host=environment.host;
|
|
const options = {
|
|
headers: new HttpHeaders({
|
|
'Content-Type' : 'application/json',
|
|
}),
|
|
withCredentials: true
|
|
};
|
|
|
|
return this.http.post<any>(host+"/api/configurateur/update_passwd", val, options);
|
|
}
|
|
|
|
retreiveParams():Observable<Parameters> {
|
|
let host=environment.host;
|
|
const options = {
|
|
headers: new HttpHeaders({
|
|
'Content-Type' : 'application/json',
|
|
}),
|
|
withCredentials: true
|
|
};
|
|
return this.http.get<Parameters>(host+"/api/configurateur/params", options);
|
|
}
|
|
|
|
updateParams(val:Parameters):Observable<any> {
|
|
let host=environment.host;
|
|
const options = {
|
|
headers: new HttpHeaders({
|
|
'Content-Type' : 'application/json',
|
|
}),
|
|
withCredentials: true
|
|
};
|
|
|
|
return this.http.post<any>(host+"/api/configurateur/update_params", val, options);
|
|
}
|
|
|
|
retreiveSchedulers():Observable<Scheduler[]> {
|
|
let host=environment.host;
|
|
const options = {
|
|
headers: new HttpHeaders({
|
|
'Content-Type' : 'application/json',
|
|
}),
|
|
withCredentials: true
|
|
};
|
|
return this.http.get<Scheduler[]>(host+"/api/configurateur/scheduler", options);
|
|
}
|
|
|
|
updateSchedulers(val:Scheduler[]):Observable<any> {
|
|
let host=environment.host;
|
|
const options = {
|
|
headers: new HttpHeaders({
|
|
'Content-Type' : 'application/json',
|
|
}),
|
|
withCredentials: true
|
|
};
|
|
|
|
return this.http.post<any>(host+"/api/configurateur/update_schedulers", val, options);
|
|
}
|
|
}
|