Last change
on this file 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
|
Rev | Line | |
---|
[baf4cc4] | 1 | import { Injectable } from '@angular/core';
|
---|
| 2 | import {HttpClient, HttpHeaders} from "@angular/common/http";
|
---|
| 3 | import {Observable} from "rxjs";
|
---|
| 4 | import {AdminUsersResponse} from "../../model/responses/AdminUsersResponse";
|
---|
| 5 | import {FinesPerLine} from "../../model/FinesPerLine";
|
---|
| 6 | import {CommutesByHour} from "../../components/charts/line-chart.component";
|
---|
| 7 | import {IncomeData} from "../../components/charts/stacked-bar-chart.component";
|
---|
| 8 |
|
---|
| 9 | @Injectable({
|
---|
| 10 | providedIn: 'root'
|
---|
| 11 | })
|
---|
| 12 | export 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.