]>
Commit | Line | Data |
---|---|---|
25a42e29 | 1 | import { Component, Input } from '@angular/core' |
94148c90 | 2 | import { durationToString } from '@app/helpers' |
67ed6552 C |
3 | import { Actor } from '@app/shared/shared-main' |
4 | import { I18n } from '@ngx-translate/i18n-polyfill' | |
d95d1559 | 5 | import { AbusePredefinedReasonsString } from '@shared/models' |
94148c90 | 6 | import { ProcessedAbuse } from './processed-abuse.model' |
801d9571 RK |
7 | |
8 | @Component({ | |
d95d1559 C |
9 | selector: 'my-abuse-details', |
10 | templateUrl: './abuse-details.component.html', | |
94148c90 | 11 | styleUrls: [ '../shared-moderation/moderation.scss', './abuse-details.component.scss' ] |
801d9571 | 12 | }) |
d95d1559 C |
13 | export class AbuseDetailsComponent { |
14 | @Input() abuse: ProcessedAbuse | |
94148c90 C |
15 | @Input() isAdminView: boolean |
16 | @Input() baseRoute: string | |
801d9571 | 17 | |
d95d1559 | 18 | private predefinedReasonsTranslations: { [key in AbusePredefinedReasonsString]: string } |
1ebddadd RK |
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('Rights'), | |
29 | serverRules: this.i18n('Server rules'), | |
30 | thumbnails: this.i18n('Thumbnails'), | |
31 | captions: this.i18n('Captions') | |
32 | } | |
33 | } | |
34 | ||
35 | get startAt () { | |
8ca56654 | 36 | return durationToString(this.abuse.video.startAt) |
1ebddadd RK |
37 | } |
38 | ||
39 | get endAt () { | |
8ca56654 | 40 | return durationToString(this.abuse.video.endAt) |
1ebddadd RK |
41 | } |
42 | ||
43 | getPredefinedReasons () { | |
d95d1559 | 44 | if (!this.abuse.predefinedReasons) return [] |
8ca56654 | 45 | |
d95d1559 | 46 | return this.abuse.predefinedReasons.map(r => ({ |
1ebddadd RK |
47 | id: r, |
48 | label: this.predefinedReasonsTranslations[r] | |
49 | })) | |
50 | } | |
51 | ||
25a42e29 RK |
52 | switchToDefaultAvatar ($event: Event) { |
53 | ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL() | |
801d9571 RK |
54 | } |
55 | } |