Add title in player peers info to show total downloaded/uploaded data
authorChocobozzz <me@florianbigard.com>
Fri, 22 Jun 2018 09:37:33 +0000 (11:37 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 22 Jun 2018 13:11:04 +0000 (15:11 +0200)
client/src/assets/player/peertube-videojs-plugin.ts
client/src/assets/player/webtorrent-info-button.ts

index 35a347e99385e3b7578468bfffe399064d7fcd23..fc07c35d61eca44fdead9fb29d2d9b21bd8720ec 100644 (file)
@@ -466,7 +466,9 @@ class PeerTubePlugin extends Plugin {
       return this.trigger('torrentInfo', {
         downloadSpeed: this.torrent.downloadSpeed,
         numPeers: this.torrent.numPeers,
-        uploadSpeed: this.torrent.uploadSpeed
+        uploadSpeed: this.torrent.uploadSpeed,
+        downloaded: this.torrent.downloaded,
+        uploaded: this.torrent.uploaded
       })
     }, this.CONSTANTS.INFO_SCHEDULER)
   }
index 1296aca3b32691bf30a7035c713b500f2c663f49..5f3e80c7994dbac73735fc00858e154631de3fe9 100644 (file)
@@ -3,6 +3,7 @@ import { bytes } from './utils'
 
 const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button')
 class WebtorrentInfoButton extends Button {
+
   createEl () {
     const div = videojsUntyped.dom.createEl('div', {
       className: 'vjs-peertube'
@@ -75,8 +76,13 @@ class WebtorrentInfoButton extends Button {
 
       const downloadSpeed = bytes(data.downloadSpeed)
       const uploadSpeed = bytes(data.uploadSpeed)
+      const totalDownloaded = bytes(data.downloaded)
+      const totalUploaded = bytes(data.uploaded)
       const numPeers = data.numPeers
 
+      subDivWebtorrent.title = this.player_.localize('Total Downloaded: ') + totalDownloaded.join(' ') + '\n' +
+        this.player_.localize('Total uploaded: ' + totalUploaded.join(' '))
+
       downloadSpeedNumber.textContent = downloadSpeed[ 0 ]
       downloadSpeedUnit.textContent = ' ' + downloadSpeed[ 1 ]