diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-01-23 22:32:43 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-01-23 22:32:43 +0100 |
commit | b99290b1d5d736083513fb8f66e91f61bfe07e0b (patch) | |
tree | e0e7fa738ee661a267f5330db35bc46d295f945f /client/src/app/admin/requests | |
parent | 11ac88de40215783835cf6e6259ff0f6cee258dd (diff) | |
download | PeerTube-b99290b1d5d736083513fb8f66e91f61bfe07e0b.tar.gz PeerTube-b99290b1d5d736083513fb8f66e91f61bfe07e0b.tar.zst PeerTube-b99290b1d5d736083513fb8f66e91f61bfe07e0b.zip |
Client: lazy load admin area
Diffstat (limited to 'client/src/app/admin/requests')
10 files changed, 0 insertions, 201 deletions
diff --git a/client/src/app/admin/requests/index.ts b/client/src/app/admin/requests/index.ts deleted file mode 100644 index 236a9ee8f..000000000 --- a/client/src/app/admin/requests/index.ts +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | export * from './request-stats'; | ||
2 | export * from './shared'; | ||
3 | export * from './requests.component'; | ||
4 | export * 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 deleted file mode 100644 index be3a66f77..000000000 --- a/client/src/app/admin/requests/request-stats/index.ts +++ /dev/null | |||
@@ -1 +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 deleted file mode 100644 index 9dbed1739..000000000 --- a/client/src/app/admin/requests/request-stats/request-stats.component.html +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | <h3>Requests stats</h3> | ||
2 | |||
3 | <div *ngIf="stats !== null"> | ||
4 | <div class="requests-general"> | ||
5 | <div> | ||
6 | <span class="label-description">Remaining requests:</span> | ||
7 | {{ stats.totalRequests }} | ||
8 | </div> | ||
9 | |||
10 | <div> | ||
11 | <span class="label-description">Interval seconds between requests:</span> | ||
12 | {{ stats.secondsInterval }} | ||
13 | </div> | ||
14 | |||
15 | <div> | ||
16 | <span class="label-description">Remaining time before the scheduled request:</span> | ||
17 | {{ stats.remainingSeconds }} | ||
18 | </div> | ||
19 | </div> | ||
20 | |||
21 | <div class="requests-limit"> | ||
22 | <div> | ||
23 | <span class="label-description">Maximum number of different pods for a scheduled request:</span> | ||
24 | {{ stats.requestsLimitPods }} | ||
25 | </div> | ||
26 | |||
27 | <div> | ||
28 | <span class="label-description">Maximum number of requests per pod for a scheduled request:</span> | ||
29 | {{ stats.requestsLimitPerPod }} | ||
30 | </div> | ||
31 | </div> | ||
32 | |||
33 | </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 deleted file mode 100644 index 9c68fba99..000000000 --- a/client/src/app/admin/requests/request-stats/request-stats.component.scss +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | .label-description { | ||
2 | display: inline-block; | ||
3 | font-weight: bold; | ||
4 | color: black; | ||
5 | } | ||
6 | |||
7 | .requests-general { | ||
8 | .label-description { | ||
9 | width: 320px; | ||
10 | } | ||
11 | } | ||
12 | |||
13 | .requests-limit { | ||
14 | margin-top: 20px; | ||
15 | |||
16 | .label-description { | ||
17 | width: 430px; | ||
18 | } | ||
19 | } | ||
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 | } | ||
diff --git a/client/src/app/admin/requests/requests.component.ts b/client/src/app/admin/requests/requests.component.ts deleted file mode 100644 index 471112b45..000000000 --- a/client/src/app/admin/requests/requests.component.ts +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | import { Component } from '@angular/core'; | ||
2 | |||
3 | @Component({ | ||
4 | template: '<router-outlet></router-outlet>' | ||
5 | }) | ||
6 | |||
7 | export class RequestsComponent { | ||
8 | } | ||
diff --git a/client/src/app/admin/requests/requests.routes.ts b/client/src/app/admin/requests/requests.routes.ts deleted file mode 100644 index 70fbf41c3..000000000 --- a/client/src/app/admin/requests/requests.routes.ts +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | import { Routes } from '@angular/router'; | ||
2 | |||
3 | import { RequestsComponent } from './requests.component'; | ||
4 | import { RequestStatsComponent } from './request-stats'; | ||
5 | |||
6 | export 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 | data: { | ||
20 | meta: { | ||
21 | titleSuffix: ' - Request stats' | ||
22 | } | ||
23 | } | ||
24 | } | ||
25 | ] | ||
26 | } | ||
27 | ]; | ||
diff --git a/client/src/app/admin/requests/shared/index.ts b/client/src/app/admin/requests/shared/index.ts deleted file mode 100644 index 32ab5767b..000000000 --- a/client/src/app/admin/requests/shared/index.ts +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
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 deleted file mode 100644 index f658c4682..000000000 --- a/client/src/app/admin/requests/shared/request-stats.model.ts +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
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 deleted file mode 100644 index 55b28bcfc..000000000 --- a/client/src/app/admin/requests/shared/request.service.ts +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
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 | } | ||