import { SortMeta } from 'primeng/api'
-import { filter } from 'rxjs/operators'
import { AfterViewInit, Component, OnInit } from '@angular/core'
-import { ActivatedRoute, Params, Router } from '@angular/router'
+import { ActivatedRoute, Router } from '@angular/router'
import { AuthService, ConfirmService, MarkdownService, Notifier, RestPagination, RestTable } from '@app/core'
import { DropdownAction } from '@app/shared/shared-main'
import { BulkService } from '@app/shared/shared-moderation'
}
]
+ selectedComments: VideoCommentAdmin[] = []
+ bulkCommentActions: DropdownAction<VideoCommentAdmin[]>[] = []
+
get authUser () {
return this.auth.getUser()
}
ngOnInit () {
this.initialize()
this.listenToSearchChange()
+
+ this.bulkCommentActions = [
+ {
+ label: $localize`Delete`,
+ handler: comments => this.removeComments(comments),
+ isDisplayed: () => this.authUser.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT),
+ iconName: 'delete'
+ }
+ ]
}
ngAfterViewInit () {
- if (this.search) this.setTableFilter(this.search)
+ if (this.search) this.setTableFilter(this.search, false)
}
getIdentifier () {
return this.markdownRenderer.textMarkdownToHTML(text, true, true)
}
+ isInSelectionMode () {
+ return this.selectedComments.length !== 0
+ }
+
protected loadData () {
this.videoCommentService.getAdminVideoComments({
pagination: this.pagination,
)
}
+ private async removeComments (comments: VideoCommentAdmin[]) {
+ const commentArgs = comments.map(c => ({ videoId: c.video.id, commentId: c.id }))
+
+ this.videoCommentService.deleteVideoComments(commentArgs).subscribe(
+ () => {
+ this.notifier.success($localize`${commentArgs.length} comments deleted.`)
+ this.loadData()
+ },
+
+ err => this.notifier.error(err.message),
+
+ () => this.selectedComments = []
+ )
+ }
+
private deleteComment (comment: VideoCommentAdmin) {
this.videoCommentService.deleteVideoComment(comment.video.id, comment.id)
.subscribe(