diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-17 11:28:11 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-17 11:28:11 +0200 |
commit | 154898b0b7bc1af41fc5a94974e338a3590c90f3 (patch) | |
tree | 5fb90f66da7587aed53c99ac1884c7acd0c1f7ca /client/src/app/+admin | |
parent | df98563e2104b82b119c00a3cd83cd0dc1242d25 (diff) | |
download | PeerTube-154898b0b7bc1af41fc5a94974e338a3590c90f3.tar.gz PeerTube-154898b0b7bc1af41fc5a94974e338a3590c90f3.tar.zst PeerTube-154898b0b7bc1af41fc5a94974e338a3590c90f3.zip |
Share models between server and client
Diffstat (limited to 'client/src/app/+admin')
-rw-r--r-- | client/src/app/+admin/friends/friend-list/friend-list.component.ts | 2 | ||||
-rw-r--r-- | client/src/app/+admin/friends/shared/friend.model.ts | 7 | ||||
-rw-r--r-- | client/src/app/+admin/friends/shared/friend.service.ts | 1 | ||||
-rw-r--r-- | client/src/app/+admin/requests/request-stats/request-stats.component.ts | 11 | ||||
-rw-r--r-- | client/src/app/+admin/requests/shared/index.ts | 2 | ||||
-rw-r--r-- | client/src/app/+admin/requests/shared/request-stats-attributes.model.ts (renamed from client/src/app/+admin/requests/shared/request-stats.model.ts) | 4 | ||||
-rw-r--r-- | client/src/app/+admin/requests/shared/request.service.ts | 9 | ||||
-rw-r--r-- | client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts | 3 |
8 files changed, 16 insertions, 23 deletions
diff --git a/client/src/app/+admin/friends/friend-list/friend-list.component.ts b/client/src/app/+admin/friends/friend-list/friend-list.component.ts index 7bf9d2c6b..9f0256d7f 100644 --- a/client/src/app/+admin/friends/friend-list/friend-list.component.ts +++ b/client/src/app/+admin/friends/friend-list/friend-list.component.ts | |||
@@ -5,7 +5,7 @@ import { ServerDataSource } from 'ng2-smart-table' | |||
5 | 5 | ||
6 | import { ConfirmService } from '../../../core' | 6 | import { ConfirmService } from '../../../core' |
7 | import { Utils } from '../../../shared' | 7 | import { Utils } from '../../../shared' |
8 | import { Friend, FriendService } from '../shared' | 8 | import { FriendService } from '../shared' |
9 | 9 | ||
10 | @Component({ | 10 | @Component({ |
11 | selector: 'my-friend-list', | 11 | selector: 'my-friend-list', |
diff --git a/client/src/app/+admin/friends/shared/friend.model.ts b/client/src/app/+admin/friends/shared/friend.model.ts deleted file mode 100644 index 6950405b9..000000000 --- a/client/src/app/+admin/friends/shared/friend.model.ts +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | export interface Friend { | ||
2 | id: string | ||
3 | host: string | ||
4 | score: number | ||
5 | email: string | ||
6 | createdAt: Date | ||
7 | } | ||
diff --git a/client/src/app/+admin/friends/shared/friend.service.ts b/client/src/app/+admin/friends/shared/friend.service.ts index f4ecd36ad..79de4470e 100644 --- a/client/src/app/+admin/friends/shared/friend.service.ts +++ b/client/src/app/+admin/friends/shared/friend.service.ts | |||
@@ -5,7 +5,6 @@ import 'rxjs/add/operator/map' | |||
5 | 5 | ||
6 | import { ServerDataSource } from 'ng2-smart-table' | 6 | import { ServerDataSource } from 'ng2-smart-table' |
7 | 7 | ||
8 | import { Friend } from './friend.model' | ||
9 | import { AuthHttp, RestExtractor, RestDataSource, ResultList } from '../../../shared' | 8 | import { AuthHttp, RestExtractor, RestDataSource, ResultList } from '../../../shared' |
10 | 9 | ||
11 | @Injectable() | 10 | @Injectable() |
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 cca4926cf..140aaf47e 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 | |||
@@ -2,7 +2,8 @@ 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, RequestSchedulerStatsAttributes } from '../shared' |
6 | import { RequestScheduler } from '../../../../../../shared' | ||
6 | 7 | ||
7 | @Component({ | 8 | @Component({ |
8 | selector: 'my-request-stats', | 9 | selector: 'my-request-stats', |
@@ -16,11 +17,7 @@ export class RequestStatsComponent implements OnInit, OnDestroy { | |||
16 | requestVideoQaduScheduler: 'Quick and dirty video updates request scheduler' | 17 | requestVideoQaduScheduler: 'Quick and dirty video updates request scheduler' |
17 | } | 18 | } |
18 | 19 | ||
19 | stats: { [ id: string ]: RequestStats } = { | 20 | stats: RequestScheduler |
20 | requestScheduler: null, | ||
21 | requestVideoEventScheduler: null, | ||
22 | requestVideoQaduScheduler: null | ||
23 | } | ||
24 | 21 | ||
25 | private intervals: { [ id: string ]: number } = { | 22 | private intervals: { [ id: string ]: number } = { |
26 | requestScheduler: null, | 23 | requestScheduler: null, |
@@ -67,7 +64,7 @@ export class RequestStatsComponent implements OnInit, OnDestroy { | |||
67 | private runIntervals () { | 64 | private runIntervals () { |
68 | Object.keys(this.intervals).forEach(requestSchedulerName => { | 65 | Object.keys(this.intervals).forEach(requestSchedulerName => { |
69 | this.intervals[requestSchedulerName] = window.setInterval(() => { | 66 | this.intervals[requestSchedulerName] = window.setInterval(() => { |
70 | const stats = this.stats[requestSchedulerName] | 67 | const stats: RequestSchedulerStatsAttributes = this.stats[requestSchedulerName] |
71 | 68 | ||
72 | stats.remainingMilliSeconds -= 1000 | 69 | stats.remainingMilliSeconds -= 1000 |
73 | 70 | ||
diff --git a/client/src/app/+admin/requests/shared/index.ts b/client/src/app/+admin/requests/shared/index.ts index 2442e810a..857fe9d29 100644 --- a/client/src/app/+admin/requests/shared/index.ts +++ b/client/src/app/+admin/requests/shared/index.ts | |||
@@ -1,2 +1,2 @@ | |||
1 | export * from './request-stats.model' | 1 | export * from './request-stats-attributes.model' |
2 | export * from './request.service' | 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-attributes.model.ts index 31550b5c0..394acc73d 100644 --- a/client/src/app/+admin/requests/shared/request-stats.model.ts +++ b/client/src/app/+admin/requests/shared/request-stats-attributes.model.ts | |||
@@ -1,9 +1,11 @@ | |||
1 | import { RequestSchedulerAttributes as FormatedRequestSchedulerAttributes } from '../../../../../../shared' | ||
2 | |||
1 | export interface Request { | 3 | export interface Request { |
2 | request: any | 4 | request: any |
3 | to: any | 5 | to: any |
4 | } | 6 | } |
5 | 7 | ||
6 | export class RequestStats { | 8 | export class RequestSchedulerStatsAttributes implements FormatedRequestSchedulerAttributes { |
7 | requestsLimitPods: number | 9 | requestsLimitPods: number |
8 | requestsLimitPerPod: number | 10 | requestsLimitPerPod: number |
9 | milliSecondsInterval: number | 11 | milliSecondsInterval: number |
diff --git a/client/src/app/+admin/requests/shared/request.service.ts b/client/src/app/+admin/requests/shared/request.service.ts index faa6b9383..53682b111 100644 --- a/client/src/app/+admin/requests/shared/request.service.ts +++ b/client/src/app/+admin/requests/shared/request.service.ts | |||
@@ -3,8 +3,9 @@ import { Observable } from 'rxjs/Observable' | |||
3 | import 'rxjs/add/operator/catch' | 3 | import 'rxjs/add/operator/catch' |
4 | import 'rxjs/add/operator/map' | 4 | import 'rxjs/add/operator/map' |
5 | 5 | ||
6 | import { RequestStats } from './request-stats.model' | 6 | import { RequestScheduler } from '../../../../../../shared' |
7 | import { AuthHttp, RestExtractor } from '../../../shared' | 7 | import { AuthHttp, RestExtractor } from '../../../shared' |
8 | import { RequestSchedulerStatsAttributes } from './request-stats-attributes.model' | ||
8 | 9 | ||
9 | @Injectable() | 10 | @Injectable() |
10 | export class RequestService { | 11 | export class RequestService { |
@@ -15,18 +16,18 @@ export class RequestService { | |||
15 | private restExtractor: RestExtractor | 16 | private restExtractor: RestExtractor |
16 | ) {} | 17 | ) {} |
17 | 18 | ||
18 | getStats (): Observable<{ [ id: string ]: RequestStats }> { | 19 | getStats (): Observable<RequestScheduler> { |
19 | return this.authHttp.get(RequestService.BASE_REQUEST_URL + 'stats') | 20 | return this.authHttp.get(RequestService.BASE_REQUEST_URL + 'stats') |
20 | .map(this.restExtractor.extractDataGet) | 21 | .map(this.restExtractor.extractDataGet) |
21 | .map(this.buildRequestObjects) | 22 | .map(this.buildRequestObjects) |
22 | .catch((res) => this.restExtractor.handleError(res)) | 23 | .catch((res) => this.restExtractor.handleError(res)) |
23 | } | 24 | } |
24 | 25 | ||
25 | private buildRequestObjects (data: any) { | 26 | private buildRequestObjects (data: RequestScheduler) { |
26 | const requestSchedulers = {} | 27 | const requestSchedulers = {} |
27 | 28 | ||
28 | Object.keys(data).forEach(requestSchedulerName => { | 29 | Object.keys(data).forEach(requestSchedulerName => { |
29 | requestSchedulers[requestSchedulerName] = new RequestStats(data[requestSchedulerName]) | 30 | requestSchedulers[requestSchedulerName] = new RequestSchedulerStatsAttributes(data[requestSchedulerName]) |
30 | }) | 31 | }) |
31 | 32 | ||
32 | return requestSchedulers | 33 | return requestSchedulers |
diff --git a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts index 60eaebb44..7c838fbf0 100644 --- a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts +++ b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts | |||
@@ -2,7 +2,8 @@ import { Component } from '@angular/core' | |||
2 | 2 | ||
3 | import { NotificationsService } from 'angular2-notifications' | 3 | import { NotificationsService } from 'angular2-notifications' |
4 | 4 | ||
5 | import { Utils, VideoAbuseService, VideoAbuse } from '../../../shared' | 5 | import { Utils, VideoAbuseService } from '../../../shared' |
6 | import { VideoAbuse } from '../../../../../shared' | ||
6 | 7 | ||
7 | @Component({ | 8 | @Component({ |
8 | selector: 'my-video-abuse-list', | 9 | selector: 'my-video-abuse-list', |