fixed restart functionality and added again

This commit is contained in:
hamza zia 2014-06-02 16:06:39 +08:00
parent 6849c22585
commit 5aca5ed8d4
3 changed files with 42 additions and 2 deletions

View File

@ -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)">

View File

@ -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')

View File

@ -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();