]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/angular/videos/components/watch/videos-watch.component.ts
Use progress bar from bootstrap for the upload
[github/Chocobozzz/PeerTube.git] / client / angular / videos / components / watch / videos-watch.component.ts
index 9a8909b75f492895fc7a7c3f24bb65e6f7637edd..6e212e8bc8afa72ec69fa9ba977d434c4ec3a6fd 100644 (file)
@@ -1,12 +1,13 @@
-import { Component, OnInit, ElementRef } from 'angular2/core';
-import { RouteParams, CanDeactivate, ComponentInstruction } from 'angular2/router';
+import { Component, OnInit, ElementRef } from '@angular/core';
+import { RouteParams, CanDeactivate, ComponentInstruction } from '@angular/router-deprecated';
+
 import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe';
 
 // TODO import it with systemjs
 declare var WebTorrent: any;
 
-import { Video } from '../../models/video';
-import { VideosService } from '../../services/videos.service';
+import { Video } from '../../video';
+import { VideosService } from '../../videos.service';
 
 @Component({
   selector: 'my-video-watch',
@@ -20,8 +21,9 @@ export class VideosWatchComponent implements OnInit, CanDeactivate {
   downloadSpeed: number;
   uploadSpeed: number;
   numPeers: number;
+  loading: boolean = false;
 
-  private _interval: number;
+  private _interval: NodeJS.Timer;
   private client: any;
 
   constructor(
@@ -42,9 +44,11 @@ export class VideosWatchComponent implements OnInit, CanDeactivate {
   }
 
   loadVideo(video: Video) {
+    this.loading = true;
     this.video = video;
     console.log('Adding ' + this.video.magnetUri + '.');
     this.client.add(this.video.magnetUri, (torrent) => {
+      this.loading = false;
       console.log('Added ' + this.video.magnetUri + '.');
       torrent.files[0].appendTo(this._elementRef.nativeElement.querySelector('.embed-responsive'), (err) => {
         if (err) {
@@ -64,7 +68,7 @@ export class VideosWatchComponent implements OnInit, CanDeactivate {
 
   routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) : any {
     console.log('Removing video from webtorrent.');
-    clearInterval(this._interval)
+    clearInterval(this._interval);
     this.client.remove(this.video.magnetUri);
     return true;
   }