source: bus-n-go-pavel-216049/bus-n-go-frontend/src/app/services/admin/admin.service.ts@ dedbf60

Last change on this file since dedbf60 was baf4cc4, checked in by ppaunovski <paunovskipavel@…>, 3 months ago

split group project and individual project into two separate folders

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[baf4cc4]1import { Injectable } from '@angular/core';
2import {HttpClient, HttpHeaders} from "@angular/common/http";
3import {Observable} from "rxjs";
4import {AdminUsersResponse} from "../../model/responses/AdminUsersResponse";
5import {FinesPerLine} from "../../model/FinesPerLine";
6import {CommutesByHour} from "../../components/charts/line-chart.component";
7import {IncomeData} from "../../components/charts/stacked-bar-chart.component";
8
9@Injectable({
10 providedIn: 'root'
11})
12export class AdminService {
13 private url = '/api/admin'
14 constructor(private http: HttpClient) { }
15
16 getAllUsers(): Observable<AdminUsersResponse[]> {
17 return this.http.get<AdminUsersResponse[]>(`${this.url}/all-users`)
18 }
19
20 updateRolesToUser(id: number, roles: string[]): Observable<AdminUsersResponse[]> {
21 return this.http.post<AdminUsersResponse[]>(`${this.url}/update-roles/${id}`, JSON.stringify(roles), {
22 headers: new HttpHeaders({'Content-Type': 'application/json'})
23 })
24 }
25
26 getFinesPerLine() {
27 return this.http.get<FinesPerLine[]>(`${this.url}/fines-by-line`);
28 }
29
30 getCommutesByHour() {
31 return this.http.get<CommutesByHour[]>(`${this.url}/commutes-by-hour`);
32 }
33
34 getTotalIncome() {
35 return this.http.get<IncomeData[]>(`${this.url}/total-income`);
36 }
37}
Note: See TracBrowser for help on using the repository browser.