]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts
Fix database benchmark in prod mode
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / video-blacklist / video-blacklist-list / video-blacklist-list.component.ts
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 }