aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts')
-rw-r--r--client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts34
1 files changed, 32 insertions, 2 deletions
diff --git a/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts b/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts
index 284ec541d..529e28f11 100644
--- a/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts
+++ b/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts
@@ -1,7 +1,6 @@
1import { SortMeta } from 'primeng/api' 1import { SortMeta } from 'primeng/api'
2import { filter } from 'rxjs/operators'
3import { AfterViewInit, Component, OnInit } from '@angular/core' 2import { AfterViewInit, Component, OnInit } from '@angular/core'
4import { ActivatedRoute, Params, Router } from '@angular/router' 3import { ActivatedRoute, Router } from '@angular/router'
5import { AuthService, ConfirmService, MarkdownService, Notifier, RestPagination, RestTable } from '@app/core' 4import { AuthService, ConfirmService, MarkdownService, Notifier, RestPagination, RestTable } from '@app/core'
6import { DropdownAction } from '@app/shared/shared-main' 5import { DropdownAction } from '@app/shared/shared-main'
7import { BulkService } from '@app/shared/shared-moderation' 6import { BulkService } from '@app/shared/shared-moderation'
@@ -41,6 +40,9 @@ export class VideoCommentListComponent extends RestTable implements OnInit, Afte
41 } 40 }
42 ] 41 ]
43 42
43 selectedComments: VideoCommentAdmin[] = []
44 bulkCommentActions: DropdownAction<VideoCommentAdmin[]>[] = []
45
44 get authUser () { 46 get authUser () {
45 return this.auth.getUser() 47 return this.auth.getUser()
46 } 48 }
@@ -78,6 +80,15 @@ export class VideoCommentListComponent extends RestTable implements OnInit, Afte
78 ngOnInit () { 80 ngOnInit () {
79 this.initialize() 81 this.initialize()
80 this.listenToSearchChange() 82 this.listenToSearchChange()
83
84 this.bulkCommentActions = [
85 {
86 label: $localize`Delete`,
87 handler: comments => this.removeComments(comments),
88 isDisplayed: () => this.authUser.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT),
89 iconName: 'delete'
90 }
91 ]
81 } 92 }
82 93
83 ngAfterViewInit () { 94 ngAfterViewInit () {
@@ -92,6 +103,10 @@ export class VideoCommentListComponent extends RestTable implements OnInit, Afte
92 return this.markdownRenderer.textMarkdownToHTML(text, true, true) 103 return this.markdownRenderer.textMarkdownToHTML(text, true, true)
93 } 104 }
94 105
106 isInSelectionMode () {
107 return this.selectedComments.length !== 0
108 }
109
95 protected loadData () { 110 protected loadData () {
96 this.videoCommentService.getAdminVideoComments({ 111 this.videoCommentService.getAdminVideoComments({
97 pagination: this.pagination, 112 pagination: this.pagination,
@@ -114,6 +129,21 @@ export class VideoCommentListComponent extends RestTable implements OnInit, Afte
114 ) 129 )
115 } 130 }
116 131
132 private async removeComments (comments: VideoCommentAdmin[]) {
133 const commentArgs = comments.map(c => ({ videoId: c.video.id, commentId: c.id }))
134
135 this.videoCommentService.deleteVideoComments(commentArgs).subscribe(
136 () => {
137 this.notifier.success($localize`${commentArgs.length} comments deleted.`)
138 this.loadData()
139 },
140
141 err => this.notifier.error(err.message),
142
143 () => this.selectedComments = []
144 )
145 }
146
117 private deleteComment (comment: VideoCommentAdmin) { 147 private deleteComment (comment: VideoCommentAdmin) {
118 this.videoCommentService.deleteVideoComment(comment.video.id, comment.id) 148 this.videoCommentService.deleteVideoComment(comment.video.id, comment.id)
119 .subscribe( 149 .subscribe(