aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/admin/requests
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/admin/requests')
-rw-r--r--client/src/app/admin/requests/index.ts4
-rw-r--r--client/src/app/admin/requests/request-stats/index.ts1
-rw-r--r--client/src/app/admin/requests/request-stats/request-stats.component.html23
-rw-r--r--client/src/app/admin/requests/request-stats/request-stats.component.scss6
-rw-r--r--client/src/app/admin/requests/request-stats/request-stats.component.ts51
-rw-r--r--client/src/app/admin/requests/requests.component.ts8
-rw-r--r--client/src/app/admin/requests/requests.routes.ts22
-rw-r--r--client/src/app/admin/requests/shared/index.ts2
-rw-r--r--client/src/app/admin/requests/shared/request-stats.model.ts32
-rw-r--r--client/src/app/admin/requests/shared/request.service.ts22
10 files changed, 171 insertions, 0 deletions
diff --git a/client/src/app/admin/requests/index.ts b/client/src/app/admin/requests/index.ts
new file mode 100644
index 000000000..236a9ee8f
--- /dev/null
+++ b/client/src/app/admin/requests/index.ts
@@ -0,0 +1,4 @@
1export * from './request-stats';
2export * from './shared';
3export * from './requests.component';
4export * from './requests.routes';
diff --git a/client/src/app/admin/requests/request-stats/index.ts b/client/src/app/admin/requests/request-stats/index.ts
new file mode 100644
index 000000000..be3a66f77
--- /dev/null
+++ b/client/src/app/admin/requests/request-stats/index.ts
@@ -0,0 +1 @@
export * from './request-stats.component';
diff --git a/client/src/app/admin/requests/request-stats/request-stats.component.html b/client/src/app/admin/requests/request-stats/request-stats.component.html
new file mode 100644
index 000000000..b5ac59a9a
--- /dev/null
+++ b/client/src/app/admin/requests/request-stats/request-stats.component.html
@@ -0,0 +1,23 @@
1<h3>Requests stats</h3>
2
3<div *ngIf="stats !== null">
4 <div>
5 <span class="label-description">Interval seconds between requests:</span>
6 {{ stats.secondsInterval }}
7 </div>
8
9 <div>
10 <span class="label-description">Remaining time before the scheduled request:</span>
11 {{ stats.remainingSeconds }}
12 </div>
13
14 <div>
15 <span class="label-description">Maximum number of requests per interval:</span>
16 {{ stats.maxRequestsInParallel }}
17 </div>
18
19 <div>
20 <span class="label-description">Remaining requests:</span>
21 {{ stats.requests.length }}
22 </div>
23</div>
diff --git a/client/src/app/admin/requests/request-stats/request-stats.component.scss b/client/src/app/admin/requests/request-stats/request-stats.component.scss
new file mode 100644
index 000000000..92c28dc99
--- /dev/null
+++ b/client/src/app/admin/requests/request-stats/request-stats.component.scss
@@ -0,0 +1,6 @@
1.label-description {
2 display: inline-block;
3 width: 350px;
4 font-weight: bold;
5 color: black;
6}
diff --git a/client/src/app/admin/requests/request-stats/request-stats.component.ts b/client/src/app/admin/requests/request-stats/request-stats.component.ts
new file mode 100644
index 000000000..4b0844574
--- /dev/null
+++ b/client/src/app/admin/requests/request-stats/request-stats.component.ts
@@ -0,0 +1,51 @@
1import { Component, OnInit, OnDestroy } from '@angular/core';
2
3import { RequestService, RequestStats } from '../shared';
4
5@Component({
6 selector: 'my-request-stats',
7 templateUrl: './request-stats.component.html',
8 styleUrls: [ './request-stats.component.scss' ]
9})
10export class RequestStatsComponent implements OnInit, OnDestroy {
11 stats: RequestStats = null;
12
13 private interval: NodeJS.Timer = null;
14
15 constructor(private requestService: RequestService) { }
16
17 ngOnInit() {
18 this.getStats();
19 }
20
21 ngOnDestroy() {
22 if (this.stats.secondsInterval !== null) {
23 clearInterval(this.interval);
24 }
25 }
26
27 getStats() {
28 this.requestService.getStats().subscribe(
29 stats => {
30 console.log(stats);
31 this.stats = stats;
32 this.runInterval();
33 },
34
35 err => alert(err.text)
36 );
37 }
38
39 private runInterval() {
40 this.interval = setInterval(() => {
41 this.stats.remainingMilliSeconds -= 1000;
42
43 if (this.stats.remainingMilliSeconds <= 0) {
44 setTimeout(() => this.getStats(), this.stats.remainingMilliSeconds + 100);
45 clearInterval(this.interval);
46 }
47 }, 1000);
48 }
49
50
51}
diff --git a/client/src/app/admin/requests/requests.component.ts b/client/src/app/admin/requests/requests.component.ts
new file mode 100644
index 000000000..471112b45
--- /dev/null
+++ b/client/src/app/admin/requests/requests.component.ts
@@ -0,0 +1,8 @@
1import { Component } from '@angular/core';
2
3@Component({
4 template: '<router-outlet></router-outlet>'
5})
6
7export class RequestsComponent {
8}
diff --git a/client/src/app/admin/requests/requests.routes.ts b/client/src/app/admin/requests/requests.routes.ts
new file mode 100644
index 000000000..78221a9ff
--- /dev/null
+++ b/client/src/app/admin/requests/requests.routes.ts
@@ -0,0 +1,22 @@
1import { Routes } from '@angular/router';
2
3import { RequestsComponent } from './requests.component';
4import { RequestStatsComponent } from './request-stats';
5
6export const RequestsRoutes: Routes = [
7 {
8 path: 'requests',
9 component: RequestsComponent,
10 children: [
11 {
12 path: '',
13 redirectTo: 'stats',
14 pathMatch: 'full'
15 },
16 {
17 path: 'stats',
18 component: RequestStatsComponent
19 }
20 ]
21 }
22];
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 @@
1export * from './request-stats.model';
2export * 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..766e80836
--- /dev/null
+++ b/client/src/app/admin/requests/shared/request-stats.model.ts
@@ -0,0 +1,32 @@
1export interface Request {
2 request: any;
3 to: any;
4}
5
6export class RequestStats {
7 maxRequestsInParallel: number;
8 milliSecondsInterval: number;
9 remainingMilliSeconds: number;
10 requests: Request[];
11
12 constructor(hash: {
13 maxRequestsInParallel: number,
14 milliSecondsInterval: number,
15 remainingMilliSeconds: number,
16 requests: Request[];
17 }) {
18 this.maxRequestsInParallel = hash.maxRequestsInParallel;
19 this.milliSecondsInterval = hash.milliSecondsInterval;
20 this.remainingMilliSeconds = hash.remainingMilliSeconds;
21 this.requests = hash.requests;
22 }
23
24 get remainingSeconds() {
25 return Math.floor(this.remainingMilliSeconds / 1000);
26 }
27
28 get secondsInterval() {
29 return Math.floor(this.milliSecondsInterval / 1000);
30 }
31
32}
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..aeec37448
--- /dev/null
+++ b/client/src/app/admin/requests/shared/request.service.ts
@@ -0,0 +1,22 @@
1import { Injectable } from '@angular/core';
2import { Observable } from 'rxjs/Observable';
3
4import { RequestStats } from './request-stats.model';
5import { AuthHttp, RestExtractor } from '../../../shared';
6
7@Injectable()
8export class RequestService {
9 private static BASE_REQUEST_URL: string = '/api/v1/requests/';
10
11 constructor (
12 private authHttp: AuthHttp,
13 private restExtractor: RestExtractor
14 ) {}
15
16 getStats(): Observable<RequestStats> {
17 return this.authHttp.get(RequestService.BASE_REQUEST_URL + 'stats')
18 .map(this.restExtractor.extractDataGet)
19 .map((data) => new RequestStats(data))
20 .catch((res) => this.restExtractor.handleError(res));
21 }
22}