argos/dmp-frontend/src/app/services/dashboard/dashboard.service.ts

38 lines
1.4 KiB
TypeScript
Raw Normal View History

2018-11-27 15:13:56 +01:00
import { HttpHeaders } from '@angular/common/http';
2017-12-15 12:52:11 +01:00
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
2018-11-27 15:13:56 +01:00
import 'rxjs/add/operator/map';
import { environment } from '../../../environments/environment';
2017-12-15 12:52:11 +01:00
import { DashboardStatisticsModel } from '../../models/dashboard/DashboardStatisticsModel';
2018-08-24 17:21:02 +02:00
import { SearchBarItem } from '../../models/dashboard/SearchBarItem';
2018-11-27 15:13:56 +01:00
import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service';
2017-12-15 12:52:11 +01:00
@Injectable()
export class DashboardService {
2018-10-05 17:00:54 +02:00
private actionUrl: string;
private headers: HttpHeaders;
2017-12-15 12:52:11 +01:00
2018-10-05 17:00:54 +02:00
constructor(private http: BaseHttpService) {
2017-12-15 12:52:11 +01:00
2018-11-27 15:13:56 +01:00
this.actionUrl = environment.Server + 'dashboard/';
2017-12-15 12:52:11 +01:00
2018-10-05 17:00:54 +02:00
this.headers = new HttpHeaders();
this.headers = this.headers.set('Content-Type', 'application/json');
this.headers = this.headers.set('Accept', 'application/json');
}
2017-12-15 12:52:11 +01:00
2018-10-05 17:00:54 +02:00
getStatistics(): Observable<DashboardStatisticsModel> {
return this.http.get<DashboardStatisticsModel>(this.actionUrl + 'getStatistics', { headers: this.headers });
}
2017-12-15 12:52:11 +01:00
2018-10-05 17:00:54 +02:00
getStatisticsSpecificuser(): Observable<DashboardStatisticsModel> {
return this.http.get<DashboardStatisticsModel>(this.actionUrl + 'me/getStatistics', { headers: this.headers });
}
2018-08-24 17:21:02 +02:00
2018-10-05 17:00:54 +02:00
searchUserItems(like: string): Observable<SearchBarItem[]> {
return this.http.get<SearchBarItem[]>(this.actionUrl + 'search?like=' + like, { headers: this.headers });
}
2018-02-02 15:07:25 +01:00
2017-12-15 12:52:11 +01:00
}