From 9d3daff3b79216b484a06ebea54d2490b778a2cc Mon Sep 17 00:00:00 2001 From: hamza zia Date: Tue, 12 Mar 2013 07:51:44 +0100 Subject: [PATCH] made rpc api angular friendly --- angular.html | 2 +- js/ctrls/download.js | 12 +++--------- js/ctrls/nav.js | 1 - js/services/rpc/rpc.js | 8 ++++++-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/angular.html b/angular.html index 5d1ea5d..daad12f 100644 --- a/angular.html +++ b/angular.html @@ -271,7 +271,7 @@ href="#"> Settings -
  • +
  • Peers
  • diff --git a/js/ctrls/download.js b/js/ctrls/download.js index a3dceff..ef47012 100644 --- a/js/ctrls/download.js +++ b/js/ctrls/download.js @@ -56,22 +56,16 @@ function( // start filling in the model of active, // waiting and stopped download 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) { - 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) { - 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 diff --git a/js/ctrls/nav.js b/js/ctrls/nav.js index 64a15fb..cb57346 100644 --- a/js/ctrls/nav.js +++ b/js/ctrls/nav.js @@ -103,5 +103,4 @@ angular }); }); }; - }]); diff --git a/js/services/rpc/rpc.js b/js/services/rpc/rpc.js index 667303e..3cdb2e5 100644 --- a/js/services/rpc/rpc.js +++ b/js/services/rpc/rpc.js @@ -3,8 +3,10 @@ angular 'webui.services.rpc.syscall', 'webui.services.constants', 'webui.services.alerts', 'webui.services.utils' ]) -.factory('$rpc', ['$syscall', '$globalTimeout', '$alerts', '$utils', -function(syscall, time, alerts, utils) { +.factory('$rpc', [ + '$syscall', '$globalTimeout', '$alerts', '$utils', + '$rootScope', +function(syscall, time, alerts, utils, rootScope) { var subscriptions = [] , configurations = [{ host: 'localhost', port: 6800, encrypt: false }] @@ -70,6 +72,8 @@ function(syscall, time, alerts, utils) { } }); + rootScope.$apply(); + if (forceNextUpdate) { forceNextUpdate = false; timeout = setTimeout(update, 0);