aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-10 10:02:18 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-10 10:18:16 +0200
commit35bf0c83c80f59ca79f4b84fac8700f17adeb22d (patch)
treea9b2106096d6ba04d7219051b17fd32cfbe6a885 /client/src/app/+admin
parent769d332177a5b02d5c2ffc134687d3b4ed65bae9 (diff)
downloadPeerTube-35bf0c83c80f59ca79f4b84fac8700f17adeb22d.tar.gz
PeerTube-35bf0c83c80f59ca79f4b84fac8700f17adeb22d.tar.zst
PeerTube-35bf0c83c80f59ca79f4b84fac8700f17adeb22d.zip
Video blacklist refractoring
Diffstat (limited to 'client/src/app/+admin')
-rw-r--r--client/src/app/+admin/admin-routing.module.ts4
-rw-r--r--client/src/app/+admin/admin.component.ts1
-rw-r--r--client/src/app/+admin/admin.module.ts9
-rw-r--r--client/src/app/+admin/blacklist/blacklist-list/index.ts1
-rw-r--r--client/src/app/+admin/blacklist/blacklist.routes.ts27
-rw-r--r--client/src/app/+admin/blacklist/index.ts4
-rw-r--r--client/src/app/+admin/blacklist/shared/blacklist.service.ts44
-rw-r--r--client/src/app/+admin/blacklist/shared/index.ts1
-rw-r--r--client/src/app/+admin/video-blacklist/index.ts3
-rw-r--r--client/src/app/+admin/video-blacklist/video-blacklist-list/index.ts1
-rw-r--r--client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.html (renamed from client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.html)4
-rw-r--r--client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts (renamed from client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.ts)15
-rw-r--r--client/src/app/+admin/video-blacklist/video-blacklist.component.ts (renamed from client/src/app/+admin/blacklist/blacklist.component.ts)3
-rw-r--r--client/src/app/+admin/video-blacklist/video-blacklist.routes.ts27
14 files changed, 47 insertions, 97 deletions
diff --git a/client/src/app/+admin/admin-routing.module.ts b/client/src/app/+admin/admin-routing.module.ts
index 0cd3e54c2..c3e4895ac 100644
--- a/client/src/app/+admin/admin-routing.module.ts
+++ b/client/src/app/+admin/admin-routing.module.ts
@@ -9,7 +9,7 @@ import { RequestSchedulersRoutes } from './request-schedulers'
9import { UsersRoutes } from './users' 9import { UsersRoutes } from './users'
10import { VideoAbusesRoutes } from './video-abuses' 10import { VideoAbusesRoutes } from './video-abuses'
11import { AdminGuard } from './admin-guard.service' 11import { AdminGuard } from './admin-guard.service'
12import { BlacklistRoutes } from './blacklist' 12import { VideoBlacklistRoutes } from './video-blacklist'
13 13
14const adminRoutes: Routes = [ 14const adminRoutes: Routes = [
15 { 15 {
@@ -27,7 +27,7 @@ const adminRoutes: Routes = [
27 ...RequestSchedulersRoutes, 27 ...RequestSchedulersRoutes,
28 ...UsersRoutes, 28 ...UsersRoutes,
29 ...VideoAbusesRoutes, 29 ...VideoAbusesRoutes,
30 ...BlacklistRoutes 30 ...VideoBlacklistRoutes
31 ] 31 ]
32 } 32 }
33] 33]
diff --git a/client/src/app/+admin/admin.component.ts b/client/src/app/+admin/admin.component.ts
index 93ec216bf..ecd62ee61 100644
--- a/client/src/app/+admin/admin.component.ts
+++ b/client/src/app/+admin/admin.component.ts
@@ -3,6 +3,5 @@ import { Component } from '@angular/core'
3@Component({ 3@Component({
4 template: '<router-outlet></router-outlet>' 4 template: '<router-outlet></router-outlet>'
5}) 5})
6
7export class AdminComponent { 6export class AdminComponent {
8} 7}
diff --git a/client/src/app/+admin/admin.module.ts b/client/src/app/+admin/admin.module.ts
index c2dd60774..f29c501b0 100644
--- a/client/src/app/+admin/admin.module.ts
+++ b/client/src/app/+admin/admin.module.ts
@@ -6,7 +6,7 @@ import { FriendsComponent, FriendAddComponent, FriendListComponent, FriendServic
6import { RequestSchedulersComponent, RequestSchedulersStatsComponent, RequestSchedulersService } from './request-schedulers' 6import { RequestSchedulersComponent, RequestSchedulersStatsComponent, RequestSchedulersService } from './request-schedulers'
7import { UsersComponent, UserAddComponent, UserUpdateComponent, UserListComponent, UserService } from './users' 7import { UsersComponent, UserAddComponent, UserUpdateComponent, UserListComponent, UserService } from './users'
8import { VideoAbusesComponent, VideoAbuseListComponent } from './video-abuses' 8import { VideoAbusesComponent, VideoAbuseListComponent } from './video-abuses'
9import { BlacklistComponent, BlacklistListComponent, BlacklistService } from './blacklist' 9import { VideoBlacklistComponent, VideoBlacklistListComponent } from './video-blacklist'
10import { SharedModule } from '../shared' 10import { SharedModule } from '../shared'
11import { AdminGuard } from './admin-guard.service' 11import { AdminGuard } from './admin-guard.service'
12 12
@@ -31,8 +31,8 @@ import { AdminGuard } from './admin-guard.service'
31 UserUpdateComponent, 31 UserUpdateComponent,
32 UserListComponent, 32 UserListComponent,
33 33
34 BlacklistComponent, 34 VideoBlacklistComponent,
35 BlacklistListComponent, 35 VideoBlacklistListComponent,
36 36
37 VideoAbusesComponent, 37 VideoAbusesComponent,
38 VideoAbuseListComponent 38 VideoAbuseListComponent
@@ -46,8 +46,7 @@ import { AdminGuard } from './admin-guard.service'
46 FriendService, 46 FriendService,
47 RequestSchedulersService, 47 RequestSchedulersService,
48 UserService, 48 UserService,
49 AdminGuard, 49 AdminGuard
50 BlacklistService
51 ] 50 ]
52}) 51})
53export class AdminModule { } 52export class AdminModule { }
diff --git a/client/src/app/+admin/blacklist/blacklist-list/index.ts b/client/src/app/+admin/blacklist/blacklist-list/index.ts
deleted file mode 100644
index 45f60a2b9..000000000
--- a/client/src/app/+admin/blacklist/blacklist-list/index.ts
+++ /dev/null
@@ -1 +0,0 @@
1export * from './blacklist-list.component'
diff --git a/client/src/app/+admin/blacklist/blacklist.routes.ts b/client/src/app/+admin/blacklist/blacklist.routes.ts
deleted file mode 100644
index 780347ca8..000000000
--- a/client/src/app/+admin/blacklist/blacklist.routes.ts
+++ /dev/null
@@ -1,27 +0,0 @@
1import { Routes } from '@angular/router'
2
3import { BlacklistComponent } from './blacklist.component'
4import { BlacklistListComponent } from './blacklist-list'
5
6export const BlacklistRoutes: Routes = [
7 {
8 path: 'blacklist',
9 component: BlacklistComponent,
10 children: [
11 {
12 path: '',
13 redirectTo: 'list',
14 pathMatch: 'full'
15 },
16 {
17 path: 'list',
18 component: BlacklistListComponent,
19 data: {
20 meta: {
21 title: 'Blacklisted videos'
22 }
23 }
24 }
25 ]
26 }
27]
diff --git a/client/src/app/+admin/blacklist/index.ts b/client/src/app/+admin/blacklist/index.ts
deleted file mode 100644
index 675dc1263..000000000
--- a/client/src/app/+admin/blacklist/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
1export * from './shared'
2export * from './blacklist-list'
3export * from './blacklist.component'
4export * from './blacklist.routes'
diff --git a/client/src/app/+admin/blacklist/shared/blacklist.service.ts b/client/src/app/+admin/blacklist/shared/blacklist.service.ts
deleted file mode 100644
index ee2bf82e9..000000000
--- a/client/src/app/+admin/blacklist/shared/blacklist.service.ts
+++ /dev/null
@@ -1,44 +0,0 @@
1import { Injectable } from '@angular/core'
2import { HttpClient, HttpParams } from '@angular/common/http'
3import { Observable } from 'rxjs/Observable'
4import 'rxjs/add/operator/catch'
5import 'rxjs/add/operator/map'
6
7import { SortMeta } from 'primeng/components/common/sortmeta'
8
9import { RestExtractor, RestPagination, RestService } from '../../../shared'
10import { Utils } from '../../../shared'
11import { BlacklistedVideo, ResultList } from '../../../../../../shared'
12
13@Injectable()
14export class BlacklistService {
15 private static BASE_BLACKLISTS_URL = API_URL + '/api/v1/blacklist/'
16
17 constructor (
18 private authHttp: HttpClient,
19 private restService: RestService,
20 private restExtractor: RestExtractor
21 ) {}
22
23 getBlacklist (pagination: RestPagination, sort: SortMeta): Observable<ResultList<BlacklistedVideo>> {
24 let params = new HttpParams()
25 params = this.restService.addRestGetParams(params, pagination, sort)
26
27 return this.authHttp.get<ResultList<BlacklistedVideo>>(BlacklistService.BASE_BLACKLISTS_URL, { params })
28 .map(res => this.restExtractor.convertResultListDateToHuman(res))
29 .map(res => this.restExtractor.applyToResultListData(res, this.formatBlacklistedVideo.bind(this)))
30 .catch(res => this.restExtractor.handleError(res))
31 }
32
33 removeVideoFromBlacklist (entry: BlacklistedVideo) {
34 return this.authHttp.delete(BlacklistService.BASE_BLACKLISTS_URL + entry.id)
35 .map(this.restExtractor.extractDataBool)
36 .catch(res => this.restExtractor.handleError(res))
37 }
38
39 private formatBlacklistedVideo (blacklistedVideo: BlacklistedVideo) {
40 return Object.assign(blacklistedVideo, {
41 createdAt: Utils.dateToHuman(blacklistedVideo.createdAt)
42 })
43 }
44}
diff --git a/client/src/app/+admin/blacklist/shared/index.ts b/client/src/app/+admin/blacklist/shared/index.ts
deleted file mode 100644
index ad22e2d51..000000000
--- a/client/src/app/+admin/blacklist/shared/index.ts
+++ /dev/null
@@ -1 +0,0 @@
1export * from './blacklist.service'
diff --git a/client/src/app/+admin/video-blacklist/index.ts b/client/src/app/+admin/video-blacklist/index.ts
new file mode 100644
index 000000000..a5451e2e1
--- /dev/null
+++ b/client/src/app/+admin/video-blacklist/index.ts
@@ -0,0 +1,3 @@
1export * from './video-blacklist-list'
2export * from './video-blacklist.component'
3export * from './video-blacklist.routes'
diff --git a/client/src/app/+admin/video-blacklist/video-blacklist-list/index.ts b/client/src/app/+admin/video-blacklist/video-blacklist-list/index.ts
new file mode 100644
index 000000000..4daf64187
--- /dev/null
+++ b/client/src/app/+admin/video-blacklist/video-blacklist-list/index.ts
@@ -0,0 +1 @@
export * from './video-blacklist-list.component'
diff --git a/client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.html b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.html
index 5d4636ee9..05d116798 100644
--- a/client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.html
+++ b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.html
@@ -18,8 +18,8 @@
18 <p-column field="createdAt" header="Created date" [sortable]="true"></p-column> 18 <p-column field="createdAt" header="Created date" [sortable]="true"></p-column>
19 <p-column header="Delete" styleClass="action-cell"> 19 <p-column header="Delete" styleClass="action-cell">
20 <ng-template pTemplate="body" let-entry="rowData"> 20 <ng-template pTemplate="body" let-entry="rowData">
21 <span (click)="removeVideoFromBlacklist(entry)" class="glyphicon glyphicon-remove glyphicon-black" title="Remove this video"></span> 21 <span (click)="removeVideoFromBlacklist(entry)" class="glyphicon glyphicon-remove glyphicon-black" title="Remove this video from blacklist"></span>
22 </ng-template> 22 </ng-template>
23 </p-column> 23 </p-column>
24 </p-dataTable> 24 </p-dataTable>
25 </div> 25 </div>
diff --git a/client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.ts b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts
index b308054ed..56024b247 100644
--- a/client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.ts
+++ b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts
@@ -4,16 +4,15 @@ import { SortMeta } from 'primeng/components/common/sortmeta'
4import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
5 5
6import { ConfirmService } from '../../../core' 6import { ConfirmService } from '../../../core'
7import { RestTable, RestPagination } from '../../../shared' 7import { VideoBlacklistService, RestTable, RestPagination } from '../../../shared'
8import { BlacklistService } from '../shared'
9import { BlacklistedVideo } from '../../../../../../shared' 8import { BlacklistedVideo } from '../../../../../../shared'
10 9
11@Component({ 10@Component({
12 selector: 'my-blacklist-list', 11 selector: 'my-video-blacklist-list',
13 templateUrl: './blacklist-list.component.html', 12 templateUrl: './video-blacklist-list.component.html',
14 styleUrls: [] 13 styleUrls: []
15}) 14})
16export class BlacklistListComponent extends RestTable implements OnInit { 15export class VideoBlacklistListComponent extends RestTable implements OnInit {
17 blacklist: BlacklistedVideo[] = [] 16 blacklist: BlacklistedVideo[] = []
18 totalRecords = 0 17 totalRecords = 0
19 rowsPerPage = 10 18 rowsPerPage = 10
@@ -23,7 +22,7 @@ export class BlacklistListComponent extends RestTable implements OnInit {
23 constructor ( 22 constructor (
24 private notificationsService: NotificationsService, 23 private notificationsService: NotificationsService,
25 private confirmService: ConfirmService, 24 private confirmService: ConfirmService,
26 private blacklistService: BlacklistService 25 private videoBlacklistService: VideoBlacklistService
27 ) { 26 ) {
28 super() 27 super()
29 } 28 }
@@ -39,7 +38,7 @@ export class BlacklistListComponent extends RestTable implements OnInit {
39 res => { 38 res => {
40 if (res === false) return 39 if (res === false) return
41 40
42 this.blacklistService.removeVideoFromBlacklist(entry).subscribe( 41 this.videoBlacklistService.removeVideoFromBlacklist(entry.videoId).subscribe(
43 status => { 42 status => {
44 this.notificationsService.success('Success', `Video ${entry.name} removed from the blacklist.`) 43 this.notificationsService.success('Success', `Video ${entry.name} removed from the blacklist.`)
45 this.loadData() 44 this.loadData()
@@ -52,7 +51,7 @@ export class BlacklistListComponent extends RestTable implements OnInit {
52 } 51 }
53 52
54 protected loadData () { 53 protected loadData () {
55 this.blacklistService.getBlacklist(this.pagination, this.sort) 54 this.videoBlacklistService.listBlacklist(this.pagination, this.sort)
56 .subscribe( 55 .subscribe(
57 resultList => { 56 resultList => {
58 this.blacklist = resultList.data 57 this.blacklist = resultList.data
diff --git a/client/src/app/+admin/blacklist/blacklist.component.ts b/client/src/app/+admin/video-blacklist/video-blacklist.component.ts
index ce8fe4298..24b8c98f8 100644
--- a/client/src/app/+admin/blacklist/blacklist.component.ts
+++ b/client/src/app/+admin/video-blacklist/video-blacklist.component.ts
@@ -3,6 +3,5 @@ import { Component } from '@angular/core'
3@Component({ 3@Component({
4 template: '<router-outlet></router-outlet>' 4 template: '<router-outlet></router-outlet>'
5}) 5})
6 6export class VideoBlacklistComponent {
7export class BlacklistComponent {
8} 7}
diff --git a/client/src/app/+admin/video-blacklist/video-blacklist.routes.ts b/client/src/app/+admin/video-blacklist/video-blacklist.routes.ts
new file mode 100644
index 000000000..682b6f8bd
--- /dev/null
+++ b/client/src/app/+admin/video-blacklist/video-blacklist.routes.ts
@@ -0,0 +1,27 @@
1import { Routes } from '@angular/router'
2
3import { VideoBlacklistComponent } from './video-blacklist.component'
4import { VideoBlacklistListComponent } from './video-blacklist-list'
5
6export const VideoBlacklistRoutes: Routes = [
7 {
8 path: 'video-blacklist',
9 component: VideoBlacklistComponent,
10 children: [
11 {
12 path: '',
13 redirectTo: 'list',
14 pathMatch: 'full'
15 },
16 {
17 path: 'list',
18 component: VideoBlacklistListComponent,
19 data: {
20 meta: {
21 title: 'Blacklisted videos'
22 }
23 }
24 }
25 ]
26 }
27]