diff options
author | Chocobozzz <me@florianbigard.com> | 2021-11-17 11:18:49 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-11-17 11:18:49 +0100 |
commit | 3cfa817672657df18260ece5b354efa0f3b6e317 (patch) | |
tree | 318a7113fac4fcf1e6d0f7888cda1939aeefc500 /client/src/app/+admin/overview/videos | |
parent | 4bdff96d77c03e5cce6052188f69a65bf6ea5781 (diff) | |
download | PeerTube-3cfa817672657df18260ece5b354efa0f3b6e317.tar.gz PeerTube-3cfa817672657df18260ece5b354efa0f3b6e317.tar.zst PeerTube-3cfa817672657df18260ece5b354efa0f3b6e317.zip |
Add ability to bulk block videos
Diffstat (limited to 'client/src/app/+admin/overview/videos')
-rw-r--r-- | client/src/app/+admin/overview/videos/video-list.component.html | 2 | ||||
-rw-r--r-- | client/src/app/+admin/overview/videos/video-list.component.ts | 36 |
2 files changed, 35 insertions, 3 deletions
diff --git a/client/src/app/+admin/overview/videos/video-list.component.html b/client/src/app/+admin/overview/videos/video-list.component.html index 6b0dc3abd..9b536ec11 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.html +++ b/client/src/app/+admin/overview/videos/video-list.component.html | |||
@@ -126,3 +126,5 @@ | |||
126 | </tr> | 126 | </tr> |
127 | </ng-template> | 127 | </ng-template> |
128 | </p-table> | 128 | </p-table> |
129 | |||
130 | <my-video-block #videoBlockModal (videoBlocked)="onVideoBlocked()"></my-video-block> | ||
diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts index 0f98a5d33..7f268bb23 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.ts +++ b/client/src/app/+admin/overview/videos/video-list.component.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import { SortMeta } from 'primeng/api' | 1 | import { SortMeta } from 'primeng/api' |
2 | import { finalize } from 'rxjs/operators' | 2 | import { finalize } from 'rxjs/operators' |
3 | import { Component, OnInit } from '@angular/core' | 3 | import { Component, OnInit, ViewChild } from '@angular/core' |
4 | import { ActivatedRoute, Router } from '@angular/router' | 4 | import { ActivatedRoute, Router } from '@angular/router' |
5 | import { AuthService, ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' | 5 | import { AuthService, ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' |
6 | import { AdvancedInputFilter } from '@app/shared/shared-forms' | 6 | import { AdvancedInputFilter } from '@app/shared/shared-forms' |
7 | import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' | 7 | import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' |
8 | import { VideoBlockComponent, VideoBlockService } from '@app/shared/shared-moderation' | ||
8 | import { VideoActionsDisplayType } from '@app/shared/shared-video-miniature' | 9 | import { VideoActionsDisplayType } from '@app/shared/shared-video-miniature' |
9 | import { UserRight, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' | 10 | import { UserRight, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' |
10 | import { VideoAdminService } from './video-admin.service' | 11 | import { VideoAdminService } from './video-admin.service' |
@@ -15,6 +16,8 @@ import { VideoAdminService } from './video-admin.service' | |||
15 | styleUrls: [ './video-list.component.scss' ] | 16 | styleUrls: [ './video-list.component.scss' ] |
16 | }) | 17 | }) |
17 | export class VideoListComponent extends RestTable implements OnInit { | 18 | export class VideoListComponent extends RestTable implements OnInit { |
19 | @ViewChild('videoBlockModal') videoBlockModal: VideoBlockComponent | ||
20 | |||
18 | videos: Video[] = [] | 21 | videos: Video[] = [] |
19 | 22 | ||
20 | totalRecords = 0 | 23 | totalRecords = 0 |
@@ -48,7 +51,8 @@ export class VideoListComponent extends RestTable implements OnInit { | |||
48 | private auth: AuthService, | 51 | private auth: AuthService, |
49 | private notifier: Notifier, | 52 | private notifier: Notifier, |
50 | private videoService: VideoService, | 53 | private videoService: VideoService, |
51 | private videoAdminService: VideoAdminService | 54 | private videoAdminService: VideoAdminService, |
55 | private videoBlockService: VideoBlockService | ||
52 | ) { | 56 | ) { |
53 | super() | 57 | super() |
54 | } | 58 | } |
@@ -68,6 +72,16 @@ export class VideoListComponent extends RestTable implements OnInit { | |||
68 | label: $localize`Delete`, | 72 | label: $localize`Delete`, |
69 | handler: videos => this.removeVideos(videos), | 73 | handler: videos => this.removeVideos(videos), |
70 | isDisplayed: () => this.authUser.hasRight(UserRight.REMOVE_ANY_VIDEO) | 74 | isDisplayed: () => this.authUser.hasRight(UserRight.REMOVE_ANY_VIDEO) |
75 | }, | ||
76 | { | ||
77 | label: $localize`Block`, | ||
78 | handler: videos => this.videoBlockModal.show(videos), | ||
79 | isDisplayed: videos => this.authUser.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) && videos.every(v => !v.blacklisted) | ||
80 | }, | ||
81 | { | ||
82 | label: $localize`Unblock`, | ||
83 | handler: videos => this.unblockVideos(videos), | ||
84 | isDisplayed: videos => this.authUser.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) && videos.every(v => v.blacklisted) | ||
71 | } | 85 | } |
72 | ] | 86 | ] |
73 | ] | 87 | ] |
@@ -132,6 +146,10 @@ export class VideoListComponent extends RestTable implements OnInit { | |||
132 | return files.reduce((p, f) => p += f.size, 0) | 146 | return files.reduce((p, f) => p += f.size, 0) |
133 | } | 147 | } |
134 | 148 | ||
149 | onVideoBlocked () { | ||
150 | this.reloadData() | ||
151 | } | ||
152 | |||
135 | protected reloadData () { | 153 | protected reloadData () { |
136 | this.selectedVideos = [] | 154 | this.selectedVideos = [] |
137 | 155 | ||
@@ -160,7 +178,19 @@ export class VideoListComponent extends RestTable implements OnInit { | |||
160 | this.videoService.removeVideo(videos.map(v => v.id)) | 178 | this.videoService.removeVideo(videos.map(v => v.id)) |
161 | .subscribe({ | 179 | .subscribe({ |
162 | next: () => { | 180 | next: () => { |
163 | this.notifier.success($localize`${videos.length} videos deleted.`) | 181 | this.notifier.success($localize`Deleted ${videos.length} videos.`) |
182 | this.reloadData() | ||
183 | }, | ||
184 | |||
185 | error: err => this.notifier.error(err.message) | ||
186 | }) | ||
187 | } | ||
188 | |||
189 | private unblockVideos (videos: Video[]) { | ||
190 | this.videoBlockService.unblockVideo(videos.map(v => v.id)) | ||
191 | .subscribe({ | ||
192 | next: () => { | ||
193 | this.notifier.success($localize`Unblocked ${videos.length} videos.`) | ||
164 | this.reloadData() | 194 | this.reloadData() |
165 | }, | 195 | }, |
166 | 196 | ||