Added config/statistics services to call API

master
Alix JEUDI--LEMOINE 1 week ago
parent b5b419705e
commit 7657843bca

@ -0,0 +1,25 @@
import { Injectable } from '@angular/core';
import { environment } from '../../environment';
import { HttpClient } from '@angular/common/http';
import { AuthService } from './auth.service';
import { Observable } from 'rxjs';
import { SystemConfig } from '../model/SystemConfig';
@Injectable({
providedIn: 'root',
})
export class ConfigService {
constructor(private http: HttpClient, private authService: AuthService) {}
public loadConfig(): Observable<SystemConfig> {
return this.http.get<SystemConfig>(`${environment.apiURL}/admin/config`, {
headers: this.authService.getAuthHeaders(),
});
}
public saveConfig(config: SystemConfig): Observable<SystemConfig> {
return this.http.patch<SystemConfig>(`${environment.apiURL}/admin/config`, config, {
headers: this.authService.getAuthHeaders(),
});
}
}

@ -0,0 +1,19 @@
import { Injectable } from '@angular/core';
import { environment } from '../../environment';
import { HttpClient } from '@angular/common/http';
import { Stats } from '../model/Stats';
import { AuthService } from './auth.service';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root',
})
export class StatisticsService {
constructor(private http: HttpClient, private authService: AuthService) {}
public loadStats(): Observable<Stats> {
return this.http.get<Stats>(`${environment.apiURL}/admin/stats`, {
headers: this.authService.getAuthHeaders(),
});
}
}
Loading…
Cancel
Save