2013-01-29 18:52:30 +01:00
|
|
|
angular.module('webui.services.rpc.helpers', [
|
2013-02-22 20:44:10 +01:00
|
|
|
'webui.services.deps', 'webui.services.rpc', 'webui.services.alerts'
|
2013-01-29 18:52:30 +01:00
|
|
|
])
|
2013-02-22 20:44:10 +01:00
|
|
|
.factory('$rpchelpers', ['$_', '$rpc', '$alerts', function(_, rpc, alerts) {
|
2013-03-20 08:45:28 +01:00
|
|
|
var miscellaneous = {version: '', enabledFeatures: []};
|
|
|
|
rpc.once('getVersion', [], function(data) { miscellaneous = data[0]});
|
2013-01-29 18:52:30 +01:00
|
|
|
return {
|
2013-03-20 08:45:28 +01:00
|
|
|
isFeatureEnabled: function(feature) {
|
|
|
|
return miscellaneous.enabledFeatures.indexOf(feature) != -1;
|
|
|
|
},
|
|
|
|
getAria2Version: function() {
|
|
|
|
return miscellaneous.version;
|
|
|
|
},
|
2014-05-31 19:32:46 +02:00
|
|
|
addUris: function(uris, settings) {
|
2013-01-29 18:52:30 +01:00
|
|
|
_.each(uris, function(uri) {
|
|
|
|
// passing true to batch all the addUri calls
|
2014-05-31 19:32:46 +02:00
|
|
|
rpc.once('addUri', [uri, settings], angular.noop, true);
|
2013-01-29 18:52:30 +01:00
|
|
|
});
|
|
|
|
|
2013-01-30 07:13:38 +01:00
|
|
|
// now dispatch all addUri syscalls
|
|
|
|
rpc.forceUpdate();
|
|
|
|
},
|
|
|
|
addTorrents: function(txts) {
|
|
|
|
_.each(txts, function(txt) {
|
|
|
|
// passing true to batch all the addUri calls
|
2013-03-09 06:44:37 +01:00
|
|
|
rpc.once('addTorrent', [txt], angular.noop, true);
|
2013-01-30 07:13:38 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// now dispatch all addUri syscalls
|
|
|
|
rpc.forceUpdate();
|
|
|
|
},
|
|
|
|
addMetalinks: function(txts) {
|
|
|
|
_.each(txts, function(txt) {
|
|
|
|
// passing true to batch all the addUri calls
|
2013-03-09 06:44:37 +01:00
|
|
|
rpc.once('addMetalink', [txt], angular.noop, true);
|
2013-01-30 07:13:38 +01:00
|
|
|
});
|
|
|
|
|
2013-01-29 18:52:30 +01:00
|
|
|
// now dispatch all addUri syscalls
|
|
|
|
rpc.forceUpdate();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}]);
|