1 import { Component, OnInit } from '@angular/core'
2 import { SortMeta } from 'primeng/components/common/sortmeta'
3 import { NotificationsService } from 'angular2-notifications'
4 import { ConfirmService } from '../../../core'
5 import { RestPagination, RestTable, VideoBlacklistService } from '../../../shared'
6 import { BlacklistedVideo } from '../../../../../../shared'
7 import { I18n } from '@ngx-translate/i18n-polyfill'
10 selector: 'my-video-blacklist-list',
11 templateUrl: './video-blacklist-list.component.html',
14 export class VideoBlacklistListComponent extends RestTable implements OnInit {
15 blacklist: BlacklistedVideo[] = []
18 sort: SortMeta = { field: 'createdAt', order: 1 }
19 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
22 private notificationsService: NotificationsService,
23 private confirmService: ConfirmService,
24 private videoBlacklistService: VideoBlacklistService,
34 async removeVideoFromBlacklist (entry: BlacklistedVideo) {
35 const confirmMessage = this.i18n(
36 'Do you really want to remove this video from the blacklist ? It will be available again in the videos list.'
39 const res = await this.confirmService.confirm(confirmMessage, this.i18n('Unblacklist'))
40 if (res === false) return
42 this.videoBlacklistService.removeVideoFromBlacklist(entry.videoId).subscribe(
44 this.notificationsService.success(
46 this.i18n('Video {{name}} removed from the blacklist.', { name: entry.name })
51 err => this.notificationsService.error(this.i18n('Error'), err.message)
55 protected loadData () {
56 this.videoBlacklistService.listBlacklist(this.pagination, this.sort)
59 this.blacklist = resultList.data
60 this.totalRecords = resultList.total
63 err => this.notificationsService.error(this.i18n('Error'), err.message)