made rpc api angular friendly

This commit is contained in:
hamza zia 2013-03-12 07:51:44 +01:00
parent f10cdb0d1c
commit 9d3daff3b7
4 changed files with 10 additions and 13 deletions

View File

@ -271,7 +271,7 @@
href="#"><i class="icon-cog"></i> Settings</a> href="#"><i class="icon-cog"></i> Settings</a>
</li> </li>
<li ng-show="download.bittorrent"> <li ng-show="download.bittorrent && false">
<a href="#"><i class="icon-list-alt"></i> Peers</a> <a href="#"><i class="icon-list-alt"></i> Peers</a>
</li> </li>

View File

@ -56,22 +56,16 @@ function(
// 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() { utils.mergeMap(data[0], scope.active, scope.getCtx);
utils.mergeMap(data[0], scope.active, scope.getCtx);
});
}); });
rpc.subscribe('tellWaiting', [0, 1000], function(data) { rpc.subscribe('tellWaiting', [0, 1000], function(data) {
scope.$apply(function() { utils.mergeMap(data[0], scope.waiting, scope.getCtx);
utils.mergeMap(data[0], scope.waiting, scope.getCtx);
});
}); });
rpc.subscribe('tellStopped', [0, 1000], function(data) { rpc.subscribe('tellStopped', [0, 1000], function(data) {
scope.$apply(function() { utils.mergeMap(data[0], scope.stopped, scope.getCtx);
utils.mergeMap(data[0], scope.stopped, scope.getCtx);
});
}); });
// actual downloads used by the view // actual downloads used by the view

View File

@ -103,5 +103,4 @@ angular
}); });
}); });
}; };
}]); }]);

View File

@ -3,8 +3,10 @@ angular
'webui.services.rpc.syscall', 'webui.services.constants', 'webui.services.alerts', 'webui.services.rpc.syscall', 'webui.services.constants', 'webui.services.alerts',
'webui.services.utils' 'webui.services.utils'
]) ])
.factory('$rpc', ['$syscall', '$globalTimeout', '$alerts', '$utils', .factory('$rpc', [
function(syscall, time, alerts, utils) { '$syscall', '$globalTimeout', '$alerts', '$utils',
'$rootScope',
function(syscall, time, alerts, utils, rootScope) {
var subscriptions = [] var subscriptions = []
, configurations = [{ host: 'localhost', port: 6800, encrypt: false }] , configurations = [{ host: 'localhost', port: 6800, encrypt: false }]
@ -70,6 +72,8 @@ function(syscall, time, alerts, utils) {
} }
}); });
rootScope.$apply();
if (forceNextUpdate) { if (forceNextUpdate) {
forceNextUpdate = false; forceNextUpdate = false;
timeout = setTimeout(update, 0); timeout = setTimeout(update, 0);