diff --git a/www/api/index.html b/www/api/index.html index d3c3c2d29ee94e797e56feab123060eba72a76b2..e2d4fabf41d4c990a93d8e17b3f61aee6919d459 100644 --- a/www/api/index.html +++ b/www/api/index.html @@ -39,6 +39,8 @@ <script src="../lib/numeral/languages/es.js"></script> <script src="../lib/numeral/languages/it.js"></script> <script src="../js/vendor/numeral.eo.js"></script> +<script src="../lib/qrcode-generator/js/qrcode.js"></script> <!-- FIXME remove this lib (see #903) --> + <script src="../lib/socket.io-client/dist/socket.io.min.js"></script> <script src="../lib/underscore/underscore-min.js"></script> diff --git a/www/js/services/bma-services.js b/www/js/services/bma-services.js index b23484cde9e08169d47de71bba3267f690f20e5b..e045aeb89e01e792f2af0d9e75e32ff6c89efdeb 100644 --- a/www/js/services/bma-services.js +++ b/www/js/services/bma-services.js @@ -300,8 +300,8 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. }; that.ready = function() { - if (that.started) return $q.when(true); - return that._startPromise || that.start(); + if (that.started) return $q.when(that.alive); + return (that._startPromise || that.start()); }; that.start = function() { @@ -321,11 +321,10 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. } console.debug("[BMA] Starting {0} {ssl: {1})...".format(that.server, that.useSsl)); - var now = Date.now(); that._startPromise = $q.all([ - csSettings.ready, + csSettings.ready(), that.isAlive() ]) .then(function(res) { diff --git a/www/js/services/currency-services.js b/www/js/services/currency-services.js index a65054d00054a83f2e69969b345bb2c1fb415887..351953cf297352eb150749d642145f4f95417261 100644 --- a/www/js/services/currency-services.js +++ b/www/js/services/currency-services.js @@ -209,7 +209,7 @@ angular.module('cesium.currency.services', ['ngApi', 'cesium.bma.services']) function ready() { if (started) return $q.when(data); - return startPromise || start(); + return (startPromise || start()); } function stop() { @@ -224,13 +224,30 @@ angular.module('cesium.currency.services', ['ngApi', 'cesium.bma.services']) } function start() { + if (startPromise) return startPromise; + if (started) return $q.when(data); + + if (!BMA.started) { + return BMA.ready() + .then(function(alive) { + if (alive) return start(); // Loop + return $timeout(start, 500); // Loop, after a delay, because BMA node seems to be not alive... + }); + } + console.debug('[currency] Starting...'); var now = Date.now(); startPromise = BMA.ready() + .then(function(started) { + if (started) return true; + return $timeout(function() {return start(true);}, 500); + }) // Load data - .then(loadData) + .then(function(started) { + return loadData(); + }) // Emit ready event .then(function() {