]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts
adding tests for audio conversions
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / video-blacklist / video-blacklist-list / video-blacklist-list.component.ts
CommitLineData
792dbaf0
GS
1import { Component, OnInit } from '@angular/core'
2import { SortMeta } from 'primeng/components/common/sortmeta'
792dbaf0 3import { NotificationsService } from 'angular2-notifications'
792dbaf0 4import { ConfirmService } from '../../../core'
b1d40cff 5import { RestPagination, RestTable, VideoBlacklistService } from '../../../shared'
792dbaf0 6import { BlacklistedVideo } from '../../../../../../shared'
b1d40cff 7import { I18n } from '@ngx-translate/i18n-polyfill'
792dbaf0
GS
8
9@Component({
35bf0c83
C
10 selector: 'my-video-blacklist-list',
11 templateUrl: './video-blacklist-list.component.html',
792dbaf0
GS
12 styleUrls: []
13})
35bf0c83 14export class VideoBlacklistListComponent extends RestTable implements OnInit {
792dbaf0
GS
15 blacklist: BlacklistedVideo[] = []
16 totalRecords = 0
17 rowsPerPage = 10
ab998f7b 18 sort: SortMeta = { field: 'createdAt', order: 1 }
792dbaf0
GS
19 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
20
21 constructor (
22 private notificationsService: NotificationsService,
23 private confirmService: ConfirmService,
b1d40cff
C
24 private videoBlacklistService: VideoBlacklistService,
25 private i18n: I18n
792dbaf0
GS
26 ) {
27 super()
28 }
29
30 ngOnInit () {
ab998f7b 31 this.loadSort()
792dbaf0
GS
32 }
33
1f30a185 34 async removeVideoFromBlacklist (entry: BlacklistedVideo) {
b1d40cff
C
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.'
37 )
792dbaf0 38
b1d40cff 39 const res = await this.confirmService.confirm(confirmMessage, this.i18n('Unblacklist'))
1f30a185 40 if (res === false) return
792dbaf0 41
1f30a185
C
42 this.videoBlacklistService.removeVideoFromBlacklist(entry.videoId).subscribe(
43 () => {
b1d40cff
C
44 this.notificationsService.success(
45 this.i18n('Success'),
25acef90 46 this.i18n('Video {{name}} removed from the blacklist.', { name: entry.name })
b1d40cff 47 )
1f30a185
C
48 this.loadData()
49 },
792dbaf0 50
b1d40cff 51 err => this.notificationsService.error(this.i18n('Error'), err.message)
792dbaf0
GS
52 )
53 }
54
55 protected loadData () {
35bf0c83 56 this.videoBlacklistService.listBlacklist(this.pagination, this.sort)
792dbaf0
GS
57 .subscribe(
58 resultList => {
59 this.blacklist = resultList.data
60 this.totalRecords = resultList.total
61 },
62
b1d40cff 63 err => this.notificationsService.error(this.i18n('Error'), err.message)
792dbaf0
GS
64 )
65 }
66}