import { Injectable } from '@angular/core'; import {HttpClient, HttpHeaders} from "@angular/common/http"; import {Observable} from "rxjs"; import {AdminUsersResponse} from "../../model/responses/AdminUsersResponse"; import {FinesPerLine} from "../../model/FinesPerLine"; import {CommutesByHour} from "../../components/charts/line-chart.component"; import {IncomeData} from "../../components/charts/stacked-bar-chart.component"; @Injectable({ providedIn: 'root' }) export class AdminService { private url = '/api/admin' constructor(private http: HttpClient) { } getAllUsers(): Observable { return this.http.get(`${this.url}/all-users`) } updateRolesToUser(id: number, roles: string[]): Observable { return this.http.post(`${this.url}/update-roles/${id}`, JSON.stringify(roles), { headers: new HttpHeaders({'Content-Type': 'application/json'}) }) } getFinesPerLine() { return this.http.get(`${this.url}/fines-by-line`); } getCommutesByHour() { return this.http.get(`${this.url}/commutes-by-hour`); } getTotalIncome() { return this.http.get(`${this.url}/total-income`); } }