diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-10-10 10:02:18 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-10-10 10:18:16 +0200 |
commit | 35bf0c83c80f59ca79f4b84fac8700f17adeb22d (patch) | |
tree | a9b2106096d6ba04d7219051b17fd32cfbe6a885 /client/src/app/+admin/video-blacklist | |
parent | 769d332177a5b02d5c2ffc134687d3b4ed65bae9 (diff) | |
download | PeerTube-35bf0c83c80f59ca79f4b84fac8700f17adeb22d.tar.gz PeerTube-35bf0c83c80f59ca79f4b84fac8700f17adeb22d.tar.zst PeerTube-35bf0c83c80f59ca79f4b84fac8700f17adeb22d.zip |
Video blacklist refractoring
Diffstat (limited to 'client/src/app/+admin/video-blacklist')
6 files changed, 128 insertions, 0 deletions
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 @@ | |||
1 | export * from './video-blacklist-list' | ||
2 | export * from './video-blacklist.component' | ||
3 | export * 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/video-blacklist/video-blacklist-list/video-blacklist-list.component.html b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.html new file mode 100644 index 000000000..05d116798 --- /dev/null +++ b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-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 from blacklist"></span> | ||
22 | </ng-template> | ||
23 | </p-column> | ||
24 | </p-dataTable> | ||
25 | </div> | ||
26 | </div> | ||
diff --git a/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts new file mode 100644 index 000000000..56024b247 --- /dev/null +++ b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts | |||
@@ -0,0 +1,64 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | ||
2 | import { SortMeta } from 'primeng/components/common/sortmeta' | ||
3 | |||
4 | import { NotificationsService } from 'angular2-notifications' | ||
5 | |||
6 | import { ConfirmService } from '../../../core' | ||
7 | import { VideoBlacklistService, RestTable, RestPagination } from '../../../shared' | ||
8 | import { BlacklistedVideo } from '../../../../../../shared' | ||
9 | |||
10 | @Component({ | ||
11 | selector: 'my-video-blacklist-list', | ||
12 | templateUrl: './video-blacklist-list.component.html', | ||
13 | styleUrls: [] | ||
14 | }) | ||
15 | export class VideoBlacklistListComponent extends RestTable implements OnInit { | ||
16 | blacklist: BlacklistedVideo[] = [] | ||
17 | totalRecords = 0 | ||
18 | rowsPerPage = 10 | ||
19 | sort: SortMeta = { field: 'id', order: 1 } | ||
20 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | ||
21 | |||
22 | constructor ( | ||
23 | private notificationsService: NotificationsService, | ||
24 | private confirmService: ConfirmService, | ||
25 | private videoBlacklistService: VideoBlacklistService | ||
26 | ) { | ||
27 | super() | ||
28 | } | ||
29 | |||
30 | ngOnInit () { | ||
31 | this.loadData() | ||
32 | } | ||
33 | |||
34 | removeVideoFromBlacklist (entry: BlacklistedVideo) { | ||
35 | const confirmMessage = 'Do you really want to remove this video from the blacklist ? It will be available again in the video list.' | ||
36 | |||
37 | this.confirmService.confirm(confirmMessage, 'Remove').subscribe( | ||
38 | res => { | ||
39 | if (res === false) return | ||
40 | |||
41 | this.videoBlacklistService.removeVideoFromBlacklist(entry.videoId).subscribe( | ||
42 | status => { | ||
43 | this.notificationsService.success('Success', `Video ${entry.name} removed from the blacklist.`) | ||
44 | this.loadData() | ||
45 | }, | ||
46 | |||
47 | err => this.notificationsService.error('Error', err.message) | ||
48 | ) | ||
49 | } | ||
50 | ) | ||
51 | } | ||
52 | |||
53 | protected loadData () { | ||
54 | this.videoBlacklistService.listBlacklist(this.pagination, this.sort) | ||
55 | .subscribe( | ||
56 | resultList => { | ||
57 | this.blacklist = resultList.data | ||
58 | this.totalRecords = resultList.total | ||
59 | }, | ||
60 | |||
61 | err => this.notificationsService.error('Error', err.message) | ||
62 | ) | ||
63 | } | ||
64 | } | ||
diff --git a/client/src/app/+admin/video-blacklist/video-blacklist.component.ts b/client/src/app/+admin/video-blacklist/video-blacklist.component.ts new file mode 100644 index 000000000..24b8c98f8 --- /dev/null +++ b/client/src/app/+admin/video-blacklist/video-blacklist.component.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | import { Component } from '@angular/core' | ||
2 | |||
3 | @Component({ | ||
4 | template: '<router-outlet></router-outlet>' | ||
5 | }) | ||
6 | export class VideoBlacklistComponent { | ||
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 @@ | |||
1 | import { Routes } from '@angular/router' | ||
2 | |||
3 | import { VideoBlacklistComponent } from './video-blacklist.component' | ||
4 | import { VideoBlacklistListComponent } from './video-blacklist-list' | ||
5 | |||
6 | export 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 | ] | ||