1 import { Component, OnInit } from '@angular/core'
2 import { SortMeta } from 'primeng/components/common/sortmeta'
4 import { NotificationsService } from 'angular2-notifications'
6 import { ConfirmService } from '../../../core'
7 import { VideoBlacklistService, RestTable, RestPagination } from '../../../shared'
8 import { BlacklistedVideo } from '../../../../../../shared'
11 selector: 'my-video-blacklist-list',
12 templateUrl: './video-blacklist-list.component.html',
15 export class VideoBlacklistListComponent extends RestTable implements OnInit {
16 blacklist: BlacklistedVideo[] = []
19 sort: SortMeta = { field: 'createdAt', order: 1 }
20 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
23 private notificationsService: NotificationsService,
24 private confirmService: ConfirmService,
25 private videoBlacklistService: VideoBlacklistService
34 async removeVideoFromBlacklist (entry: BlacklistedVideo) {
35 const confirmMessage = 'Do you really want to remove this video from the blacklist ? It will be available again in the videos list.'
37 const res = await this.confirmService.confirm(confirmMessage, 'Unblacklist')
38 if (res === false) return
40 this.videoBlacklistService.removeVideoFromBlacklist(entry.videoId).subscribe(
42 this.notificationsService.success('Success', `Video ${entry.name} removed from the blacklist.`)
46 err => this.notificationsService.error('Error', err.message)
50 protected loadData () {
51 this.videoBlacklistService.listBlacklist(this.pagination, this.sort)
54 this.blacklist = resultList.data
55 this.totalRecords = resultList.total
58 err => this.notificationsService.error('Error', err.message)