import { Component, OnInit, ViewChild } from '@angular/core'
import { Account } from '../../../shared/account/account.model'
-import { NotificationsService } from 'angular2-notifications'
+import { Notifier } from '@app/core'
import { SortMeta } from 'primeng/components/common/sortmeta'
import { VideoAbuse, VideoAbuseState } from '../../../../../../shared'
import { RestPagination, RestTable, VideoAbuseService } from '../../../shared'
import { ConfirmService } from '../../../core/index'
import { ModerationCommentModalComponent } from './moderation-comment-modal.component'
import { Video } from '../../../shared/video/video.model'
+import { MarkdownService } from '@app/shared/renderer'
@Component({
selector: 'my-video-abuse-list',
export class VideoAbuseListComponent extends RestTable implements OnInit {
@ViewChild('moderationCommentModal') moderationCommentModal: ModerationCommentModalComponent
- videoAbuses: VideoAbuse[] = []
+ videoAbuses: (VideoAbuse & { moderationCommentHtml?: string, reasonHtml?: string })[] = []
totalRecords = 0
rowsPerPage = 10
sort: SortMeta = { field: 'createdAt', order: 1 }
videoAbuseActions: DropdownAction<VideoAbuse>[] = []
constructor (
- private notificationsService: NotificationsService,
+ private notifier: Notifier,
private videoAbuseService: VideoAbuseService,
private confirmService: ConfirmService,
- private i18n: I18n
+ private i18n: I18n,
+ private markdownRenderer: MarkdownService
) {
super()
this.videoAbuseActions = [
{
- label: this.i18n('Delete'),
+ label: this.i18n('Delete this report'),
handler: videoAbuse => this.removeVideoAbuse(videoAbuse)
},
{
}
ngOnInit () {
- this.loadSort()
+ this.initialize()
}
openModerationCommentModal (videoAbuse: VideoAbuse) {
}
async removeVideoAbuse (videoAbuse: VideoAbuse) {
- const res = await this.confirmService.confirm(this.i18n('Do you really want to delete this abuse?'), this.i18n('Delete'))
+ const res = await this.confirmService.confirm(this.i18n('Do you really want to delete this abuse report?'), this.i18n('Delete'))
if (res === false) return
this.videoAbuseService.removeVideoAbuse(videoAbuse).subscribe(
() => {
- this.notificationsService.success(
- this.i18n('Success'),
- this.i18n('Abuse deleted.')
- )
+ this.notifier.success(this.i18n('Abuse deleted.'))
this.loadData()
},
- err => this.notificationsService.error(this.i18n('Error'), err.message)
+ err => this.notifier.error(err.message)
)
}
.subscribe(
() => this.loadData(),
- err => this.notificationsService.error(this.i18n('Error'), err.message)
+ err => this.notifier.error(err.message)
)
}
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.notificationsService.error(this.i18n('Error'), err.message)
+ err => this.notifier.error(err.message)
)
}
+
+ private toHtml (text: string) {
+ return this.markdownRenderer.textMarkdownToHTML(text)
+ }
}