X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=client%2Fsrc%2Fapp%2Fvideos%2Fvideo-watch%2Fvideo-watch.component.ts;h=d83cc5a7aa9f4a3ab6562ded5f232c382e9ce8af;hb=4f8c0eb0e9356ee2782ea6eb12a92e4dc5f66127;hp=0309938c0d3bfecb902fcc5342d86eca215fe9f3;hpb=067e3f84cebc553c60321b527139aa7703eaa5d8;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/videos/video-watch/video-watch.component.ts b/client/src/app/videos/video-watch/video-watch.component.ts index 0309938c0..d83cc5a7a 100644 --- a/client/src/app/videos/video-watch/video-watch.component.ts +++ b/client/src/app/videos/video-watch/video-watch.component.ts @@ -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; @@ -28,6 +33,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { playerElement: Element; uploadSpeed: number; video: Video = null; + videoNotFound = false; private errorTimer: NodeJS.Timer; private sub: any; @@ -39,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() { @@ -51,7 +58,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.setOpenGraphTags(); this.loadVideo(); }, - error => alert(error.text) + error => { + this.videoNotFound = true; + } ); }); @@ -73,7 +82,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy { console.log('Removing video from webtorrent.'); clearInterval(this.torrentInfosInterval); clearTimeout(this.errorTimer); - this.webTorrentService.remove(this.video.magnetUri); + + if (this.video !== null) { + this.webTorrentService.remove(this.video.magnetUri); + } // Remove player videojs(this.playerElement).dispose(); @@ -115,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(); - } - - hideShareModal() { - this.shareModal.hide(); + this.videoShareModal.show(); } - getVideoIframeCode() { - return ''; + showMagnetUriModal() { + this.videoMagnetModal.show(); } - getVideoUrl() { - return window.location.href; + isUserLoggedIn() { + return this.authService.isLoggedIn(); } private loadTooLong() {