aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-abuse-list/abuse-details.component.ts
blob: 0e872079a58124e5fc83ee80514f3c093eda5488 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Component, Input } 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'

@Component({
  selector: 'my-abuse-details',
  templateUrl: './abuse-details.component.html',
  styleUrls: [ '../shared-moderation/moderation.scss', './abuse-details.component.scss' ]
})
export class AbuseDetailsComponent {
  @Input() abuse: ProcessedAbuse
  @Input() isAdminView: boolean
  @Input() baseRoute: string

  private predefinedReasonsTranslations: { [key in AbusePredefinedReasonsString]: string }

  constructor (
    private i18n: I18n
  ) {
    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('Copyright'),
      serverRules: this.i18n('Server rules'),
      thumbnails: this.i18n('Thumbnails'),
      captions: this.i18n('Captions')
    }
  }

  get startAt () {
    return durationToString(this.abuse.video.startAt)
  }

  get endAt () {
    return durationToString(this.abuse.video.endAt)
  }

  getPredefinedReasons () {
    if (!this.abuse.predefinedReasons) return []

    return this.abuse.predefinedReasons.map(r => ({
      id: r,
      label: this.predefinedReasonsTranslations[r]
    }))
  }

  switchToDefaultAvatar ($event: Event) {
    ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL()
  }
}