2013-01-29 13:47:40 +01:00
|
|
|
angular
|
2013-01-29 18:52:30 +01:00
|
|
|
.module('webui.ctrls.nav', [
|
2014-06-02 21:36:21 +02:00
|
|
|
'webui.services.configuration', 'webui.services.modals',
|
2013-02-20 14:12:55 +01:00
|
|
|
'webui.services.rpc', 'webui.services.rpc.helpers',
|
2013-06-23 22:01:15 +02:00
|
|
|
'webui.services.settings', 'webui.services.utils'
|
2013-01-29 18:52:30 +01:00
|
|
|
])
|
|
|
|
.controller('NavCtrl', [
|
2014-05-31 19:32:46 +02:00
|
|
|
'$scope', '$modals',
|
2013-02-25 10:58:35 +01:00
|
|
|
'$rpc', '$rpchelpers', '$fileSettings',
|
|
|
|
'$globalSettings', '$globalExclude',
|
2013-06-23 22:01:15 +02:00
|
|
|
'$utils',
|
2013-02-25 10:58:35 +01:00
|
|
|
function(
|
2014-05-31 19:32:46 +02:00
|
|
|
scope, modals,
|
2013-02-25 10:58:35 +01:00
|
|
|
rpc, rhelpers, fsettings,
|
2013-06-23 22:01:15 +02:00
|
|
|
gsettings, gexclude,
|
|
|
|
utils
|
2013-02-25 10:58:35 +01:00
|
|
|
) {
|
2013-01-29 18:52:30 +01:00
|
|
|
|
2013-03-20 08:45:28 +01:00
|
|
|
scope.isFeatureEnabled = function(f) { return rhelpers.isFeatureEnabled(f) };
|
|
|
|
|
2013-01-28 15:18:21 +01:00
|
|
|
// initially collapsed in mobile resolution
|
|
|
|
scope.collapsed = true;
|
2013-01-29 18:52:30 +01:00
|
|
|
|
2014-06-10 09:19:24 +02:00
|
|
|
scope.onDownloadFilter = function() {
|
|
|
|
// Forward to MainCtrl.
|
|
|
|
scope.$parent.downloadFilter = scope.downloadFilter;
|
|
|
|
scope.$parent.onDownloadFilter();
|
|
|
|
};
|
|
|
|
|
2013-02-25 14:09:11 +01:00
|
|
|
// manage download functions
|
|
|
|
scope.forcePauseAll = function() {
|
|
|
|
rpc.once('forcePauseAll', []);
|
|
|
|
}
|
|
|
|
|
|
|
|
scope.purgeDownloadResult = function() {
|
|
|
|
rpc.once('purgeDownloadResult', []);
|
|
|
|
}
|
|
|
|
|
|
|
|
scope.unpauseAll = function() {
|
|
|
|
rpc.once('unpauseAll', []);
|
|
|
|
}
|
|
|
|
|
2013-01-29 18:52:30 +01:00
|
|
|
scope.addUris = function() {
|
2013-01-30 07:13:38 +01:00
|
|
|
modals.invoke(
|
|
|
|
'getUris', _.bind(rhelpers.addUris, rhelpers)
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
scope.addTorrents = function() {
|
|
|
|
modals.invoke(
|
|
|
|
'getTorrents', _.bind(rhelpers.addTorrents, rhelpers)
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
scope.addMetalinks = function() {
|
|
|
|
modals.invoke(
|
|
|
|
'getMetalinks', _.bind(rhelpers.addMetalinks, rhelpers)
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
scope.addTorrent = function() {
|
|
|
|
modals.invoke(
|
|
|
|
'getTorrent', _.bind(rhelpers.addTorrents, rhelpers)
|
|
|
|
);
|
2013-01-29 18:52:30 +01:00
|
|
|
};
|
|
|
|
|
2013-02-26 15:02:26 +01:00
|
|
|
scope.changeCSettings = function() {
|
2013-03-09 06:35:53 +01:00
|
|
|
modals.invoke(
|
|
|
|
'connection', rpc.getConfiguration(), _.bind(rpc.configure, rpc)
|
|
|
|
);
|
2013-02-26 15:02:26 +01:00
|
|
|
}
|
|
|
|
|
2013-02-20 01:13:06 +01:00
|
|
|
scope.changeGSettings = function() {
|
2013-02-20 14:12:55 +01:00
|
|
|
rpc.once('getGlobalOption', [], function(data) {
|
2013-06-23 22:01:15 +02:00
|
|
|
var starred = utils.getCookie('aria2props');
|
|
|
|
if (!starred || !starred.indexOf) starred = [];
|
2013-02-20 14:12:55 +01:00
|
|
|
var vals = data[0];
|
2013-02-25 10:58:35 +01:00
|
|
|
var settings = {};
|
|
|
|
|
|
|
|
// global settings divided into
|
|
|
|
// file settings + some global specific
|
|
|
|
// settings
|
|
|
|
|
|
|
|
_.forEach([fsettings, gsettings], function(sets) {
|
|
|
|
for (var i in sets) {
|
2013-02-25 11:50:42 +01:00
|
|
|
if (gexclude.indexOf(i) != -1) continue;
|
2013-02-25 10:58:35 +01:00
|
|
|
|
2014-05-31 19:32:46 +02:00
|
|
|
settings[i] = _.cloneDeep(sets[i]);
|
2013-06-23 22:01:15 +02:00
|
|
|
settings[i].starred = starred.indexOf(i) != -1;
|
2013-02-25 10:58:35 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-02-20 14:12:55 +01:00
|
|
|
for (var i in vals) {
|
2013-02-25 10:58:35 +01:00
|
|
|
if (i in gexclude) continue;
|
|
|
|
|
2013-02-20 14:12:55 +01:00
|
|
|
if (!(i in settings)) {
|
2013-06-23 22:01:15 +02:00
|
|
|
settings[i] = { name: i, val: vals[i], desc: '', starred: starred.indexOf(i) != -1 };
|
2013-02-20 14:12:55 +01:00
|
|
|
}
|
2013-02-25 10:58:35 +01:00
|
|
|
|
2013-02-20 14:12:55 +01:00
|
|
|
else {
|
|
|
|
settings[i].val = vals[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-26 15:02:26 +01:00
|
|
|
modals.invoke(
|
|
|
|
'settings', settings,
|
2014-05-31 19:32:46 +02:00
|
|
|
'Global Settings', 'Save', function(settings) {
|
2013-02-26 15:02:26 +01:00
|
|
|
|
2013-02-20 14:12:55 +01:00
|
|
|
var sets = {};
|
2013-06-23 22:01:15 +02:00
|
|
|
var starred = [];
|
|
|
|
for (var i in settings) {
|
|
|
|
sets[i] = settings[i].val
|
2014-06-02 21:36:21 +02:00
|
|
|
|
2013-06-23 22:01:15 +02:00
|
|
|
if (settings[i].starred) {
|
|
|
|
starred.push(i);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
console.log('saving aria2 starred:', starred);
|
2014-06-02 21:36:21 +02:00
|
|
|
|
2013-02-20 14:12:55 +01:00
|
|
|
rpc.once('changeGlobalOption', [sets]);
|
2013-06-23 22:01:15 +02:00
|
|
|
utils.setCookie('aria2props', starred);
|
2013-02-20 14:12:55 +01:00
|
|
|
});
|
2013-02-20 01:13:06 +01:00
|
|
|
});
|
|
|
|
};
|
2014-02-17 01:13:25 +01:00
|
|
|
|
|
|
|
scope.showServerInfo = function() {
|
|
|
|
modals.invoke(
|
|
|
|
'server_info'
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
scope.showAbout = function() {
|
|
|
|
modals.invoke(
|
|
|
|
'about'
|
|
|
|
);
|
|
|
|
}
|
2014-05-31 19:32:46 +02:00
|
|
|
|
2013-01-15 09:24:09 +01:00
|
|
|
}]);
|