diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 14:32:15 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 14:32:15 +0200 |
commit | df98563e2104b82b119c00a3cd83cd0dc1242d25 (patch) | |
tree | a9720bf01bac9ad5646bd3d3c9bc7653617afdad /client/src/app/+admin/requests/request-stats | |
parent | 46757b477c1adb5f98060d15998a3852e18902a6 (diff) | |
download | PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.gz PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.zst PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.zip |
Use typescript standard and lint all files
Diffstat (limited to 'client/src/app/+admin/requests/request-stats')
-rw-r--r-- | client/src/app/+admin/requests/request-stats/index.ts | 2 | ||||
-rw-r--r-- | client/src/app/+admin/requests/request-stats/request-stats.component.ts | 55 |
2 files changed, 27 insertions, 30 deletions
diff --git a/client/src/app/+admin/requests/request-stats/index.ts b/client/src/app/+admin/requests/request-stats/index.ts index be3a66f77..740c401bb 100644 --- a/client/src/app/+admin/requests/request-stats/index.ts +++ b/client/src/app/+admin/requests/request-stats/index.ts | |||
@@ -1 +1 @@ | |||
export * from './request-stats.component'; | export * from './request-stats.component' | ||
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 85dd7e492..cca4926cf 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 | |||
@@ -1,12 +1,12 @@ | |||
1 | import { Component, OnInit, OnDestroy } from '@angular/core'; | 1 | import { Component, OnInit, OnDestroy } from '@angular/core' |
2 | 2 | ||
3 | import { NotificationsService } from 'angular2-notifications'; | 3 | import { NotificationsService } from 'angular2-notifications' |
4 | 4 | ||
5 | import { RequestService, RequestStats } from '../shared'; | 5 | import { RequestService, RequestStats } from '../shared' |
6 | 6 | ||
7 | @Component({ | 7 | @Component({ |
8 | selector: 'my-request-stats', | 8 | selector: 'my-request-stats', |
9 | templateUrl: './request-stats.component.html', | 9 | templateUrl: './request-stats.component.html', |
10 | styleUrls: [ './request-stats.component.scss' ] | 10 | styleUrls: [ './request-stats.component.scss' ] |
11 | }) | 11 | }) |
12 | export class RequestStatsComponent implements OnInit, OnDestroy { | 12 | export class RequestStatsComponent implements OnInit, OnDestroy { |
@@ -14,70 +14,67 @@ export class RequestStatsComponent implements OnInit, OnDestroy { | |||
14 | requestScheduler: 'Basic request scheduler', | 14 | requestScheduler: 'Basic request scheduler', |
15 | requestVideoEventScheduler: 'Video events request scheduler', | 15 | requestVideoEventScheduler: 'Video events request scheduler', |
16 | requestVideoQaduScheduler: 'Quick and dirty video updates request scheduler' | 16 | requestVideoQaduScheduler: 'Quick and dirty video updates request scheduler' |
17 | }; | 17 | } |
18 | 18 | ||
19 | stats: { [ id: string ]: RequestStats } = { | 19 | stats: { [ id: string ]: RequestStats } = { |
20 | requestScheduler: null, | 20 | requestScheduler: null, |
21 | requestVideoEventScheduler: null, | 21 | requestVideoEventScheduler: null, |
22 | requestVideoQaduScheduler: null | 22 | requestVideoQaduScheduler: null |
23 | }; | 23 | } |
24 | 24 | ||
25 | private intervals: { [ id: string ]: number } = { | 25 | private intervals: { [ id: string ]: number } = { |
26 | requestScheduler: null, | 26 | requestScheduler: null, |
27 | requestVideoEventScheduler: null, | 27 | requestVideoEventScheduler: null, |
28 | requestVideoQaduScheduler: null | 28 | requestVideoQaduScheduler: null |
29 | }; | 29 | } |
30 | 30 | ||
31 | private timeouts: { [ id: string ]: number } = { | 31 | private timeouts: { [ id: string ]: number } = { |
32 | requestScheduler: null, | 32 | requestScheduler: null, |
33 | requestVideoEventScheduler: null, | 33 | requestVideoEventScheduler: null, |
34 | requestVideoQaduScheduler: null | 34 | requestVideoQaduScheduler: null |
35 | }; | 35 | } |
36 | |||
37 | 36 | ||
38 | constructor( | 37 | constructor ( |
39 | private notificationsService: NotificationsService, | 38 | private notificationsService: NotificationsService, |
40 | private requestService: RequestService | 39 | private requestService: RequestService |
41 | ) { } | 40 | ) { } |
42 | 41 | ||
43 | ngOnInit() { | 42 | ngOnInit () { |
44 | this.getStats(); | 43 | this.getStats() |
45 | this.runIntervals(); | 44 | this.runIntervals() |
46 | } | 45 | } |
47 | 46 | ||
48 | ngOnDestroy() { | 47 | ngOnDestroy () { |
49 | Object.keys(this.stats).forEach(requestSchedulerName => { | 48 | Object.keys(this.stats).forEach(requestSchedulerName => { |
50 | if (this.intervals[requestSchedulerName] !== null) { | 49 | if (this.intervals[requestSchedulerName] !== null) { |
51 | window.clearInterval(this.intervals[requestSchedulerName]); | 50 | window.clearInterval(this.intervals[requestSchedulerName]) |
52 | } | 51 | } |
53 | 52 | ||
54 | if (this.timeouts[requestSchedulerName] !== null) { | 53 | if (this.timeouts[requestSchedulerName] !== null) { |
55 | window.clearTimeout(this.timeouts[requestSchedulerName]); | 54 | window.clearTimeout(this.timeouts[requestSchedulerName]) |
56 | } | 55 | } |
57 | }); | 56 | }) |
58 | } | 57 | } |
59 | 58 | ||
60 | getStats() { | 59 | getStats () { |
61 | this.requestService.getStats().subscribe( | 60 | this.requestService.getStats().subscribe( |
62 | stats => this.stats = stats, | 61 | stats => this.stats = stats, |
63 | 62 | ||
64 | err => this.notificationsService.error('Error', err.text) | 63 | err => this.notificationsService.error('Error', err.text) |
65 | ); | 64 | ) |
66 | } | 65 | } |
67 | 66 | ||
68 | private runIntervals() { | 67 | private runIntervals () { |
69 | Object.keys(this.intervals).forEach(requestSchedulerName => { | 68 | Object.keys(this.intervals).forEach(requestSchedulerName => { |
70 | this.intervals[requestSchedulerName] = window.setInterval(() => { | 69 | this.intervals[requestSchedulerName] = window.setInterval(() => { |
71 | const stats = this.stats[requestSchedulerName]; | 70 | const stats = this.stats[requestSchedulerName] |
72 | 71 | ||
73 | stats.remainingMilliSeconds -= 1000; | 72 | stats.remainingMilliSeconds -= 1000 |
74 | 73 | ||
75 | if (stats.remainingMilliSeconds <= 0) { | 74 | if (stats.remainingMilliSeconds <= 0) { |
76 | this.timeouts[requestSchedulerName] = window.setTimeout(() => this.getStats(), stats.remainingMilliSeconds + 100); | 75 | this.timeouts[requestSchedulerName] = window.setTimeout(() => this.getStats(), stats.remainingMilliSeconds + 100) |
77 | } | 76 | } |
78 | }, 1000); | 77 | }, 1000) |
79 | }); | 78 | }) |
80 | } | 79 | } |
81 | |||
82 | |||
83 | } | 80 | } |