-import { Component, Input } from '@angular/core'
+import { Component, Input, OnInit } from '@angular/core'
import { durationToString } from '@app/helpers'
-import { Actor } from '@app/shared/shared-main'
-import { I18n } from '@ngx-translate/i18n-polyfill'
import { AbusePredefinedReasonsString } from '@shared/models'
import { ProcessedAbuse } from './processed-abuse.model'
templateUrl: './abuse-details.component.html',
styleUrls: [ '../shared-moderation/moderation.scss', './abuse-details.component.scss' ]
})
-export class AbuseDetailsComponent {
+export class AbuseDetailsComponent implements OnInit {
@Input() abuse: ProcessedAbuse
@Input() isAdminView: boolean
- @Input() baseRoute: string
+ predefinedReasons: { id: string, label: string }[]
private predefinedReasonsTranslations: { [key in AbusePredefinedReasonsString]: string }
- constructor (
- private i18n: I18n
- ) {
+ constructor () {
this.predefinedReasonsTranslations = {
- violentOrRepulsive: this.i18n('Violent or Repulsive'),
- hatefulOrAbusive: this.i18n('Hateful or Abusive'),
- spamOrMisleading: this.i18n('Spam or Misleading'),
- privacy: this.i18n('Privacy'),
- rights: this.i18n('Rights'),
- serverRules: this.i18n('Server rules'),
- thumbnails: this.i18n('Thumbnails'),
- captions: this.i18n('Captions')
+ violentOrRepulsive: $localize`Violent or Repulsive`,
+ hatefulOrAbusive: $localize`Hateful or Abusive`,
+ spamOrMisleading: $localize`Spam or Misleading`,
+ privacy: $localize`Privacy`,
+ rights: $localize`Copyright`,
+ serverRules: $localize`Server rules`,
+ thumbnails: $localize`Thumbnails`,
+ captions: $localize`Captions`
}
}
- get startAt () {
- return durationToString(this.abuse.video.startAt)
- }
-
- get endAt () {
- return durationToString(this.abuse.video.endAt)
- }
+ ngOnInit (): void {
+ if (!this.abuse.predefinedReasons) return
- getPredefinedReasons () {
- if (!this.abuse.predefinedReasons) return []
-
- return this.abuse.predefinedReasons.map(r => ({
+ this.predefinedReasons = this.abuse.predefinedReasons.map(r => ({
id: r,
label: this.predefinedReasonsTranslations[r]
}))
}
- switchToDefaultAvatar ($event: Event) {
- ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL()
+ get startAt () {
+ return durationToString(this.abuse.video.startAt)
+ }
+
+ get endAt () {
+ return durationToString(this.abuse.video.endAt)
}
}