Add blacklist reason field
[oweals/peertube.git] / client / src / app / videos / +video-watch / video-watch.component.ts
index afbb0c596eed30cca94c5b221b858f3889e20c38..878655d4a898f0b6e6500e4e3ffa18357e98d189 100644 (file)
@@ -10,7 +10,7 @@ import { forkJoin, Subscription } from 'rxjs'
 import * as videojs from 'video.js'
 import 'videojs-hotkeys'
 import * as WebTorrent from 'webtorrent'
-import { ResultList, UserVideoRateType, VideoPrivacy, VideoRateType, VideoState } from '../../../../../shared'
+import { UserVideoRateType, VideoPrivacy, VideoRateType, VideoState } from '../../../../../shared'
 import '../../../assets/player/peertube-videojs-plugin'
 import { AuthService, ConfirmService } from '../../core'
 import { RestExtractor, VideoBlacklistService } from '../../shared'
@@ -21,6 +21,7 @@ import { MarkdownService } from '../shared'
 import { VideoDownloadComponent } from './modal/video-download.component'
 import { VideoReportComponent } from './modal/video-report.component'
 import { VideoShareComponent } from './modal/video-share.component'
+import { VideoBlacklistComponent } from './modal/video-blacklist.component'
 import { addContextMenu, getVideojsOptions, loadLocale } from '../../../assets/player/peertube-player'
 import { ServerService } from '@app/core'
 import { I18n } from '@ngx-translate/i18n-polyfill'
@@ -28,7 +29,6 @@ import { environment } from '../../../environments/environment'
 import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
 import { VideoCaptionService } from '@app/shared/video-caption'
 import { VideoCaption } from '../../../../../shared/models/videos/video-caption.model'
-import { VideoJSCaption } from '../../../assets/player/peertube-videojs-typings'
 
 @Component({
   selector: 'my-video-watch',
@@ -42,6 +42,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
   @ViewChild('videoShareModal') videoShareModal: VideoShareComponent
   @ViewChild('videoReportModal') videoReportModal: VideoReportComponent
   @ViewChild('videoSupportModal') videoSupportModal: VideoSupportComponent
+  @ViewChild('videoBlacklistModal') videoBlacklistModal: VideoBlacklistComponent
 
   otherVideosDisplayed: Video[] = []
 
@@ -157,26 +158,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     }
   }
 
-  async blacklistVideo (event: Event) {
-    event.preventDefault()
-
-    const res = await this.confirmService.confirm(this.i18n('Do you really want to blacklist this video?'), this.i18n('Blacklist'))
-    if (res === false) return
-
-    this.videoBlacklistService.blacklistVideo(this.video.id)
-        .subscribe(
-          () => {
-            this.notificationsService.success(
-              this.i18n('Success'),
-              this.i18n('Video {{videoName}} had been blacklisted.', { videoName: this.video.name })
-            )
-            this.redirectService.redirectToHomepage()
-          },
-
-          error => this.notificationsService.error(this.i18n('Error'), error.message)
-        )
-  }
-
   showMoreDescription () {
     if (this.completeVideoDescription === undefined) {
       return this.loadCompleteDescription()
@@ -231,6 +212,11 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     this.videoDownloadModal.show()
   }
 
+  showBlacklistModal (event: Event) {
+    event.preventDefault()
+    this.videoBlacklistModal.show()
+  }
+
   isUserLoggedIn () {
     return this.authService.isLoggedIn()
   }
@@ -290,6 +276,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     return this.video && this.video.state.id === VideoState.TO_TRANSCODE
   }
 
+  isVideoToImport () {
+    return this.video && this.video.state.id === VideoState.TO_IMPORT
+  }
+
   hasVideoScheduledPublication () {
     return this.video && this.video.scheduledUpdate !== undefined
   }