Added file (de)selecting, multiple file support, pausing/resuming torrents, improved debugging

This commit is contained in:
Diego Rodríguez 2015-12-30 00:00:35 -05:00
parent 8ea664a38d
commit e07685a273
4 changed files with 80 additions and 22 deletions

View file

@ -7,13 +7,13 @@
- [x] Informative GUI with easy sharing options - [x] Informative GUI with easy sharing options
- [x] Downloading from an info hash or magnet URI - [x] Downloading from an info hash or magnet URI
- [x] Downloading from a .torrent file (Coming Soon) - [x] Downloading from a .torrent file (Coming Soon)
- [x] Seeding files (Single file only for the moment) - [x] Seeding files (Single/multiple files)
- [ ] Seeding CORS-enabled remote files (Coming Soon) - [ ] Seeding CORS-enabled remote files (Coming Soon)
- [x] Download/Upload speed per torrent - [x] Download/Upload speed per torrent
- [x] Download/Upload speed of client (All torrents) - [x] Download/Upload speed of client (All torrents)
- [ ] Removing torrents from the client (Coming Soon) - [x] Removing torrents from the client
- [ ] Pause torrent (Coming Soon) - [x] Pause/Resume torrent
- [ ] Selecting/Deselecting files (Coming Soon) - [x] Selecting/Deselecting files (Coming Soon)
- [x] Client Debugging - [x] Client Debugging
- [ ] Use custom trackers/rtcConfig - [ ] Use custom trackers/rtcConfig

View file

