improved download restart by preserving the preferences of the original download
This commit is contained in:
parent
1b6969cf81
commit
8f0500c78e
|
@ -1,16 +1,16 @@
|
|||
angular
|
||||
.module('webui.ctrls.download', [
|
||||
"ui.bootstrap",
|
||||
'webui.services.utils', 'webui.services.rpc', 'webui.services.alerts',
|
||||
'webui.services.utils', 'webui.services.rpc', 'webui.services.rpc.helpers', 'webui.services.alerts',
|
||||
'webui.services.settings', 'webui.services.modals', 'webui.services.configuration',
|
||||
])
|
||||
.controller('MainCtrl', [
|
||||
'$scope', '$name', '$enable', '$rpc', '$utils', '$alerts', '$modals',
|
||||
'$scope', '$name', '$enable', '$rpc', '$rpchelpers', '$utils', '$alerts', '$modals',
|
||||
'$fileSettings', '$activeInclude', '$waitingExclude', '$pageSize',
|
||||
// for document title
|
||||
'$window',
|
||||
function(
|
||||
scope, name, enable, rpc, utils, alerts, modals,
|
||||
scope, name, enable, rpc, rhelpers, utils, alerts, modals,
|
||||
fsettings, activeInclude, waitingExclude, pageSize,
|
||||
window
|
||||
) {
|
||||
|
@ -42,6 +42,8 @@ function(
|
|||
// assumes downloads which are started by URIs, not torrents.
|
||||
// the preferences are also not transferred, just simple restart
|
||||
|
||||
rpc.once('getOption', [d.gid], function(data) {
|
||||
var prefs = data[0];
|
||||
rpc.once('getFiles', [d.gid], function(data) {
|
||||
var files = data[0];
|
||||
var uris =
|
||||
|
@ -55,12 +57,13 @@ function(
|
|||
}).value();
|
||||
|
||||
if (uris.length > 0) {
|
||||
console.log('adding uris:', uris);
|
||||
console.log('adding uris:', uris, prefs);
|
||||
scope.remove(d, function() {
|
||||
rpc.once('addUri', uris, angular.noop, true);
|
||||
rhelpers.addUris(uris, prefs);
|
||||
}, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,6 +78,9 @@ function(
|
|||
// otherwise permanantly remove it
|
||||
// d: the download ctx
|
||||
scope.remove = function(d, cb, noConfirm) {
|
||||
// HACK to make sure an angular digest is not running, as only one can happen at a time, and confirm is a blocking
|
||||
// call so an rpc response can also trigger a digest call
|
||||
setTimeout(function() {
|
||||
if (!noConfirm && !confirm("Remove %s and associated meta-data?".replace("%s", d.name))) {
|
||||
return;
|
||||
}
|
||||
|
@ -89,9 +95,10 @@ function(
|
|||
d.followedFrom = null;
|
||||
}
|
||||
rpc.once(method, [d.gid], cb);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
// start filling in the model of active,
|
||||
// start filling in the model of active,
|
||||
// waiting and stopped download
|
||||
rpc.subscribe('tellActive', [], function(data) {
|
||||
scope.$apply(function() {
|
||||
|
@ -506,16 +513,17 @@ function(
|
|||
rpc.once('getOption', [d.gid], function(data) {
|
||||
var vals = data[0];
|
||||
|
||||
for (var i in fsettings) {
|
||||
var sets = _.cloneDeep(fsettings);
|
||||
for (var i in sets) {
|
||||
if (type == 'active' && activeInclude.indexOf(i) == -1) continue;
|
||||
|
||||
if (type == 'waiting' && waitingExclude.indexOf(i) != -1) continue;
|
||||
|
||||
settings[i] = fsettings[i];
|
||||
settings[i] = sets[i];
|
||||
settings[i].val = vals[i] || settings[i].val;
|
||||
}
|
||||
|
||||
modals.invoke('settings', settings, scope.name + ' settings', function(settings) {
|
||||
modals.invoke('settings', settings, d.name + ' settings', 'Change', function(settings) {
|
||||
var sets = {};
|
||||
for (var i in settings) { sets[i] = settings[i].val };
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user