aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/requests/request-stats/request-stats.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin/requests/request-stats/request-stats.component.ts')
-rw-r--r--client/src/app/+admin/requests/request-stats/request-stats.component.ts60
1 files changed, 43 insertions, 17 deletions
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
index 18855a5f8..85dd7e492 100644
--- a/client/src/app/+admin/requests/request-stats/request-stats.component.ts
+++ b/client/src/app/+admin/requests/request-stats/request-stats.component.ts
@@ -10,10 +10,30 @@ import { RequestService, RequestStats } from '../shared';
10 styleUrls: [ './request-stats.component.scss' ] 10 styleUrls: [ './request-stats.component.scss' ]
11}) 11})
12export class RequestStatsComponent implements OnInit, OnDestroy { 12export class RequestStatsComponent implements OnInit, OnDestroy {
13 stats: RequestStats = null; 13 statsTitles = {
14 requestScheduler: 'Basic request scheduler',
15 requestVideoEventScheduler: 'Video events request scheduler',
16 requestVideoQaduScheduler: 'Quick and dirty video updates request scheduler'
17 };
18
19 stats: { [ id: string ]: RequestStats } = {
20 requestScheduler: null,
21 requestVideoEventScheduler: null,
22 requestVideoQaduScheduler: null
23 };
24
25 private intervals: { [ id: string ]: number } = {
26 requestScheduler: null,
27 requestVideoEventScheduler: null,
28 requestVideoQaduScheduler: null
29 };
30
31 private timeouts: { [ id: string ]: number } = {
32 requestScheduler: null,
33 requestVideoEventScheduler: null,
34 requestVideoQaduScheduler: null
35 };
14 36
15 private interval: number = null;
16 private timeout: number = null;
17 37
18 constructor( 38 constructor(
19 private notificationsService: NotificationsService, 39 private notificationsService: NotificationsService,
@@ -22,17 +42,19 @@ export class RequestStatsComponent implements OnInit, OnDestroy {
22 42
23 ngOnInit() { 43 ngOnInit() {
24 this.getStats(); 44 this.getStats();
25 this.runInterval(); 45 this.runIntervals();
26 } 46 }
27 47
28 ngOnDestroy() { 48 ngOnDestroy() {
29 if (this.interval !== null) { 49 Object.keys(this.stats).forEach(requestSchedulerName => {
30 window.clearInterval(this.interval); 50 if (this.intervals[requestSchedulerName] !== null) {
31 } 51 window.clearInterval(this.intervals[requestSchedulerName]);
52 }
32 53
33 if (this.timeout !== null) { 54 if (this.timeouts[requestSchedulerName] !== null) {
34 window.clearTimeout(this.timeout); 55 window.clearTimeout(this.timeouts[requestSchedulerName]);
35 } 56 }
57 });
36 } 58 }
37 59
38 getStats() { 60 getStats() {
@@ -43,14 +65,18 @@ export class RequestStatsComponent implements OnInit, OnDestroy {
43 ); 65 );
44 } 66 }
45 67
46 private runInterval() { 68 private runIntervals() {
47 this.interval = window.setInterval(() => { 69 Object.keys(this.intervals).forEach(requestSchedulerName => {
48 this.stats.remainingMilliSeconds -= 1000; 70 this.intervals[requestSchedulerName] = window.setInterval(() => {
71 const stats = this.stats[requestSchedulerName];
49 72
50 if (this.stats.remainingMilliSeconds <= 0) { 73 stats.remainingMilliSeconds -= 1000;
51 this.timeout = window.setTimeout(() => this.getStats(), this.stats.remainingMilliSeconds + 100); 74
52 } 75 if (stats.remainingMilliSeconds <= 0) {
53 }, 1000); 76 this.timeouts[requestSchedulerName] = window.setTimeout(() => this.getStats(), stats.remainingMilliSeconds + 100);
77 }
78 }, 1000);
79 });
54 } 80 }
55 81
56 82