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/shared/shared-moderation/video-block.component.ts | |
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/shared/shared-moderation/video-block.component.ts')
-rw-r--r-- | client/src/app/shared/shared-moderation/video-block.component.ts | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/client/src/app/shared/shared-moderation/video-block.component.ts b/client/src/app/shared/shared-moderation/video-block.component.ts index a6180dd14..400913f02 100644 --- a/client/src/app/shared/shared-moderation/video-block.component.ts +++ b/client/src/app/shared/shared-moderation/video-block.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' | 1 | import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' |
2 | import { Notifier } from '@app/core' | 2 | import { Notifier } from '@app/core' |
3 | import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' | 3 | import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' |
4 | import { Video } from '@app/shared/shared-main' | 4 | import { Video } from '@app/shared/shared-main' |
@@ -13,12 +13,12 @@ import { VideoBlockService } from './video-block.service' | |||
13 | styleUrls: [ './video-block.component.scss' ] | 13 | styleUrls: [ './video-block.component.scss' ] |
14 | }) | 14 | }) |
15 | export class VideoBlockComponent extends FormReactive implements OnInit { | 15 | export class VideoBlockComponent extends FormReactive implements OnInit { |
16 | @Input() video: Video = null | ||
17 | |||
18 | @ViewChild('modal', { static: true }) modal: NgbModal | 16 | @ViewChild('modal', { static: true }) modal: NgbModal |
19 | 17 | ||
20 | @Output() videoBlocked = new EventEmitter() | 18 | @Output() videoBlocked = new EventEmitter() |
21 | 19 | ||
20 | videos: Video[] | ||
21 | |||
22 | error: string = null | 22 | error: string = null |
23 | 23 | ||
24 | private openedModal: NgbModalRef | 24 | private openedModal: NgbModalRef |
@@ -41,7 +41,25 @@ export class VideoBlockComponent extends FormReactive implements OnInit { | |||
41 | }, defaultValues) | 41 | }, defaultValues) |
42 | } | 42 | } |
43 | 43 | ||
44 | show () { | 44 | isMultiple () { |
45 | return this.videos.length > 1 | ||
46 | } | ||
47 | |||
48 | getSingleVideo () { | ||
49 | return this.videos[0] | ||
50 | } | ||
51 | |||
52 | hasLive () { | ||
53 | return this.videos.some(v => v.isLive) | ||
54 | } | ||
55 | |||
56 | hasLocal () { | ||
57 | return this.videos.some(v => v.isLocal) | ||
58 | } | ||
59 | |||
60 | show (videos: Video[]) { | ||
61 | this.videos = videos | ||
62 | |||
45 | this.openedModal = this.modalService.open(this.modal, { centered: true, keyboard: false }) | 63 | this.openedModal = this.modalService.open(this.modal, { centered: true, keyboard: false }) |
46 | } | 64 | } |
47 | 65 | ||
@@ -51,17 +69,30 @@ export class VideoBlockComponent extends FormReactive implements OnInit { | |||
51 | } | 69 | } |
52 | 70 | ||
53 | block () { | 71 | block () { |
54 | const reason = this.form.value['reason'] || undefined | 72 | const options = this.videos.map(v => ({ |
55 | const unfederate = this.video.isLocal ? this.form.value['unfederate'] : undefined | 73 | videoId: v.id, |
74 | reason: this.form.value['reason'] || undefined, | ||
75 | unfederate: v.isLocal | ||
76 | ? this.form.value['unfederate'] | ||
77 | : undefined | ||
78 | })) | ||
56 | 79 | ||
57 | this.videoBlocklistService.blockVideo(this.video.id, reason, unfederate) | 80 | this.videoBlocklistService.blockVideo(options) |
58 | .subscribe({ | 81 | .subscribe({ |
59 | next: () => { | 82 | next: () => { |
60 | this.notifier.success($localize`Video blocked.`) | 83 | const message = this.isMultiple |
84 | ? $localize`Blocked ${this.videos.length} videos.` | ||
85 | : $localize`Blocked ${this.getSingleVideo().name}` | ||
86 | |||
87 | this.notifier.success(message) | ||
61 | this.hide() | 88 | this.hide() |
62 | 89 | ||
63 | this.video.blacklisted = true | 90 | for (const o of options) { |
64 | this.video.blacklistedReason = reason | 91 | const video = this.videos.find(v => v.id === o.videoId) |
92 | |||
93 | video.blacklisted = true | ||
94 | video.blacklistedReason = o.reason | ||
95 | } | ||
65 | 96 | ||
66 | this.videoBlocked.emit() | 97 | this.videoBlocked.emit() |
67 | }, | 98 | }, |