2017-12-15 12:52:11 +01:00
|
|
|
import 'rxjs/add/operator/map';
|
|
|
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { HostConfiguration } from './../../app.constants';
|
|
|
|
import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service';
|
|
|
|
import { Observable } from 'rxjs/Observable';
|
|
|
|
import { DashboardStatisticsModel } from '../../models/dashboard/DashboardStatisticsModel';
|
2018-08-24 17:21:02 +02:00
|
|
|
import { SearchBarItem } from '../../models/dashboard/SearchBarItem';
|
2017-12-15 12:52:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class DashboardService {
|
|
|
|
|
2018-08-24 17:21:02 +02:00
|
|
|
private actionUrl: string;
|
|
|
|
private headers: HttpHeaders;
|
2017-12-15 12:52:11 +01:00
|
|
|
|
2018-08-24 17:21:02 +02:00
|
|
|
constructor(private http: BaseHttpService) {
|
2017-12-15 12:52:11 +01:00
|
|
|
|
2018-08-24 17:21:02 +02:00
|
|
|
this.actionUrl = HostConfiguration.Server + 'dashboard/';
|
2017-12-15 12:52:11 +01:00
|
|
|
|
2018-08-24 17:21:02 +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-08-24 17:21:02 +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-08-24 17:21:02 +02:00
|
|
|
getStatisticsSpecificuser(): Observable<DashboardStatisticsModel> {
|
|
|
|
return this.http.get<DashboardStatisticsModel>(this.actionUrl + 'me/getStatistics', { headers: this.headers });
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|