diff options
Diffstat (limited to 'client/src/app/+admin')
16 files changed, 7 insertions, 264 deletions
diff --git a/client/src/app/+admin/admin-routing.module.ts b/client/src/app/+admin/admin-routing.module.ts index 7262768fe..88f44a811 100644 --- a/client/src/app/+admin/admin-routing.module.ts +++ b/client/src/app/+admin/admin-routing.module.ts | |||
@@ -5,7 +5,6 @@ import { MetaGuard } from '@ngx-meta/core' | |||
5 | 5 | ||
6 | import { AdminComponent } from './admin.component' | 6 | import { AdminComponent } from './admin.component' |
7 | import { FriendsRoutes } from './friends' | 7 | import { FriendsRoutes } from './friends' |
8 | import { RequestSchedulersRoutes } from './request-schedulers' | ||
9 | import { UsersRoutes } from './users' | 8 | import { UsersRoutes } from './users' |
10 | import { VideoAbusesRoutes } from './video-abuses' | 9 | import { VideoAbusesRoutes } from './video-abuses' |
11 | import { VideoBlacklistRoutes } from './video-blacklist' | 10 | import { VideoBlacklistRoutes } from './video-blacklist' |
@@ -23,7 +22,6 @@ const adminRoutes: Routes = [ | |||
23 | pathMatch: 'full' | 22 | pathMatch: 'full' |
24 | }, | 23 | }, |
25 | ...FriendsRoutes, | 24 | ...FriendsRoutes, |
26 | ...RequestSchedulersRoutes, | ||
27 | ...UsersRoutes, | 25 | ...UsersRoutes, |
28 | ...VideoAbusesRoutes, | 26 | ...VideoAbusesRoutes, |
29 | ...VideoBlacklistRoutes | 27 | ...VideoBlacklistRoutes |
diff --git a/client/src/app/+admin/admin.module.ts b/client/src/app/+admin/admin.module.ts index 6c216e5d8..32f6c42a6 100644 --- a/client/src/app/+admin/admin.module.ts +++ b/client/src/app/+admin/admin.module.ts | |||
@@ -3,7 +3,6 @@ import { NgModule } from '@angular/core' | |||
3 | import { AdminComponent } from './admin.component' | 3 | import { AdminComponent } from './admin.component' |
4 | import { AdminRoutingModule } from './admin-routing.module' | 4 | import { AdminRoutingModule } from './admin-routing.module' |
5 | import { FriendsComponent, FriendAddComponent, FriendListComponent, FriendService } from './friends' | 5 | import { FriendsComponent, FriendAddComponent, FriendListComponent, FriendService } from './friends' |
6 | import { RequestSchedulersComponent, RequestSchedulersStatsComponent, RequestSchedulersService } from './request-schedulers' | ||
7 | import { UsersComponent, UserAddComponent, UserUpdateComponent, UserListComponent, UserService } from './users' | 6 | import { UsersComponent, UserAddComponent, UserUpdateComponent, UserListComponent, UserService } from './users' |
8 | import { VideoAbusesComponent, VideoAbuseListComponent } from './video-abuses' | 7 | import { VideoAbusesComponent, VideoAbuseListComponent } from './video-abuses' |
9 | import { VideoBlacklistComponent, VideoBlacklistListComponent } from './video-blacklist' | 8 | import { VideoBlacklistComponent, VideoBlacklistListComponent } from './video-blacklist' |
@@ -22,9 +21,6 @@ import { SharedModule } from '../shared' | |||
22 | FriendAddComponent, | 21 | FriendAddComponent, |
23 | FriendListComponent, | 22 | FriendListComponent, |
24 | 23 | ||
25 | RequestSchedulersComponent, | ||
26 | RequestSchedulersStatsComponent, | ||
27 | |||
28 | UsersComponent, | 24 | UsersComponent, |
29 | UserAddComponent, | 25 | UserAddComponent, |
30 | UserUpdateComponent, | 26 | UserUpdateComponent, |
@@ -43,7 +39,6 @@ import { SharedModule } from '../shared' | |||
43 | 39 | ||
44 | providers: [ | 40 | providers: [ |
45 | FriendService, | 41 | FriendService, |
46 | RequestSchedulersService, | ||
47 | UserService | 42 | UserService |
48 | ] | 43 | ] |
49 | }) | 44 | }) |
diff --git a/client/src/app/+admin/friends/friend-add/friend-add.component.ts b/client/src/app/+admin/friends/friend-add/friend-add.component.ts index 6580e1b88..29ed23e0c 100644 --- a/client/src/app/+admin/friends/friend-add/friend-add.component.ts +++ b/client/src/app/+admin/friends/friend-add/friend-add.component.ts | |||
@@ -91,7 +91,7 @@ export class FriendAddComponent implements OnInit { | |||
91 | res => { | 91 | res => { |
92 | if (res === false) return | 92 | if (res === false) return |
93 | 93 | ||
94 | this.friendService.makeFriends(notEmptyHosts).subscribe( | 94 | this.friendService.follow(notEmptyHosts).subscribe( |
95 | status => { | 95 | status => { |
96 | this.notificationsService.success('Success', 'Make friends request sent!') | 96 | this.notificationsService.success('Success', 'Make friends request sent!') |
97 | // Wait requests between pods | 97 | // Wait requests between pods |
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 5a1ecd280..0323ae96d 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 | |||
@@ -74,7 +74,7 @@ export class FriendListComponent extends RestTable implements OnInit { | |||
74 | } | 74 | } |
75 | 75 | ||
76 | protected loadData () { | 76 | protected loadData () { |
77 | this.friendService.getFriends(this.pagination, this.sort) | 77 | this.friendService.getFollowing(this.pagination, this.sort) |
78 | .subscribe( | 78 | .subscribe( |
79 | resultList => { | 79 | resultList => { |
80 | this.friends = resultList.data | 80 | this.friends = resultList.data |
diff --git a/client/src/app/+admin/friends/friends.routes.ts b/client/src/app/+admin/friends/friends.routes.ts index 61cfcae19..e2cb953b3 100644 --- a/client/src/app/+admin/friends/friends.routes.ts +++ b/client/src/app/+admin/friends/friends.routes.ts | |||
@@ -12,7 +12,7 @@ export const FriendsRoutes: Routes = [ | |||
12 | component: FriendsComponent, | 12 | component: FriendsComponent, |
13 | canActivate: [ UserRightGuard ], | 13 | canActivate: [ UserRightGuard ], |
14 | data: { | 14 | data: { |
15 | userRight: UserRight.MANAGE_PODS | 15 | userRight: UserRight.MANAGE_PEERTUBE_FOLLOW |
16 | }, | 16 | }, |
17 | children: [ | 17 | children: [ |
18 | { | 18 | { |
diff --git a/client/src/app/+admin/friends/shared/friend.service.ts b/client/src/app/+admin/friends/shared/friend.service.ts index a32cdcc88..083a2fce0 100644 --- a/client/src/app/+admin/friends/shared/friend.service.ts +++ b/client/src/app/+admin/friends/shared/friend.service.ts | |||
@@ -19,21 +19,21 @@ export class FriendService { | |||
19 | private restExtractor: RestExtractor | 19 | private restExtractor: RestExtractor |
20 | ) {} | 20 | ) {} |
21 | 21 | ||
22 | getFriends (pagination: RestPagination, sort: SortMeta): Observable<ResultList<Pod>> { | 22 | getFollowing (pagination: RestPagination, sort: SortMeta): Observable<ResultList<Pod>> { |
23 | let params = new HttpParams() | 23 | let params = new HttpParams() |
24 | params = this.restService.addRestGetParams(params, pagination, sort) | 24 | params = this.restService.addRestGetParams(params, pagination, sort) |
25 | 25 | ||
26 | return this.authHttp.get<ResultList<Pod>>(FriendService.BASE_FRIEND_URL, { params }) | 26 | return this.authHttp.get<ResultList<Account>>(API_URL + '/followers', { params }) |
27 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) | 27 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) |
28 | .catch(res => this.restExtractor.handleError(res)) | 28 | .catch(res => this.restExtractor.handleError(res)) |
29 | } | 29 | } |
30 | 30 | ||
31 | makeFriends (notEmptyHosts: String[]) { | 31 | follow (notEmptyHosts: String[]) { |
32 | const body = { | 32 | const body = { |
33 | hosts: notEmptyHosts | 33 | hosts: notEmptyHosts |
34 | } | 34 | } |
35 | 35 | ||
36 | return this.authHttp.post(FriendService.BASE_FRIEND_URL + 'make-friends', body) | 36 | return this.authHttp.post(API_URL + '/follow', body) |
37 | .map(this.restExtractor.extractDataBool) | 37 | .map(this.restExtractor.extractDataBool) |
38 | .catch(res => this.restExtractor.handleError(res)) | 38 | .catch(res => this.restExtractor.handleError(res)) |
39 | } | 39 | } |
diff --git a/client/src/app/+admin/request-schedulers/index.ts b/client/src/app/+admin/request-schedulers/index.ts deleted file mode 100644 index 87b72e8c7..000000000 --- a/client/src/app/+admin/request-schedulers/index.ts +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | export * from './request-schedulers-stats' | ||
2 | export * from './shared' | ||
3 | export * from './request-schedulers.component' | ||
4 | export * from './request-schedulers.routes' | ||
diff --git a/client/src/app/+admin/request-schedulers/request-schedulers-stats/index.ts b/client/src/app/+admin/request-schedulers/request-schedulers-stats/index.ts deleted file mode 100644 index a3323e6be..000000000 --- a/client/src/app/+admin/request-schedulers/request-schedulers-stats/index.ts +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | export * from './request-schedulers-stats.component' | ||
diff --git a/client/src/app/+admin/request-schedulers/request-schedulers-stats/request-schedulers-stats.component.html b/client/src/app/+admin/request-schedulers/request-schedulers-stats/request-schedulers-stats.component.html deleted file mode 100644 index 4508ab4c2..000000000 --- a/client/src/app/+admin/request-schedulers/request-schedulers-stats/request-schedulers-stats.component.html +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | <div class="row"> | ||
2 | <div class="content-padding"> | ||
3 | |||
4 | <h3>Requests stats</h3> | ||
5 | |||
6 | <ng-template [ngIf]="stats"> | ||
7 | <div *ngFor="let requestSchedulerName of statsTitles | keys" class="col-lg-4 col-md-12"> | ||
8 | <div class="panel panel-default" *ngIf="stats[requestSchedulerName] !== null"> | ||
9 | <div class="panel-heading">{{ statsTitles[requestSchedulerName] }}</div> | ||
10 | |||
11 | <div class="panel-body"> | ||
12 | <div class="requests-general"> | ||
13 | <div> | ||
14 | <span class="label-description">Remaining requests:</span> | ||
15 | {{ stats[requestSchedulerName].totalRequests }} | ||
16 | </div> | ||
17 | |||
18 | <div> | ||
19 | <span class="label-description">Interval seconds between requests:</span> | ||
20 | {{ stats[requestSchedulerName].secondsInterval }} | ||
21 | </div> | ||
22 | |||
23 | <div> | ||
24 | <span class="label-description">Remaining time before the scheduled request:</span> | ||
25 | {{ stats[requestSchedulerName].remainingSeconds }} | ||
26 | </div> | ||
27 | </div> | ||
28 | |||
29 | <div class="requests-limit"> | ||
30 | <div> | ||
31 | <span class="label-description">Maximum number of different pods for a scheduled request:</span> | ||
32 | {{ stats[requestSchedulerName].requestsLimitPods }} | ||
33 | </div> | ||
34 | |||
35 | <div> | ||
36 | <span class="label-description">Maximum number of requests per pod for a scheduled request:</span> | ||
37 | {{ stats[requestSchedulerName].requestsLimitPerPod }} | ||
38 | </div> | ||
39 | </div> | ||
40 | </div> | ||
41 | </div> | ||
42 | </div> | ||
43 | </ng-template> | ||
44 | |||
45 | </div> | ||
46 | </div> | ||
diff --git a/client/src/app/+admin/request-schedulers/request-schedulers-stats/request-schedulers-stats.component.scss b/client/src/app/+admin/request-schedulers/request-schedulers-stats/request-schedulers-stats.component.scss deleted file mode 100644 index b2c413259..000000000 --- a/client/src/app/+admin/request-schedulers/request-schedulers-stats/request-schedulers-stats.component.scss +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | .label-description { | ||
2 | font-weight: bold; | ||
3 | color: black; | ||
4 | } | ||
5 | |||
6 | .requests-limit { | ||
7 | margin-top: 20px; | ||
8 | } | ||
diff --git a/client/src/app/+admin/request-schedulers/request-schedulers-stats/request-schedulers-stats.component.ts b/client/src/app/+admin/request-schedulers/request-schedulers-stats/request-schedulers-stats.component.ts deleted file mode 100644 index 1654827ab..000000000 --- a/client/src/app/+admin/request-schedulers/request-schedulers-stats/request-schedulers-stats.component.ts +++ /dev/null | |||
@@ -1,77 +0,0 @@ | |||
1 | import { Component, OnInit, OnDestroy } from '@angular/core' | ||
2 | |||
3 | import { NotificationsService } from 'angular2-notifications' | ||
4 | |||
5 | import { RequestSchedulersService, RequestSchedulerStatsAttributes } from '../shared' | ||
6 | import { RequestSchedulerStats } from '../../../../../../shared' | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-request-schedulers-stats', | ||
10 | templateUrl: './request-schedulers-stats.component.html', | ||
11 | styleUrls: [ './request-schedulers-stats.component.scss' ] | ||
12 | }) | ||
13 | export class RequestSchedulersStatsComponent implements OnInit, OnDestroy { | ||
14 | statsTitles = { | ||
15 | requestScheduler: 'Basic request scheduler', | ||
16 | requestVideoEventScheduler: 'Video events request scheduler', | ||
17 | requestVideoQaduScheduler: 'Quick and dirty video updates request scheduler' | ||
18 | } | ||
19 | |||
20 | stats: RequestSchedulerStats | ||
21 | |||
22 | private intervals: { [ id: string ]: number } = { | ||
23 | requestScheduler: null, | ||
24 | requestVideoEventScheduler: null, | ||
25 | requestVideoQaduScheduler: null | ||
26 | } | ||
27 | |||
28 | private timeouts: { [ id: string ]: number } = { | ||
29 | requestScheduler: null, | ||
30 | requestVideoEventScheduler: null, | ||
31 | requestVideoQaduScheduler: null | ||
32 | } | ||
33 | |||
34 | constructor ( | ||
35 | private notificationsService: NotificationsService, | ||
36 | private requestService: RequestSchedulersService | ||
37 | ) { } | ||
38 | |||
39 | ngOnInit () { | ||
40 | this.getStats() | ||
41 | this.runIntervals() | ||
42 | } | ||
43 | |||
44 | ngOnDestroy () { | ||
45 | Object.keys(this.stats).forEach(requestSchedulerName => { | ||
46 | if (this.intervals[requestSchedulerName] !== null) { | ||
47 | window.clearInterval(this.intervals[requestSchedulerName]) | ||
48 | } | ||
49 | |||
50 | if (this.timeouts[requestSchedulerName] !== null) { | ||
51 | window.clearTimeout(this.timeouts[requestSchedulerName]) | ||
52 | } | ||
53 | }) | ||
54 | } | ||
55 | |||
56 | getStats () { | ||
57 | this.requestService.getStats().subscribe( | ||
58 | stats => this.stats = stats, | ||
59 | |||
60 | err => this.notificationsService.error('Error', err.message) | ||
61 | ) | ||
62 | } | ||
63 | |||
64 | private runIntervals () { | ||
65 | Object.keys(this.intervals).forEach(requestSchedulerName => { | ||
66 | this.intervals[requestSchedulerName] = window.setInterval(() => { | ||
67 | const stats: RequestSchedulerStatsAttributes = this.stats[requestSchedulerName] | ||
68 | |||
69 | stats.remainingMilliSeconds -= 1000 | ||
70 | |||
71 | if (stats.remainingMilliSeconds <= 0) { | ||
72 | this.timeouts[requestSchedulerName] = window.setTimeout(() => this.getStats(), stats.remainingMilliSeconds + 100) | ||
73 | } | ||
74 | }, 1000) | ||
75 | }) | ||
76 | } | ||
77 | } | ||
diff --git a/client/src/app/+admin/request-schedulers/request-schedulers.component.ts b/client/src/app/+admin/request-schedulers/request-schedulers.component.ts deleted file mode 100644 index 5444d6ea5..000000000 --- a/client/src/app/+admin/request-schedulers/request-schedulers.component.ts +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | import { Component } from '@angular/core' | ||
2 | |||
3 | @Component({ | ||
4 | template: '<router-outlet></router-outlet>' | ||
5 | }) | ||
6 | export class RequestSchedulersComponent { | ||
7 | } | ||
diff --git a/client/src/app/+admin/request-schedulers/request-schedulers.routes.ts b/client/src/app/+admin/request-schedulers/request-schedulers.routes.ts deleted file mode 100644 index c2564de15..000000000 --- a/client/src/app/+admin/request-schedulers/request-schedulers.routes.ts +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | import { Routes } from '@angular/router' | ||
2 | |||
3 | import { UserRightGuard } from '../../core' | ||
4 | import { UserRight } from '../../../../../shared' | ||
5 | import { RequestSchedulersComponent } from './request-schedulers.component' | ||
6 | import { RequestSchedulersStatsComponent } from './request-schedulers-stats' | ||
7 | |||
8 | export const RequestSchedulersRoutes: Routes = [ | ||
9 | { | ||
10 | path: 'requests', | ||
11 | component: RequestSchedulersComponent, | ||
12 | canActivate: [ UserRightGuard ], | ||
13 | data: { | ||
14 | userRight: UserRight.MANAGE_REQUEST_SCHEDULERS | ||
15 | }, | ||
16 | children: [ | ||
17 | { | ||
18 | path: '', | ||
19 | redirectTo: 'stats', | ||
20 | pathMatch: 'full' | ||
21 | }, | ||
22 | { | ||
23 | path: 'stats', | ||
24 | component: RequestSchedulersStatsComponent, | ||
25 | data: { | ||
26 | meta: { | ||
27 | title: 'Request stats' | ||
28 | } | ||
29 | } | ||
30 | } | ||
31 | ] | ||
32 | } | ||
33 | ] | ||
diff --git a/client/src/app/+admin/request-schedulers/shared/index.ts b/client/src/app/+admin/request-schedulers/shared/index.ts deleted file mode 100644 index 1a0174409..000000000 --- a/client/src/app/+admin/request-schedulers/shared/index.ts +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | export * from './request-schedulers-stats-attributes.model' | ||
2 | export * from './request-schedulers.service' | ||
diff --git a/client/src/app/+admin/request-schedulers/shared/request-schedulers-stats-attributes.model.ts b/client/src/app/+admin/request-schedulers/shared/request-schedulers-stats-attributes.model.ts deleted file mode 100644 index c4abf3d4d..000000000 --- a/client/src/app/+admin/request-schedulers/shared/request-schedulers-stats-attributes.model.ts +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | import { RequestSchedulerStatsAttributes as FormattedRequestSchedulerStatsAttributes } from '../../../../../../shared' | ||
2 | |||
3 | export interface Request { | ||
4 | request: any | ||
5 | to: any | ||
6 | } | ||
7 | |||
8 | export class RequestSchedulerStatsAttributes implements FormattedRequestSchedulerStatsAttributes { | ||
9 | requestsLimitPods: number | ||
10 | requestsLimitPerPod: number | ||
11 | milliSecondsInterval: number | ||
12 | remainingMilliSeconds: number | ||
13 | totalRequests: number | ||
14 | |||
15 | constructor (hash: { | ||
16 | requestsLimitPods: number, | ||
17 | requestsLimitPerPod: number, | ||
18 | milliSecondsInterval: number, | ||
19 | remainingMilliSeconds: number, | ||
20 | totalRequests: number | ||
21 | }) { | ||
22 | this.requestsLimitPods = hash.requestsLimitPods | ||
23 | this.requestsLimitPerPod = hash.requestsLimitPerPod | ||
24 | this.milliSecondsInterval = hash.milliSecondsInterval | ||
25 | this.remainingMilliSeconds = hash.remainingMilliSeconds | ||
26 | this.totalRequests = hash.totalRequests | ||
27 | } | ||
28 | |||
29 | get remainingSeconds () { | ||
30 | return Math.floor(this.remainingMilliSeconds / 1000) | ||
31 | } | ||
32 | |||
33 | get secondsInterva () { | ||
34 | return Math.floor(this.milliSecondsInterval / 1000) | ||
35 | } | ||
36 | |||
37 | } | ||
diff --git a/client/src/app/+admin/request-schedulers/shared/request-schedulers.service.ts b/client/src/app/+admin/request-schedulers/shared/request-schedulers.service.ts deleted file mode 100644 index 44d9cbc3e..000000000 --- a/client/src/app/+admin/request-schedulers/shared/request-schedulers.service.ts +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | import { Injectable } from '@angular/core' | ||
2 | import { HttpClient } from '@angular/common/http' | ||
3 | import { Observable } from 'rxjs/Observable' | ||
4 | import 'rxjs/add/operator/catch' | ||
5 | import 'rxjs/add/operator/map' | ||
6 | |||
7 | import { RequestSchedulerStats } from '../../../../../../shared' | ||
8 | import { RestExtractor } from '../../../shared' | ||
9 | import { RequestSchedulerStatsAttributes } from './request-schedulers-stats-attributes.model' | ||
10 | |||
11 | @Injectable() | ||
12 | export class RequestSchedulersService { | ||
13 | private static BASE_REQUEST_URL = API_URL + '/api/v1/request-schedulers/' | ||
14 | |||
15 | constructor ( | ||
16 | private authHttp: HttpClient, | ||
17 | private restExtractor: RestExtractor | ||
18 | ) {} | ||
19 | |||
20 | getStats () { | ||
21 | return this.authHttp.get<RequestSchedulerStats>(RequestSchedulersService.BASE_REQUEST_URL + 'stats') | ||
22 | .map(res => this.buildRequestObjects(res)) | ||
23 | .catch(res => this.restExtractor.handleError(res)) | ||
24 | } | ||
25 | |||
26 | private buildRequestObjects (data: RequestSchedulerStats) { | ||
27 | const requestSchedulers: { [ id: string ]: RequestSchedulerStatsAttributes } = {} | ||
28 | |||
29 | Object.keys(data).forEach(requestSchedulerName => { | ||
30 | requestSchedulers[requestSchedulerName] = new RequestSchedulerStatsAttributes(data[requestSchedulerName]) | ||
31 | }) | ||
32 | |||
33 | return requestSchedulers | ||
34 | } | ||
35 | } | ||