fixed restart functionality and added again
This commit is contained in:
parent
6849c22585
commit
5aca5ed8d4
|
@ -351,6 +351,13 @@
|
||||||
<i class="icon-play"></i>
|
<i class="icon-play"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
ng-show="canRestart(download)"
|
||||||
|
class="btn"
|
||||||
|
ng-click="restart(download)">
|
||||||
|
<i class="icon-repeat"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="btn hidden-phone"
|
class="btn hidden-phone"
|
||||||
ng-click="remove(download)">
|
ng-click="remove(download)">
|
||||||
|
|
|
@ -36,6 +36,38 @@ function(
|
||||||
rpc.once('unpause', [d.gid]);
|
rpc.once('unpause', [d.gid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scope.restart = function(d) {
|
||||||
|
// assumes downloads which are started by URIs, not torrents.
|
||||||
|
// the preferences are also not transferred, just simple restart
|
||||||
|
|
||||||
|
rpc.once('getFiles', [d.gid], function(data) {
|
||||||
|
var files = data[0];
|
||||||
|
var uris =
|
||||||
|
_.chain(files).map(function(f) { return f.uris })
|
||||||
|
.filter(function(uris) { return uris && uris.length })
|
||||||
|
.map(function(uris) {
|
||||||
|
var u = _.chain(uris)
|
||||||
|
.map(function(u) { return u.uri })
|
||||||
|
.uniq().value();
|
||||||
|
return u;
|
||||||
|
}).value();
|
||||||
|
|
||||||
|
if (uris.length > 0) {
|
||||||
|
console.log('adding uris:', uris);
|
||||||
|
scope.remove(d, function() {
|
||||||
|
rpc.once('addUri', uris, angular.noop, true);
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
scope.canRestart = function(d) {
|
||||||
|
return (['active', 'paused'].indexOf(d.status) == -1
|
||||||
|
&& !d.bittorrent);
|
||||||
|
}
|
||||||
|
|
||||||
// remove the download,
|
// remove the download,
|
||||||
// put it in stopped list if active,
|
// put it in stopped list if active,
|
||||||
// otherwise permanantly remove it
|
// otherwise permanantly remove it
|
||||||
|
@ -44,6 +76,7 @@ function(
|
||||||
if (!noConfirm && !confirm("Remove %s and associated meta-data?".replace("%s", d.name))) {
|
if (!noConfirm && !confirm("Remove %s and associated meta-data?".replace("%s", d.name))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var method = 'remove';
|
var method = 'remove';
|
||||||
|
|
||||||
if (scope.getType(d) == 'stopped')
|
if (scope.getType(d) == 'stopped')
|
||||||
|
@ -56,7 +89,7 @@ function(
|
||||||
rpc.once(method, [d.gid], cb);
|
rpc.once(method, [d.gid], cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// start filling in the model of active,
|
// start filling in the model of active,
|
||||||
// waiting and stopped download
|
// waiting and stopped download
|
||||||
rpc.subscribe('tellActive', [], function(data) {
|
rpc.subscribe('tellActive', [], function(data) {
|
||||||
scope.$apply(function() {
|
scope.$apply(function() {
|
||||||
|
|
|
@ -74,7 +74,7 @@ angular
|
||||||
},
|
},
|
||||||
parse: function() {
|
parse: function() {
|
||||||
return _
|
return _
|
||||||
.chain(this.uris.trim().split(/\n\r?/g))
|
.chain(this.uris.trim().split(/\r?\n/g))
|
||||||
.map(function(d) { return d.trim().split(/\s+/g) })
|
.map(function(d) { return d.trim().split(/\s+/g) })
|
||||||
.filter(function(d) { return d.length })
|
.filter(function(d) { return d.length })
|
||||||
.value();
|
.value();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user