aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/moderation/video-auto-blacklist-list/video-auto-blacklist-list.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin/moderation/video-auto-blacklist-list/video-auto-blacklist-list.component.ts')
-rw-r--r--client/src/app/+admin/moderation/video-auto-blacklist-list/video-auto-blacklist-list.component.ts100
1 files changed, 100 insertions, 0 deletions
diff --git a/client/src/app/+admin/moderation/video-auto-blacklist-list/video-auto-blacklist-list.component.ts b/client/src/app/+admin/moderation/video-auto-blacklist-list/video-auto-blacklist-list.component.ts
new file mode 100644
index 000000000..b79f574c9
--- /dev/null
+++ b/client/src/app/+admin/moderation/video-auto-blacklist-list/video-auto-blacklist-list.component.ts
@@ -0,0 +1,100 @@
1import { Component, OnInit, OnDestroy } from '@angular/core'
2import { Location } from '@angular/common'
3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { Router, ActivatedRoute } from '@angular/router'
5import { AbstractVideoList } from '@app/shared/video/abstract-video-list'
6import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
7import { Notifier, AuthService } from '@app/core'
8import { Video } from '@shared/models'
9import { VideoBlacklistService } from '@app/shared'
10import { immutableAssign } from '@app/shared/misc/utils'
11import { ScreenService } from '@app/shared/misc/screen.service'
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})
18export class VideoAutoBlacklistListComponent extends AbstractVideoList implements OnInit, OnDestroy {
19 titlePage: string
20 currentRoute = '/admin/moderation/video-auto-blacklist/list'
21 checkedVideos: { [ id: number ]: boolean } = {}
22 pagination: ComponentPagination = {
23 currentPage: 1,
24 itemsPerPage: 5,
25 totalItems: null
26 }
27
28 protected baseVideoWidth = -1
29 protected baseVideoHeight = 155
30
31 constructor (
32 protected router: Router,
33 protected route: ActivatedRoute,
34 protected i18n: I18n,
35 protected notifier: Notifier,
36 protected location: Location,
37 protected authService: AuthService,
38 protected screenService: ScreenService,
39 private videoBlacklistService: VideoBlacklistService,
40 ) {
41 super()
42
43 this.titlePage = this.i18n('Auto-blacklisted videos')
44 }
45
46 ngOnInit () {
47 super.ngOnInit()
48 }
49
50 ngOnDestroy () {
51 super.ngOnDestroy()
52 }
53
54 abortSelectionMode () {
55 this.checkedVideos = {}
56 }
57
58 isInSelectionMode () {
59 return Object.keys(this.checkedVideos).some(k => this.checkedVideos[k] === true)
60 }
61
62 getVideosObservable (page: number) {
63 const newPagination = immutableAssign(this.pagination, { currentPage: page })
64
65 return this.videoBlacklistService.getAutoBlacklistedAsVideoList(newPagination)
66 }
67
68 generateSyndicationList () {
69 throw new Error('Method not implemented.')
70 }
71
72 removeVideoFromBlacklist (entry: Video) {
73 this.videoBlacklistService.removeVideoFromBlacklist(entry.id).subscribe(
74 () => {
75 this.notifier.success(this.i18n('Video {{name}} removed from blacklist.', { name: entry.name }))
76 this.reloadVideos()
77 },
78
79 error => this.notifier.error(error.message)
80 )
81 }
82
83 removeSelectedVideosFromBlacklist () {
84 const toReleaseVideosIds = Object.keys(this.checkedVideos)
85 .filter(k => this.checkedVideos[ k ] === true)
86 .map(k => parseInt(k, 10))
87
88 this.videoBlacklistService.removeVideoFromBlacklist(toReleaseVideosIds).subscribe(
89 () => {
90 this.notifier.success(this.i18n('{{num}} videos removed from blacklist.', { num: toReleaseVideosIds.length }))
91
92 this.abortSelectionMode()
93 this.reloadVideos()
94 },
95
96 error => this.notifier.error(error.message)
97 )
98 }
99
100}