]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add torrent informations (speed...) below the video
authorChocobozzz <florian.bigard@gmail.com>
Thu, 28 Apr 2016 18:40:56 +0000 (20:40 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Thu, 28 Apr 2016 18:40:56 +0000 (20:40 +0200)
client/angular/videos/components/watch/videos-watch.component.html
client/angular/videos/components/watch/videos-watch.component.ts
client/index.html
client/package.json

index e4722275102d53d5a73a7db6cb8a6067267e1b58..1ec0b1e1954e7b7a4b650a5bae6afcedbcc41bf9 100644 (file)
@@ -1,2 +1,7 @@
 <div class="embed-responsive embed-responsive-19by9">
 </div>
+<div id="torrent-info">
+  <div>Download: {{ downloadSpeed | bytes }}/s</div>
+  <div>Upload: {{ uploadSpeed | bytes }}/s</div>
+  <div>Number of peers: {{ numPeers }}</div>
+<div>
index c35c0ab19f668d75655a4e858c12720963106ef7..9a8909b75f492895fc7a7c3f24bb65e6f7637edd 100644 (file)
@@ -1,5 +1,6 @@
 import { Component, OnInit, ElementRef } from 'angular2/core';
 import { RouteParams, CanDeactivate, ComponentInstruction } from 'angular2/router';
+import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe';
 
 // TODO import it with systemjs
 declare var WebTorrent: any;
@@ -10,12 +11,17 @@ import { VideosService } from '../../services/videos.service';
 @Component({
   selector: 'my-video-watch',
   templateUrl: 'app/angular/videos/components/watch/videos-watch.component.html',
-  styleUrls: [ 'app/angular/videos/components/watch/videos-watch.component.css' ]
+  styleUrls: [ 'app/angular/videos/components/watch/videos-watch.component.css' ],
+  pipes: [ BytesPipe ]
 })
 
 export class VideosWatchComponent implements OnInit, CanDeactivate {
   video: Video;
+  downloadSpeed: number;
+  uploadSpeed: number;
+  numPeers: number;
 
+  private _interval: number;
   private client: any;
 
   constructor(
@@ -46,11 +52,19 @@ export class VideosWatchComponent implements OnInit, CanDeactivate {
           console.error(err);
         }
       });
+
+      // Refresh each second
+      this._interval = setInterval(() => {
+        this.downloadSpeed = torrent.downloadSpeed;
+        this.uploadSpeed = torrent.uploadSpeed;
+        this.numPeers = torrent.numPeers;
+      }, 1000);
     });
   }
 
   routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) : any {
     console.log('Removing video from webtorrent.');
+    clearInterval(this._interval)
     this.client.remove(this.video.magnetUri);
     return true;
   }
index 4b273aae4c711012852464ed95b4e334db98ab7d..6a2085ca680101a1d1eba3c2c8d9dfb95388ab1f 100644 (file)
               format: 'register',
               defaultExtension: 'js'
             }
-          },
+          }
+        },
+        map: {
+          'angular-pipes/src/math/bytes.pipe': '/app/node_modules/angular-pipes/src/math/bytes.pipe.js'
         }
       });
       System.import('/app/angular/bootstrap')
index 8070881f555ac07615737a37781b107ba8923fa8..d44ea8ff05a57a23abcb338ea341ae424ebd64cc 100644 (file)
@@ -21,6 +21,7 @@
   },
   "license": "ISC",
   "dependencies": {
+    "angular-pipes": "^1.4.1",
     "angular2": "2.0.0-beta.14",
     "blueimp-file-upload": "^9.12.1",
     "bootstrap-sass": "^3.3.6",