]>
Commit | Line | Data |
---|---|---|
1 | import { Component, Input } from '@angular/core' | |
2 | import { durationToString } from '@app/helpers' | |
3 | import { Account } from '@app/shared/shared-main' | |
4 | import { AbusePredefinedReasonsString } from '@shared/models' | |
5 | import { ProcessedAbuse } from './processed-abuse.model' | |
6 | ||
7 | @Component({ | |
8 | selector: 'my-abuse-details', | |
9 | templateUrl: './abuse-details.component.html', | |
10 | styleUrls: [ '../shared-moderation/moderation.scss', './abuse-details.component.scss' ] | |
11 | }) | |
12 | export class AbuseDetailsComponent { | |
13 | @Input() abuse: ProcessedAbuse | |
14 | @Input() isAdminView: boolean | |
15 | @Input() baseRoute: string | |
16 | ||
17 | private predefinedReasonsTranslations: { [key in AbusePredefinedReasonsString]: string } | |
18 | ||
19 | constructor () { | |
20 | this.predefinedReasonsTranslations = { | |
21 | violentOrRepulsive: $localize`Violent or Repulsive`, | |
22 | hatefulOrAbusive: $localize`Hateful or Abusive`, | |
23 | spamOrMisleading: $localize`Spam or Misleading`, | |
24 | privacy: $localize`Privacy`, | |
25 | rights: $localize`Copyright`, | |
26 | serverRules: $localize`Server rules`, | |
27 | thumbnails: $localize`Thumbnails`, | |
28 | captions: $localize`Captions` | |
29 | } | |
30 | } | |
31 | ||
32 | get startAt () { | |
33 | return durationToString(this.abuse.video.startAt) | |
34 | } | |
35 | ||
36 | get endAt () { | |
37 | return durationToString(this.abuse.video.endAt) | |
38 | } | |
39 | ||
40 | getPredefinedReasons () { | |
41 | if (!this.abuse.predefinedReasons) return [] | |
42 | ||
43 | return this.abuse.predefinedReasons.map(r => ({ | |
44 | id: r, | |
45 | label: this.predefinedReasonsTranslations[r] | |
46 | })) | |
47 | } | |
48 | ||
49 | switchToDefaultAvatar ($event: Event) { | |
50 | ($event.target as HTMLImageElement).src = Account.GET_DEFAULT_AVATAR_URL() | |
51 | } | |
52 | } |