]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/moderation/abuse-list/abuse-details.component.ts
Add ability to report comments in front end
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / moderation / abuse-list / abuse-details.component.ts
CommitLineData
25a42e29 1import { Component, Input } from '@angular/core'
67ed6552
C
2import { Actor } from '@app/shared/shared-main'
3import { I18n } from '@ngx-translate/i18n-polyfill'
d95d1559
C
4import { AbusePredefinedReasonsString } from '@shared/models'
5import { ProcessedAbuse } from './abuse-list.component'
1942f11d 6import { durationToString } from '@app/helpers'
801d9571
RK
7
8@Component({
d95d1559
C
9 selector: 'my-abuse-details',
10 templateUrl: './abuse-details.component.html',
801d9571
RK
11 styleUrls: [ '../moderation.component.scss' ]
12})
d95d1559
C
13export class AbuseDetailsComponent {
14 @Input() abuse: ProcessedAbuse
801d9571 15
d95d1559 16 private predefinedReasonsTranslations: { [key in AbusePredefinedReasonsString]: string }
1ebddadd
RK
17
18 constructor (
19 private i18n: I18n
20 ) {
21 this.predefinedReasonsTranslations = {
22 violentOrRepulsive: this.i18n('Violent or Repulsive'),
23 hatefulOrAbusive: this.i18n('Hateful or Abusive'),
24 spamOrMisleading: this.i18n('Spam or Misleading'),
25 privacy: this.i18n('Privacy'),
26 rights: this.i18n('Rights'),
27 serverRules: this.i18n('Server rules'),
28 thumbnails: this.i18n('Thumbnails'),
29 captions: this.i18n('Captions')
30 }
31 }
32
33 get startAt () {
8ca56654 34 return durationToString(this.abuse.video.startAt)
1ebddadd
RK
35 }
36
37 get endAt () {
8ca56654 38 return durationToString(this.abuse.video.endAt)
1ebddadd
RK
39 }
40
41 getPredefinedReasons () {
d95d1559 42 if (!this.abuse.predefinedReasons) return []
8ca56654 43
d95d1559 44 return this.abuse.predefinedReasons.map(r => ({
1ebddadd
RK
45 id: r,
46 label: this.predefinedReasonsTranslations[r]
47 }))
48 }
49
25a42e29
RK
50 switchToDefaultAvatar ($event: Event) {
51 ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL()
801d9571
RK
52 }
53}