]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/videos/video-watch/video-watch.component.ts
Client: add ability to report a video
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-watch / video-watch.component.ts
index 3dab2bbb7f1432262bdec720d65f497b72528497..d83cc5a7aa9f4a3ab6562ded5f232c382e9ce8af 100644 (file)
@@ -1,10 +1,14 @@
+import { setInterval, setTimeout } from 'timers'
 import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
 import { ActivatedRoute } from '@angular/router';
 
-import { ModalDirective } from 'ng2-bootstrap/components/modal';
 import { MetaService } from 'ng2-meta';
 import * as videojs from 'video.js';
 
+import { AuthService } from '../../core';
+import { VideoMagnetComponent } from './video-magnet.component';
+import { VideoShareComponent } from './video-share.component';
+import { VideoReportComponent } from './video-report.component';
 import { Video, VideoService } from '../shared';
 import { WebTorrentService } from './webtorrent.service';
 
@@ -17,8 +21,9 @@ import { WebTorrentService } from './webtorrent.service';
 export class VideoWatchComponent implements OnInit, OnDestroy {
   private static LOADTIME_TOO_LONG: number = 30000;
 
-  @ViewChild('magnetUriModal') magnetUriModal: ModalDirective;
-  @ViewChild('shareModal') shareModal: ModalDirective;
+  @ViewChild('videoMagnetModal') videoMagnetModal: VideoMagnetComponent;
+  @ViewChild('videoShareModal') videoShareModal: VideoShareComponent;
+  @ViewChild('videoReportModal') videoReportModal: VideoReportComponent;
 
   downloadSpeed: number;
   error: boolean = false;
@@ -40,7 +45,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     private route: ActivatedRoute,
     private videoService: VideoService,
     private metaService: MetaService,
-    private webTorrentService: WebTorrentService
+    private webTorrentService: WebTorrentService,
+    private authService: AuthService
   ) {}
 
   ngOnInit() {
@@ -121,31 +127,21 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     });
   }
 
-  showMagnetUriModal() {
-    this.magnetUriModal.show();
-  }
-
-  hideMagnetUriModal() {
-    this.magnetUriModal.hide();
+  showReportModal(event: Event) {
+    event.preventDefault();
+    this.videoReportModal.show();
   }
 
   showShareModal() {
-    this.shareModal.show();
+    this.videoShareModal.show();
   }
 
-  hideShareModal() {
-    this.shareModal.hide();
-  }
-
-  getVideoIframeCode() {
-    return '<iframe width="560" height="315" ' +
-           'src="' + window.location.origin + '/videos/embed/' + this.video.id + '" ' +
-           'frameborder="0" allowfullscreen>' +
-           '</iframe>';
+  showMagnetUriModal() {
+    this.videoMagnetModal.show();
   }
 
-  getVideoUrl() {
-    return window.location.href;
+  isUserLoggedIn() {
+    return this.authService.isLoggedIn();
   }
 
   private loadTooLong() {