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