predefined report reasons & improved reporter UI (#2842)
[oweals/peertube.git] / client / src / app / +admin / moderation / video-abuse-list / video-abuse-details.component.ts
index d9cb19845f03a5440c0e466d9a872fdea7b734b6..13485124f21074f9ee19d5b4b00b9914c745dda3 100644 (file)
@@ -1,7 +1,9 @@
 import { Component, Input } from '@angular/core'
-import { Account } from '@app/shared/account/account.model'
 import { Actor } from '@app/shared/actor/actor.model'
+import { VideoAbusePredefinedReasonsString } from '../../../../../../shared/models/videos/abuse/video-abuse-reason.model'
 import { ProcessedVideoAbuse } from './video-abuse-list.component'
+import { I18n } from '@ngx-translate/i18n-polyfill'
+import { durationToString } from '@app/shared/misc/utils'
 
 @Component({
   selector: 'my-video-abuse-details',
@@ -11,6 +13,39 @@ import { ProcessedVideoAbuse } from './video-abuse-list.component'
 export class VideoAbuseDetailsComponent {
   @Input() videoAbuse: ProcessedVideoAbuse
 
+  private predefinedReasonsTranslations: { [key in VideoAbusePredefinedReasonsString]: string }
+
+  constructor (
+    private i18n: I18n
+  ) {
+    this.predefinedReasonsTranslations = {
+      violentOrRepulsive: this.i18n('Violent or Repulsive'),
+      hatefulOrAbusive: this.i18n('Hateful or Abusive'),
+      spamOrMisleading: this.i18n('Spam or Misleading'),
+      privacy: this.i18n('Privacy'),
+      rights: this.i18n('Rights'),
+      serverRules: this.i18n('Server rules'),
+      thumbnails: this.i18n('Thumbnails'),
+      captions: this.i18n('Captions')
+    }
+  }
+
+  get startAt () {
+    return durationToString(this.videoAbuse.startAt)
+  }
+
+  get endAt () {
+    return durationToString(this.videoAbuse.endAt)
+  }
+
+  getPredefinedReasons () {
+    if (!this.videoAbuse.predefinedReasons) return []
+    return this.videoAbuse.predefinedReasons.map(r => ({
+      id: r,
+      label: this.predefinedReasonsTranslations[r]
+    }))
+  }
+
   switchToDefaultAvatar ($event: Event) {
     ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL()
   }