aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/app/+admin/admin-routing.module.ts4
-rw-r--r--client/src/app/+admin/admin.module.ts7
-rw-r--r--client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.html26
-rw-r--r--client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.ts65
-rw-r--r--client/src/app/+admin/blacklist/blacklist-list/index.ts1
-rw-r--r--client/src/app/+admin/blacklist/blacklist.component.ts8
-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/core/menu/menu-admin.component.html5
11 files changed, 190 insertions, 2 deletions
diff --git a/client/src/app/+admin/admin-routing.module.ts b/client/src/app/+admin/admin-routing.module.ts
index a3845b72c..0cd3e54c2 100644
--- a/client/src/app/+admin/admin-routing.module.ts
+++ b/client/src/app/+admin/admin-routing.module.ts
@@ -9,6 +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'
12 13
13const adminRoutes: Routes = [ 14const adminRoutes: Routes = [
14 { 15 {
@@ -25,7 +26,8 @@ const adminRoutes: Routes = [
25 ...FriendsRoutes, 26 ...FriendsRoutes,
26 ...RequestSchedulersRoutes, 27 ...RequestSchedulersRoutes,
27 ...UsersRoutes, 28 ...UsersRoutes,
28 ...VideoAbusesRoutes 29 ...VideoAbusesRoutes,
30 ...BlacklistRoutes
29 ] 31 ]
30 } 32 }
31] 33]
diff --git a/client/src/app/+admin/admin.module.ts b/client/src/app/+admin/admin.module.ts
index 786dbc15c..c2dd60774 100644
--- a/client/src/app/+admin/admin.module.ts
+++ b/client/src/app/+admin/admin.module.ts
@@ -6,6 +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 { SharedModule } from '../shared' 10import { SharedModule } from '../shared'
10import { AdminGuard } from './admin-guard.service' 11import { AdminGuard } from './admin-guard.service'
11 12
@@ -30,6 +31,9 @@ import { AdminGuard } from './admin-guard.service'
30 UserUpdateComponent, 31 UserUpdateComponent,
31 UserListComponent, 32 UserListComponent,
32 33
34 BlacklistComponent,
35 BlacklistListComponent,
36
33 VideoAbusesComponent, 37 VideoAbusesComponent,
34 VideoAbuseListComponent 38 VideoAbuseListComponent
35 ], 39 ],
@@ -42,7 +46,8 @@ import { AdminGuard } from './admin-guard.service'
42 FriendService, 46 FriendService,
43 RequestSchedulersService, 47 RequestSchedulersService,
44 UserService, 48 UserService,
45 AdminGuard 49 AdminGuard,
50 BlacklistService
46 ] 51 ]
47}) 52})
48export class AdminModule { } 53export class AdminModule { }
diff --git a/client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.html b/client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.html
new file mode 100644
index 000000000..5d4636ee9
--- /dev/null
+++ b/client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.html
@@ -0,0 +1,26 @@
1<div class="row">
2 <div class="content-padding">
3 <h3>Blacklisted videos</h3>
4
5 <p-dataTable
6 [value]="blacklist" [lazy]="true" [paginator]="true" [totalRecords]="totalRecords" [rows]="rowsPerPage"
7 sortField="id" (onLazyLoad)="loadLazy($event)"
8 >
9 <p-column field="id" header="ID" [sortable]="true"></p-column>
10 <p-column field="name" header="Name" [sortable]="true"></p-column>
11 <p-column field="description" header="Description"></p-column>
12 <p-column field="duration" header="Duration" [sortable]="true"></p-column>
13 <p-column field="views" header="Views" [sortable]="true"></p-column>
14 <p-column field="likes" header="Likes" [sortable]="true"></p-column>
15 <p-column field="dislikes" header="Dislikes" [sortable]="true"></p-column>
16 <p-column field="nsfw" header="NSFW"></p-column>
17 <p-column field="uuid" header="UUID" [sortable]="true"></p-column>
18 <p-column field="createdAt" header="Created date" [sortable]="true"></p-column>
19 <p-column header="Delete" styleClass="action-cell">
20 <ng-template pTemplate="body" let-entry="rowData">
21 <span (click)="removeVideoFromBlacklist(entry)" class="glyphicon glyphicon-remove glyphicon-black" title="Remove this video"></span>
22 </ng-template>
23 </p-column>
24 </p-dataTable>
25 </div>
26</div>
diff --git a/client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.ts b/client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.ts
new file mode 100644
index 000000000..b308054ed
--- /dev/null
+++ b/client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.ts
@@ -0,0 +1,65 @@
1import { Component, OnInit } from '@angular/core'
2import { SortMeta } from 'primeng/components/common/sortmeta'
3
4import { NotificationsService } from 'angular2-notifications'
5
6import { ConfirmService } from '../../../core'
7import { RestTable, RestPagination } from '../../../shared'
8import { BlacklistService } from '../shared'
9import { BlacklistedVideo } from '../../../../../../shared'
10
11@Component({
12 selector: 'my-blacklist-list',
13 templateUrl: './blacklist-list.component.html',
14 styleUrls: []
15})
16export class BlacklistListComponent extends RestTable implements OnInit {
17 blacklist: BlacklistedVideo[] = []
18 totalRecords = 0
19 rowsPerPage = 10
20 sort: SortMeta = { field: 'id', order: 1 }
21 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
22
23 constructor (
24 private notificationsService: NotificationsService,
25 private confirmService: ConfirmService,
26 private blacklistService: BlacklistService
27 ) {
28 super()
29 }
30
31 ngOnInit () {
32 this.loadData()
33 }
34
35 removeVideoFromBlacklist (entry: BlacklistedVideo) {
36 const confirmMessage = 'Do you really want to remove this video from the blacklist ? It will be available again in the video list.'
37
38 this.confirmService.confirm(confirmMessage, 'Remove').subscribe(
39 res => {
40 if (res === false) return
41
42 this.blacklistService.removeVideoFromBlacklist(entry).subscribe(
43 status => {
44 this.notificationsService.success('Success', `Video ${entry.name} removed from the blacklist.`)
45 this.loadData()
46 },
47
48 err => this.notificationsService.error('Error', err.message)
49 )
50 }
51 )
52 }
53
54 protected loadData () {
55 this.blacklistService.getBlacklist(this.pagination, this.sort)
56 .subscribe(
57 resultList => {
58 this.blacklist = resultList.data
59 this.totalRecords = resultList.total
60 },
61
62 err => this.notificationsService.error('Error', err.message)
63 )
64 }
65}
diff --git a/client/src/app/+admin/blacklist/blacklist-list/index.ts b/client/src/app/+admin/blacklist/blacklist-list/index.ts
new file mode 100644
index 000000000..45f60a2b9
--- /dev/null
+++ b/client/src/app/+admin/blacklist/blacklist-list/index.ts
@@ -0,0 +1 @@
export * from './blacklist-list.component'
diff --git a/client/src/app/+admin/blacklist/blacklist.component.ts b/client/src/app/+admin/blacklist/blacklist.component.ts
new file mode 100644
index 000000000..ce8fe4298
--- /dev/null
+++ b/client/src/app/+admin/blacklist/blacklist.component.ts
@@ -0,0 +1,8 @@
1import { Component } from '@angular/core'
2
3@Component({
4 template: '<router-outlet></router-outlet>'
5})
6
7export class BlacklistComponent {
8}
diff --git a/client/src/app/+admin/blacklist/blacklist.routes.ts b/client/src/app/+admin/blacklist/blacklist.routes.ts
new file mode 100644
index 000000000..780347ca8
--- /dev/null
+++ b/client/src/app/+admin/blacklist/blacklist.routes.ts
@@ -0,0 +1,27 @@
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
new file mode 100644
index 000000000..675dc1263
--- /dev/null
+++ b/client/src/app/+admin/blacklist/index.ts
@@ -0,0 +1,4 @@
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
new file mode 100644
index 000000000..1b090c9c5
--- /dev/null
+++ b/client/src/app/+admin/blacklist/shared/blacklist.service.ts
@@ -0,0 +1,44 @@
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/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
new file mode 100644
index 000000000..ad22e2d51
--- /dev/null
+++ b/client/src/app/+admin/blacklist/shared/index.ts
@@ -0,0 +1 @@
export * from './blacklist.service'
diff --git a/client/src/app/core/menu/menu-admin.component.html b/client/src/app/core/menu/menu-admin.component.html
index 0dfe22d84..f512a4e67 100644
--- a/client/src/app/core/menu/menu-admin.component.html
+++ b/client/src/app/core/menu/menu-admin.component.html
@@ -19,6 +19,11 @@
19 <span class="hidden-xs glyphicon glyphicon-alert"></span> 19 <span class="hidden-xs glyphicon glyphicon-alert"></span>
20 Video abuses 20 Video abuses
21 </a> 21 </a>
22
23 <a routerLink="/admin/blacklist/list" routerLinkActive="active">
24 <span class="hidden-xs glyphicon glyphicon-eye-close"></span>
25 Video blacklist
26 </a>
22 </div> 27 </div>
23 28
24 <div class="panel-block"> 29 <div class="panel-block">