diff options
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.ts | 48 |
1 files changed, 0 insertions, 48 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 deleted file mode 100644 index 23b836779..000000000 --- a/client/src/app/admin/requests/request-stats/request-stats.component.ts +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | import { setInterval } from 'timers' | ||
2 | import { Component, OnInit, OnDestroy } from '@angular/core'; | ||
3 | |||
4 | import { RequestService, RequestStats } from '../shared'; | ||
5 | |||
6 | @Component({ | ||
7 | selector: 'my-request-stats', | ||
8 | templateUrl: './request-stats.component.html', | ||
9 | styleUrls: [ './request-stats.component.scss' ] | ||
10 | }) | ||
11 | export class RequestStatsComponent implements OnInit, OnDestroy { | ||
12 | stats: RequestStats = null; | ||
13 | |||
14 | private interval: NodeJS.Timer = null; | ||
15 | |||
16 | constructor(private requestService: RequestService) { } | ||
17 | |||
18 | ngOnInit() { | ||
19 | this.getStats(); | ||
20 | this.runInterval(); | ||
21 | } | ||
22 | |||
23 | ngOnDestroy() { | ||
24 | if (this.stats !== null && this.stats.secondsInterval !== null) { | ||
25 | clearInterval(this.interval); | ||
26 | } | ||
27 | } | ||
28 | |||
29 | getStats() { | ||
30 | this.requestService.getStats().subscribe( | ||
31 | stats => this.stats = stats, | ||
32 | |||
33 | err => alert(err.text) | ||
34 | ); | ||
35 | } | ||
36 | |||
37 | private runInterval() { | ||
38 | this.interval = setInterval(() => { | ||
39 | this.stats.remainingMilliSeconds -= 1000; | ||
40 | |||
41 | if (this.stats.remainingMilliSeconds <= 0) { | ||
42 | setTimeout(() => this.getStats(), this.stats.remainingMilliSeconds + 100); | ||
43 | } | ||
44 | }, 1000); | ||
45 | } | ||
46 | |||
47 | |||
48 | } | ||