]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/shared-abuse-list/abuse-details.component.ts
Fix lint
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-abuse-list / abuse-details.component.ts
CommitLineData
25a42e29 1import { Component, Input } from '@angular/core'
94148c90 2import { durationToString } from '@app/helpers'
67ed6552
C
3import { Actor } from '@app/shared/shared-main'
4import { I18n } from '@ngx-translate/i18n-polyfill'
d95d1559 5import { AbusePredefinedReasonsString } from '@shared/models'
94148c90 6import { 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
13export 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'),
830c762b 28 rights: this.i18n('Copyright'),
1ebddadd
RK
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}