diff options
Diffstat (limited to 'client/src/app/+admin/requests/shared/request.service.ts')
-rw-r--r-- | client/src/app/+admin/requests/shared/request.service.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/client/src/app/+admin/requests/shared/request.service.ts b/client/src/app/+admin/requests/shared/request.service.ts new file mode 100644 index 000000000..55b28bcfc --- /dev/null +++ b/client/src/app/+admin/requests/shared/request.service.ts | |||
@@ -0,0 +1,24 @@ | |||
1 | import { Injectable } from '@angular/core'; | ||
2 | import { Observable } from 'rxjs/Observable'; | ||
3 | import 'rxjs/add/operator/catch'; | ||
4 | import 'rxjs/add/operator/map'; | ||
5 | |||
6 | import { RequestStats } from './request-stats.model'; | ||
7 | import { AuthHttp, RestExtractor } from '../../../shared'; | ||
8 | |||
9 | @Injectable() | ||
10 | export class RequestService { | ||
11 | private static BASE_REQUEST_URL: string = '/api/v1/requests/'; | ||
12 | |||
13 | constructor ( | ||
14 | private authHttp: AuthHttp, | ||
15 | private restExtractor: RestExtractor | ||
16 | ) {} | ||
17 | |||
18 | getStats(): Observable<RequestStats> { | ||
19 | return this.authHttp.get(RequestService.BASE_REQUEST_URL + 'stats') | ||
20 | .map(this.restExtractor.extractDataGet) | ||
21 | .map((data) => new RequestStats(data)) | ||
22 | .catch((res) => this.restExtractor.handleError(res)); | ||
23 | } | ||
24 | } | ||