]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/moderation/video-auto-blacklist-list/video-auto-blacklist-list.component.ts
smaller miniature average size in fluid grid, updated admin instructions for global...
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / moderation / video-auto-blacklist-list / video-auto-blacklist-list.component.ts
CommitLineData
693263e9 1import { Component } from '@angular/core'
7ccddd7b 2import { I18n } from '@ngx-translate/i18n-polyfill'
e2409062 3import { ActivatedRoute, Router } from '@angular/router'
7ccddd7b 4import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
e2409062 5import { AuthService, Notifier, ServerService } from '@app/core'
7ccddd7b
JM
6import { VideoBlacklistService } from '@app/shared'
7import { immutableAssign } from '@app/shared/misc/utils'
8import { ScreenService } from '@app/shared/misc/screen.service'
e2409062 9import { MiniatureDisplayOptions } from '@app/shared/video/video-miniature.component'
693263e9
C
10import { SelectionType } from '@app/shared/video/videos-selection.component'
11import { Video } from '@app/shared/video/video.model'
7ccddd7b
JM
12
13@Component({
14 selector: 'my-video-auto-blacklist-list',
15 templateUrl: './video-auto-blacklist-list.component.html',
16 styleUrls: [ './video-auto-blacklist-list.component.scss' ]
17})
693263e9 18export class VideoAutoBlacklistListComponent {
7ccddd7b 19 titlePage: string
693263e9 20 selection: SelectionType = {}
e2409062
C
21 miniatureDisplayOptions: MiniatureDisplayOptions = {
22 date: true,
23 views: false,
24 by: true,
25 privacyLabel: false,
26 privacyText: true,
27 state: false,
28 blacklistInfo: false,
29 nsfw: true
30 }
693263e9
C
31 pagination: ComponentPagination = {
32 currentPage: 1,
33 itemsPerPage: 5,
34 totalItems: null
35 }
36 videos: Video[] = []
37 getVideosObservableFunction = this.getVideosObservable.bind(this)
e2409062 38
7ccddd7b
JM
39 constructor (
40 protected router: Router,
41 protected route: ActivatedRoute,
7ccddd7b 42 protected notifier: Notifier,
7ccddd7b
JM
43 protected authService: AuthService,
44 protected screenService: ScreenService,
489290b8
C
45 protected serverService: ServerService,
46 private i18n: I18n,
47 private videoBlacklistService: VideoBlacklistService
7ccddd7b 48 ) {
7ccddd7b
JM
49 this.titlePage = this.i18n('Auto-blacklisted videos')
50 }
51
7ccddd7b
JM
52 getVideosObservable (page: number) {
53 const newPagination = immutableAssign(this.pagination, { currentPage: page })
54
55 return this.videoBlacklistService.getAutoBlacklistedAsVideoList(newPagination)
56 }
57
7ccddd7b
JM
58 removeVideoFromBlacklist (entry: Video) {
59 this.videoBlacklistService.removeVideoFromBlacklist(entry.id).subscribe(
60 () => {
61 this.notifier.success(this.i18n('Video {{name}} removed from blacklist.', { name: entry.name }))
693263e9
C
62
63 this.videos = this.videos.filter(v => v.id !== entry.id)
7ccddd7b
JM
64 },
65
66 error => this.notifier.error(error.message)
67 )
68 }
69
70 removeSelectedVideosFromBlacklist () {
693263e9
C
71 const toReleaseVideosIds = Object.keys(this.selection)
72 .filter(k => this.selection[ k ] === true)
7ccddd7b
JM
73 .map(k => parseInt(k, 10))
74
75 this.videoBlacklistService.removeVideoFromBlacklist(toReleaseVideosIds).subscribe(
76 () => {
77 this.notifier.success(this.i18n('{{num}} videos removed from blacklist.', { num: toReleaseVideosIds.length }))
78
693263e9
C
79 this.selection = {}
80 this.videos = this.videos.filter(v => toReleaseVideosIds.includes(v.id) === false)
7ccddd7b
JM
81 },
82
83 error => this.notifier.error(error.message)
84 )
85 }
7ccddd7b 86}