Added file (de)selecting, multiple file support, pausing/resuming torrents, improved debugging
This commit is contained in:
parent
8ea664a38d
commit
e07685a273
4 changed files with 80 additions and 22 deletions
|
@ -7,13 +7,13 @@
|
|||
- [x] Informative GUI with easy sharing options
|
||||
- [x] Downloading from an info hash or magnet URI
|
||||
- [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)
|
||||
- [x] Download/Upload speed per torrent
|
||||
- [x] Download/Upload speed of client (All torrents)
|
||||
- [ ] Removing torrents from the client (Coming Soon)
|
||||
- [ ] Pause torrent (Coming Soon)
|
||||
- [ ] Selecting/Deselecting files (Coming Soon)
|
||||
- [x] Removing torrents from the client
|
||||
- [x] Pause/Resume torrent
|
||||
- [x] Selecting/Deselecting files (Coming Soon)
|
||||
- [x] Client Debugging
|
||||
- [ ] Use custom trackers/rtcConfig
|
||||
|
||||
|
|
36
app.coffee
36
app.coffee
|
@ -32,11 +32,11 @@ rtcConfig = {
|
|||
|
||||
client = new WebTorrent {rtcConfig: rtcConfig}
|
||||
|
||||
dbg = (string, torrent, color) ->
|
||||
dbg = (string, item, color) ->
|
||||
color = if color? then color else '#333333'
|
||||
if window.localStorage.getItem('debug')?
|
||||
if torrent? && torrent.name
|
||||
console.debug '%cβTorrent:torrent:' + torrent.name + ' (' + torrent.infoHash + ') %c' + string, 'color: #33C3F0', 'color: ' + color
|
||||
if item? && item.name
|
||||
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
|
||||
else
|
||||
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 =
|
||||
columnDefs: $scope.columns
|
||||
data: $scope.client.validTorrents
|
||||
data: $scope.client.torrents
|
||||
enableColumnResizing: true
|
||||
enableColumnMenus: false
|
||||
enableRowSelection: true
|
||||
|
@ -96,11 +96,17 @@ app.controller 'bTorrentCtrl', ['$scope','$http','$log','$location', 'ngNotify',
|
|||
else
|
||||
$scope.selectedTorrent = row.entity
|
||||
|
||||
$scope.seedFile = (file) ->
|
||||
if file?
|
||||
dbg 'Seeding file ' + file.name
|
||||
$scope.seedFiles = (files) ->
|
||||
if files?
|
||||
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.seed file, opts, $scope.onSeed
|
||||
$scope.client.seed files, opts, $scope.onSeed
|
||||
delete opts.name
|
||||
return
|
||||
|
||||
$scope.openTorrentFile = (file) ->
|
||||
|
@ -124,12 +130,21 @@ app.controller 'bTorrentCtrl', ['$scope','$http','$log','$location', 'ngNotify',
|
|||
return
|
||||
|
||||
$scope.destroyedTorrent = (err) ->
|
||||
$scope.client.processing = false
|
||||
if err
|
||||
throw err
|
||||
dbg 'Destroyed torrent'
|
||||
dbg 'Destroyed torrent', $scope.selectedTorrent
|
||||
$scope.selectedTorrent = null
|
||||
$scope.client.processing = false
|
||||
return
|
||||
|
||||
$scope.changePriority = (file) ->
|
||||
if file.priority == '-1'
|
||||
dbg 'Deselected', file
|
||||
file.deselect()
|
||||
else
|
||||
dbg 'Selected ', file
|
||||
file.select()
|
||||
|
||||
$scope.onTorrent = (torrent, isSeed) ->
|
||||
torrent.safeTorrentFileURL = torrent.torrentFileURL
|
||||
torrent.fileName = torrent.name + '.torrent'
|
||||
|
@ -146,6 +161,7 @@ app.controller 'bTorrentCtrl', ['$scope','$http','$log','$location', 'ngNotify',
|
|||
throw err
|
||||
if isSeed
|
||||
dbg 'Started seeding', torrent
|
||||
if $scope.client.validTorrents.indexOf(torrent) == -1
|
||||
$scope.client.validTorrents.push torrent
|
||||
if !($scope.selectedTorrent?)
|
||||
$scope.selectedTorrent = torrent
|
||||
|
|
25
index.jade
25
index.jade
|
@ -8,7 +8,7 @@ html(ng-app='bTorrent', lang='en')
|
|||
meta(name='keywords', content='βTorrent, btorrent, client, webtorrent, browser, torrent, stream, bittorrent')
|
||||
meta(name='author', content='Diego Rodríguez Baquero - DiegoRBaquero')
|
||||
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/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')
|
||||
|
@ -17,7 +17,7 @@ html(ng-app='bTorrent', lang='en')
|
|||
header
|
||||
h1
|
||||
| βTorrent
|
||||
span.version v0.8.1
|
||||
span.version v0.9.0
|
||||
.container
|
||||
.row
|
||||
.four.columns
|
||||
|
@ -31,13 +31,24 @@ html(ng-app='bTorrent', lang='en')
|
|||
i.fa.fa-folder-open
|
||||
| Open torrent file
|
||||
.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
|
||||
| Seed a file
|
||||
| Seed files
|
||||
.row.grid(ui-grid='gridOptions', ui-grid-resize-columns, ui-grid-selection)
|
||||
.row(ng-if="selectedTorrent")
|
||||
.six.columns(style='overflow: auto')
|
||||
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
|
||||
ul
|
||||
li
|
||||
|
@ -56,12 +67,18 @@ html(ng-app='bTorrent', lang='en')
|
|||
tr
|
||||
th Name
|
||||
th Size
|
||||
th Priority
|
||||
tbody
|
||||
tr.files(ng-repeat='file in selectedTorrent.files')
|
||||
td(ng-hide='file.done') {{file.name}}
|
||||
td(ng-show='file.done')
|
||||
a(ng-href='{{file.url}}', download='{{file.name}}', target='_self', ng-show='file.done') {{file.name}}
|
||||
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
|
||||
strong Client Stats:
|
||||
| ↓ {{client.downloadSpeed() | pbytes}}/s ·
|
||||
|
|
25
style.sass
25
style.sass
|
@ -33,6 +33,9 @@ footer
|
|||
.download-button
|
||||
margin-left: 10px
|
||||
|
||||
.no-margin
|
||||
margin: 0px
|
||||
|
||||
.spinner
|
||||
position: absolute
|
||||
top: 30%
|
||||
|
@ -51,3 +54,25 @@ footer
|
|||
margin-top: -100px
|
||||
font-size: 200px
|
||||
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
|
Loading…
Reference in a new issue