diff options
Diffstat (limited to 'client/src/app/+admin/requests/shared')
-rw-r--r-- | client/src/app/+admin/requests/shared/index.ts | 2 | ||||
-rw-r--r-- | client/src/app/+admin/requests/shared/request-stats.model.ts | 35 | ||||
-rw-r--r-- | client/src/app/+admin/requests/shared/request.service.ts | 24 |
3 files changed, 61 insertions, 0 deletions
diff --git a/client/src/app/+admin/requests/shared/index.ts b/client/src/app/+admin/requests/shared/index.ts new file mode 100644 index 000000000..32ab5767b --- /dev/null +++ b/client/src/app/+admin/requests/shared/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './request-stats.model'; | ||
2 | export * from './request.service'; | ||
diff --git a/client/src/app/+admin/requests/shared/request-stats.model.ts b/client/src/app/+admin/requests/shared/request-stats.model.ts new file mode 100644 index 000000000..f658c4682 --- /dev/null +++ b/client/src/app/+admin/requests/shared/request-stats.model.ts | |||
@@ -0,0 +1,35 @@ | |||
1 | export interface Request { | ||
2 | request: any; | ||
3 | to: any; | ||
4 | } | ||
5 | |||
6 | export class RequestStats { | ||
7 | requestsLimitPods: number; | ||
8 | requestsLimitPerPod: number; | ||
9 | milliSecondsInterval: number; | ||
10 | remainingMilliSeconds: number; | ||
11 | totalRequests: number; | ||
12 | |||
13 | constructor(hash: { | ||
14 | requestsLimitPods: number, | ||
15 | requestsLimitPerPod: number, | ||
16 | milliSecondsInterval: number, | ||
17 | remainingMilliSeconds: number, | ||
18 | totalRequests: number; | ||
19 | }) { | ||
20 | this.requestsLimitPods = hash.requestsLimitPods; | ||
21 | this.requestsLimitPerPod = hash.requestsLimitPerPod; | ||
22 | this.milliSecondsInterval = hash.milliSecondsInterval; | ||
23 | this.remainingMilliSeconds = hash.remainingMilliSeconds; | ||
24 | this.totalRequests = hash.totalRequests; | ||
25 | } | ||
26 | |||
27 | get remainingSeconds() { | ||
28 | return Math.floor(this.remainingMilliSeconds / 1000); | ||
29 | } | ||
30 | |||
31 | get secondsInterval() { | ||
32 | return Math.floor(this.milliSecondsInterval / 1000); | ||
33 | } | ||
34 | |||
35 | } | ||
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 | } | ||