diff options
Diffstat (limited to 'client/src/app/+admin/blacklist/blacklist-list')
3 files changed, 92 insertions, 0 deletions
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 @@ | |||
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 { RestTable, RestPagination } from '../../../shared' | ||
8 | import { BlacklistService } from '../shared' | ||
9 | import { BlacklistedVideo } from '../../../../../../shared' | ||
10 | |||
11 | @Component({ | ||
12 | selector: 'my-blacklist-list', | ||
13 | templateUrl: './blacklist-list.component.html', | ||
14 | styleUrls: [] | ||
15 | }) | ||
16 | export 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' | |||