@ -32,11 +32,11 @@ rtcConfig = {
client = new WebTorrent {rtcConfig: rtcConfig} client = new WebTorrent {rtcConfig: rtcConfig}
dbg = (string, torrent, color) -> dbg = (string, item, color) ->
color = if color? then color else '#333333' color = if color? then color else '#333333'
if window.localStorage.getItem('debug')? if window.localStorage.getItem('debug')?
if torrent? && torrent.name if item? && item.name
console.debug '%cβTorrent:torrent:' + torrent.name + ' (' + torrent.infoHash + ') %c' + string, 'color: #33C3F0', 'color: ' + color console.debug '%cβTorrent:' + (if item.infoHash? then 'torrent ' else 'torrent ' + item._torrent.name + ':file ') + item.name + (if item.infoHash? then ' (' + item.infoHash + ')' else '') + ' %c' + string, 'color: #33C3F0', 'color: ' + color
return return
else else
console.debug '%cβTorrent:client %c' + string, 'color: #33C3F0', 'color: ' + color console.debug '%cβTorrent:client %c' + string, 'color: #33C3F0', 'color: ' + color
@ -73,7 +73,7 @@ app.controller 'bTorrentCtrl', ['$scope','$http','$log','$location', 'ngNotify',
$scope.gridOptions = $scope.gridOptions =
columnDefs: $scope.columns columnDefs: $scope.columns
data: $scope.client.validTorrents data: $scope.client.torrents
enableColumnResizing: true enableColumnResizing: true
enableColumnMenus: false enableColumnMenus: false
enableRowSelection: true enableRowSelection: true
@ -96,11 +96,17 @@ app.controller 'bTorrentCtrl', ['$scope','$http','$log','$location', 'ngNotify',
else else
$scope.selectedTorrent = row.entity $scope.selectedTorrent = row.entity
$scope.seedFile = (file) -> $scope.seedFiles = (files) ->
if file? if files?
dbg 'Seeding file ' + file.name if files.length == 1
dbg 'Seeding file ' + files[0].name
else
dbg 'Seeding ' + files.length + ' files'
name = prompt('Please name your torrent', 'My Awesome Torrent') || 'My Awesome Torrent'
opts.name = name
$scope.client.processing = true $scope.client.processing = true
$scope.client.seed file, opts, $scope.onSeed $scope.client.seed files, opts, $scope.onSeed
delete opts.name
return return
$scope.openTorrentFile = (file) -> $scope.openTorrentFile = (file) ->
@ -124,12 +130,21 @@ app.controller 'bTorrentCtrl', ['$scope','$http','$log','$location', 'ngNotify',
return return
$scope.destroyedTorrent = (err) -> $scope.destroyedTorrent = (err) ->
$scope.client.processing = false
if err if err
throw err throw err
dbg 'Destroyed torrent' dbg 'Destroyed torrent', $scope.selectedTorrent
$scope.selectedTorrent = null
$scope.client.processing = false
return return
$scope.changePriority = (file) ->
if file.priority == '-1'
dbg 'Deselected', file
file.deselect()
else
dbg 'Selected ', file
file.select()
$scope.onTorrent = (torrent, isSeed) -> $scope.onTorrent = (torrent, isSeed) ->
torrent.safeTorrentFileURL = torrent.torrentFileURL torrent.safeTorrentFileURL = torrent.torrentFileURL
torrent.fileName = torrent.name + '.torrent' torrent.fileName = torrent.name + '.torrent'
@ -146,6 +161,7 @@ app.controller 'bTorrentCtrl', ['$scope','$http','$log','$location', 'ngNotify',
throw err throw err
if isSeed if isSeed
dbg 'Started seeding', torrent dbg 'Started seeding', torrent
if $scope.client.validTorrents.indexOf(torrent) == -1
$scope.client.validTorrents.push torrent $scope.client.validTorrents.push torrent
if !($scope.selectedTorrent?) if !($scope.selectedTorrent?)
$scope.selectedTorrent = torrent $scope.selectedTorrent = torrent

View file

@ -8,7 +8,7 @@ html(ng-app='bTorrent', lang='en')
meta(name='keywords', content='βTorrent, btorrent, client, webtorrent, browser, torrent, stream, bittorrent') meta(name='keywords', content='βTorrent, btorrent, client, webtorrent, browser, torrent, stream, bittorrent')
meta(name='author', content='Diego Rodríguez Baquero - DiegoRBaquero') meta(name='author', content='Diego Rodríguez Baquero - DiegoRBaquero')
meta(name='viewport', content='width=device-width, initial-scale=1') meta(name='viewport', content='width=device-width, initial-scale=1')
script(src='https://cdn.jsdelivr.net/g/webtorrent@0.63,momentjs@2.10,angularjs@1.4,angular.ui-grid@3.0,angular.ng-notify@0.7,angular.file-upload@10.1') script(src='https://cdn.jsdelivr.net/g/webtorrent@0.66,momentjs@2.10,angularjs@1.4,angular.ui-grid@3.0,angular.ng-notify@0.7,angular.file-upload@10.1')
link(rel='stylesheet', href='https://cdn.jsdelivr.net/g/normalize@3.0,skeleton@2.0,angular.ng-notify@0.7(ng-notify.min.css)') link(rel='stylesheet', href='https://cdn.jsdelivr.net/g/normalize@3.0,skeleton@2.0,angular.ng-notify@0.7(ng-notify.min.css)')
link(rel='stylesheet', href='https://cdn.jsdelivr.net/fontawesome/4.5/css/font-awesome.min.css') link(rel='stylesheet', href='https://cdn.jsdelivr.net/fontawesome/4.5/css/font-awesome.min.css')
link(rel='stylesheet', href='https://cdn.jsdelivr.net/angular.ui-grid/3.0.7/ui-grid.min.css') link(rel='stylesheet', href='https://cdn.jsdelivr.net/angular.ui-grid/3.0.7/ui-grid.min.css')
@ -17,7 +17,7 @@ html(ng-app='bTorrent', lang='en')
header header
h1 h1
| βTorrent | βTorrent
span.version v0.8.1 span.version v0.9.0
.container .container
.row .row
.four.columns .four.columns
@ -31,13 +31,24 @@ html(ng-app='bTorrent', lang='en')
i.fa.fa-folder-open i.fa.fa-folder-open
| Open torrent file | Open torrent file
.three.columns.u-pull-right .three.columns.u-pull-right
button.u-pull-right.button-primary(type='file', ngf-select='seedFile($file)') button.u-pull-right.button-primary(ngf-select='seedFiles($files)', multiple='')
i.fa.fa-upload i.fa.fa-upload
| Seed a file | Seed files
.row.grid(ui-grid='gridOptions', ui-grid-resize-columns, ui-grid-selection) .row.grid(ui-grid='gridOptions', ui-grid-resize-columns, ui-grid-selection)
.row(ng-if="selectedTorrent") .row(ng-if="selectedTorrent")
.six.columns(style='overflow: auto') .six.columns(style='overflow: auto')
h5 {{selectedTorrent.name}} h5 {{selectedTorrent.name}}
button(ng-if='!selectedTorrent.swarm.paused', ng-click='selectedTorrent.pause()')
i.fa.fa-pause
| Pause
|
button(ng-if='selectedTorrent.swarm.paused', ng-click='selectedTorrent.resume()')
i.fa.fa-play
| Resume
|
button.button-danger(ng-click='client.remove(selectedTorrent.infoHash, destroyedTorrent)')
i.fa.fa-times
| Remove
h6 Share h6 Share
ul ul
li li
@ -56,12 +67,18 @@ html(ng-app='bTorrent', lang='en')
tr tr
th Name th Name
th Size th Size
th Priority
tbody tbody
tr.files(ng-repeat='file in selectedTorrent.files') tr.files(ng-repeat='file in selectedTorrent.files')
td(ng-hide='file.done') {{file.name}} td(ng-hide='file.done') {{file.name}}
td(ng-show='file.done') td(ng-show='file.done')
a(ng-href='{{file.url}}', download='{{file.name}}', target='_self', ng-show='file.done') {{file.name}} a(ng-href='{{file.url}}', download='{{file.name}}', target='_self', ng-show='file.done') {{file.name}}
td {{file.length | pbytes}} td {{file.length | pbytes}}
td
select.no-margin(name='{{file.name}}Priority', ng-model='file.priority', ng-init='file.priority = "0"', ng-change='changePriority(file)')
option(value='1') High Priority
option(value='0' selected='') Low Priority
option(value='-1') Don't download
.center .center
strong Client Stats: strong Client Stats:
| ↓ {{client.downloadSpeed() | pbytes}}/s · | ↓ {{client.downloadSpeed() | pbytes}}/s ·

View file

@ -33,6 +33,9 @@ footer
.download-button .download-button
margin-left: 10px margin-left: 10px
.no-margin
margin: 0px
.spinner .spinner
position: absolute position: absolute
top: 30% top: 30%
@ -51,3 +54,25 @@ footer
margin-top: -100px margin-top: -100px
font-size: 200px font-size: 200px
transform: translateY(-50%) transform: translateY(-50%)
.button.button-danger,
button.button-danger,
input[type="submit"].button-danger,
input[type="reset"].button-danger,
input[type="button"].button-danger
color: #FFF
background-color: #D9534F
border-color: #D9534F
.button.button-danger:hover,
button.button-danger:hover,
input[type="submit"].button-danger:hover,
input[type="reset"].button-danger:hover,
input[type="button"].button-danger:hover,
.button.button-danger:focus,
button.button-danger:focus,
input[type="submit"].button-danger:focus,
input[type="reset"].button-danger:focus,
input[type="button"].button-danger:focus
color: #FFF
background-color: #C43E3A
border-color: #C43E3A