import { Component, OnInit, ViewChild } from '@angular/core'
import { Account } from '../../../shared/account/account.model'
import { Notifier } from '@app/core'
-import { SortMeta } from 'primeng/components/common/sortmeta'
+import { SortMeta } from 'primeng/api'
import { VideoAbuse, VideoAbuseState } from '../../../../../../shared'
import { RestPagination, RestTable, VideoAbuseService } from '../../../shared'
import { I18n } from '@ngx-translate/i18n-polyfill'
styleUrls: [ '../moderation.component.scss']
})
export class VideoAbuseListComponent extends RestTable implements OnInit {
- @ViewChild('moderationCommentModal') moderationCommentModal: ModerationCommentModalComponent
+ @ViewChild('moderationCommentModal', { static: true }) moderationCommentModal: ModerationCommentModalComponent
- videoAbuses: VideoAbuse[] = []
+ videoAbuses: (VideoAbuse & { moderationCommentHtml?: string, reasonHtml?: string })[] = []
totalRecords = 0
rowsPerPage = 10
sort: SortMeta = { field: 'createdAt', order: 1 }
}
- toHtml (text: string) {
- return this.markdownRenderer.textMarkdownToHTML(text)
- }
-
protected loadData () {
return this.videoAbuseService.getVideoAbuses(this.pagination, this.sort)
.subscribe(
- resultList => {
- this.videoAbuses = resultList.data
+ async resultList => {
this.totalRecords = resultList.total
+
+ this.videoAbuses = resultList.data
+
+ for (const abuse of this.videoAbuses) {
+ Object.assign(abuse, {
+ reasonHtml: await this.toHtml(abuse.reason),
+ moderationCommentHtml: await this.toHtml(abuse.moderationComment)
+ })
+ }
+
},
err => this.notifier.error(err.message)
)
}
+
+ private toHtml (text: string) {
+ return this.markdownRenderer.textMarkdownToHTML(text)
+ }
}