aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-17 11:28:11 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-17 11:28:11 +0200
commit154898b0b7bc1af41fc5a94974e338a3590c90f3 (patch)
tree5fb90f66da7587aed53c99ac1884c7acd0c1f7ca /client/src/app/+admin
parentdf98563e2104b82b119c00a3cd83cd0dc1242d25 (diff)
downloadPeerTube-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.ts2
-rw-r--r--client/src/app/+admin/friends/shared/friend.model.ts7
-rw-r--r--client/src/app/+admin/friends/shared/friend.service.ts1
-rw-r--r--client/src/app/+admin/requests/request-stats/request-stats.component.ts11
-rw-r--r--client/src/app/+admin/requests/shared/index.ts2
-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.ts9
-rw-r--r--client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts3
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
6import { ConfirmService } from '../../../core' 6import { ConfirmService } from '../../../core'
7import { Utils } from '../../../shared' 7import { Utils } from '../../../shared'
8import { Friend, FriendService } from '../shared' 8import { 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 @@
1export 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
6import { ServerDataSource } from 'ng2-smart-table' 6import { ServerDataSource } from 'ng2-smart-table'
7 7
8import { Friend } from './friend.model'
9import { AuthHttp, RestExtractor, RestDataSource, ResultList } from '../../../shared' 8import { 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
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4 4
5import { RequestService, RequestStats } from '../shared' 5import { RequestService, RequestSchedulerStatsAttributes } from '../shared'
6import { 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 @@
1export * from './request-stats.model' 1export * from './request-stats-attributes.model'
2export * from './request.service' 2export * 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 @@
1import { RequestSchedulerAttributes as FormatedRequestSchedulerAttributes } from '../../../../../../shared'
2
1export interface Request { 3export interface Request {
2 request: any 4 request: any
3 to: any 5 to: any
4} 6}
5 7
6export class RequestStats { 8export 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'
3import 'rxjs/add/operator/catch' 3import 'rxjs/add/operator/catch'
4import 'rxjs/add/operator/map' 4import 'rxjs/add/operator/map'
5 5
6import { RequestStats } from './request-stats.model' 6import { RequestScheduler } from '../../../../../../shared'
7import { AuthHttp, RestExtractor } from '../../../shared' 7import { AuthHttp, RestExtractor } from '../../../shared'
8import { RequestSchedulerStatsAttributes } from './request-stats-attributes.model'
8 9
9@Injectable() 10@Injectable()
10export class RequestService { 11export 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
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4 4
5import { Utils, VideoAbuseService, VideoAbuse } from '../../../shared' 5import { Utils, VideoAbuseService } from '../../../shared'
6import { VideoAbuse } from '../../../../../shared'
6 7
7@Component({ 8@Component({
8 selector: 'my-video-abuse-list', 9 selector: 'my-video-abuse-list',