diff --git a/app/config.json b/app/config.json index 575031a1add81b16c0d6c3c33e5eede774cfa4a3..1cb92604900d55d33ba907ab046d783abb52d1e4 100644 --- a/app/config.json +++ b/app/config.json @@ -278,8 +278,8 @@ "en": "license/license_g1-en.txt" }, "node": { - "host": "localhost", - "port": 9600 + "host": "g1.duniter.fr", + "port": 443 }, "fallbackNodes": [{ "host": "g1.duniter.org", @@ -292,7 +292,7 @@ ], "plugins":{ "es": { - "enable": false, + "enable": true, "askEnable": false, "host": "localhost", "port": 9200, diff --git a/www/js/config.js b/www/js/config.js index 0899861842dc1bbcb1af809ac5435e161f53d3b9..04a5851c6e674d1bc4cac397892101ef96ce0543 100644 --- a/www/js/config.js +++ b/www/js/config.js @@ -10,56 +10,49 @@ angular.module("cesium.config", []) .constant("csConfig", { "cacheTimeMs": 300000, - "fallbackLanguage": "en", + "fallbackLanguage": "fr-FR", + "defaultLanguage": "fr-FR", "rememberMe": true, "showUDHistory": true, - "timeout": 30000, + "timeout": 300000, "timeWarningExpireMembership": 5184000, "timeWarningExpire": 7776000, - "keepAuthIlde": 600, "useLocalStorage": true, - "useRelative": false, - "expertMode": false, + "useRelative": true, + "expertMode": true, "decimalCount": 2, - "httpsMode": false, - "shareBaseUrl": "https://g1.duniter.fr", "helptip": { - "enable": true, + "enable": false, "installDocUrl": { "fr-FR": "https://duniter.org/fr/wiki/duniter/installer/", "en": "https://duniter.org/en/wiki/duniter/install/" } }, "license": { - "fr-FR": "license/license_g1-fr-FR", - "en": "license/license_g1-en" + "fr-FR": "license/license_g1-fr-FR.txt", + "en": "license/license_g1-en.txt" }, "node": { "host": "g1.duniter.org", - "port": "443" + "port": 443 }, "fallbackNodes": [ - { - "host": "g1.duniter.fr", - "port": "443" - }, { "host": "g1.duniter.org", - "port": "443" - } - ], - "developers": [ + "port": 443 + }, { - "name": "Benoit Lavenier", - "pubkey": "38MEAZN68Pz1DTvT3tqgxx4yQP6snJCQhPqEFxbDk4aE" + "host": "g1.duniter.fr", + "port": 443 } ], "plugins": { "es": { "enable": true, "askEnable": true, - "host": "g1.data.duniter.fr", - "port": "443", + "host": "localhost", + "port": 9200, + "wsPort": 9400, "fallbackNodes": [ { "host": "g1.data.le-sou.org", @@ -77,11 +70,20 @@ angular.module("cesium.config", []) "certReceived": true }, "defaultCountry": "France" + }, + "graph": { + "enable": true + }, + "neo4j": { + "enable": true + }, + "rml9": { + "enable": true } }, "version": "0.19.0", - "build": "2017-10-27T18:10:53.795Z", + "build": "2017-11-02T09:29:53.441Z", "newIssueUrl": "https://github.com/duniter/cesium/issues/new?labels=bug" }) -; \ No newline at end of file +; diff --git a/www/plugins/es/js/controllers/settings-controllers.js b/www/plugins/es/js/controllers/settings-controllers.js index ac55d11e880171063e75e093006671193d028842..b6b981a8817aaedfa62ac18164632687ff651d3b 100644 --- a/www/plugins/es/js/controllers/settings-controllers.js +++ b/www/plugins/es/js/controllers/settings-controllers.js @@ -74,7 +74,7 @@ function ESPluginSettingsController ($scope, $q, $translate, $ionicPopup, UIUti $scope.formData.enable = wasEnable; } - $scope.temporary = $scope.formData.enable && esHttp.node.isTemporary(); + $scope.isFallbackNode = $scope.formData.enable && esHttp.node.isFallback(); $scope.server = $scope.getServer(esHttp); $scope.loading = false; @@ -82,9 +82,6 @@ function ESPluginSettingsController ($scope, $q, $translate, $ionicPopup, UIUti esSettings.api.state.on.changed($scope, function(enable) { $scope.load(true); - /*$scope.formData.enable = enable; - $scope.temporary = enable && esHttp.node.isTemporary(); - $scope.server = esHttp.server;*/ }); $scope.setPopupForm = function(popupForm) { @@ -133,7 +130,7 @@ function ESPluginSettingsController ($scope, $q, $translate, $ionicPopup, UIUti }) .then(function() { $scope.server = $scope.getServer(esHttp); - $scope.temporary = false; + $scope.isFallbackNode = false; UIUtils.loading.hide(); }); }); diff --git a/www/plugins/es/js/services/http-services.js b/www/plugins/es/js/services/http-services.js index 4b2dedc7a514136e0810ecd241dcbd5efa98e887..b5914cb6449fe6ff4f5097f8bd5f78860b8f20ba 100644 --- a/www/plugins/es/js/services/http-services.js +++ b/www/plugins/es/js/services/http-services.js @@ -29,8 +29,12 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic ES_USER_API_ENDPOINT: exact(constants.ES_USER_API_ENDPOINT) }, fallbackNodeIndex = 0, + listeners, defaultSettingsNode; + that.data = { + isFallback: false + }; that.cache = _emptyCache(); that.api = new Api(this, "esHttp"); that.started = false; @@ -75,10 +79,14 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic } // Say if the ES node is a fallback node or the configured node - function isTemporaryNode() { - return !!that.temporary; + function isFallbackNode() { + return that.data.isFallback; } + // Set fallback flag (e.g. called by ES settings, when resetting settings) + function setIsFallbackNode(isFallback) { + that.data.isFallback = isFallback; + } function exact(regexpContent) { return new RegExp('^' + regexpContent + '$'); @@ -95,6 +103,24 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic }; } + function onSettingsReset(data, deferred) { + deferred = deferred || $q.defer(); + + if (that.data.isFallback) { + // Force a restart + if (that.started) { + that.stop(); + } + } + + // Reset to default values + that.data.isFallback = false; + defaultSettingsNode = null; + + deferred.resolve(data); + return deferred.promise; + } + that.cleanCache = function() { console.debug('[ES] [http] Cleaning requests cache...'); _.keys(that.cache.wsByPath).forEach(function(key) { @@ -104,12 +130,15 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic that.cache = _emptyCache(); }; - that.copy = function(otherNode, skipStart) { + that.copy = function(otherNode) { if (that.started) that.stop(); that.init(otherNode.host, otherNode.port, otherNode.wsPort, otherNode.useSsl || otherNode.port == 443); - return skipStart ? $q.when() : that.start(true /*skipInit*/); + that.data.isTemporary = false; // reset temporary flag + return that.start(true /*skipInit*/); }; + + // Get time (UTC) that.date = { now : csHttp.date.now }; @@ -190,6 +219,7 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic // Alert user if node not reached - fix issue # that.checkNodeAlive = function(alive) { if (alive) { + setIsFallbackNode(!isSameNodeAsSettings()); return true; } if (angular.isUndefined(alive)) { @@ -217,14 +247,12 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic .then(function (confirm) { if (!confirm) return false; // stop the loop - that.temporary = fallbackNode; - that.cleanCache(); - that.copy(fallbackNode, true/*skip start*/); + that.init(fallbackNode.host, fallbackNode.port, fallbackNode.wsPort, fallbackNode.useSsl || fallbackNode.port == 443); - // loop - return that.checkNodeAlive(); // loop + // check is alive then loop + return that.isAlive().then(that.checkNodeAlive); }); }; @@ -243,7 +271,11 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic that._startPromise = csPlatform.ready() .then(function() { - if (!skipInit) that.init(); // Init with defaults settings + + if (!skipInit) { + // Init with defaults settings + that.init(); + } }) .then(function() { console.debug('[ES] [http] Starting on [{0}]{1}...'.format( @@ -252,8 +284,7 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic )); var now = new Date().getTime(); - return that.isAlive() - .then(that.checkNodeAlive) + return that.checkNodeAlive() .then(function(alive) { that.alive = alive; if (!alive) { @@ -263,11 +294,19 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic fallbackNodeIndex = 0; // reset the fallback node counter return false; } + + // Add listeners + addListeners(); + console.debug('[ES] [http] Started in '+(new Date().getTime()-now)+'ms'); that.api.node.raise.start(); + + that.started = true; delete that._startPromise; fallbackNodeIndex = 0; // reset the fallback node counter + + return true; }); }); @@ -277,7 +316,9 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic that.stop = function() { console.debug('[ES] [http] Stopping...'); - delete that.temporary; + removeListeners(); + + setIsFallbackNode(false); // will be re-computed during start phase delete that._startPromise; if (that.alive) { that.cleanCache(); @@ -546,6 +587,21 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic }; } + function addListeners() { + // Watch some service events + listeners = [ + csSettings.api.data.on.reset($rootScope, onSettingsReset, that) + ]; + } + + function removeListeners() { + _.forEach(listeners, function(remove){ + remove(); + }); + listeners = []; + } + + // Define events that.api.registerEvent('node', 'start'); that.api.registerEvent('node', 'stop'); @@ -556,7 +612,7 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic parseEndPoint: parseEndPoint, same: isSameNode, sameAsSettings: isSameNodeAsSettings, - isTemporary: isTemporaryNode + isFallback: isFallbackNode }, record: { post: postRecord, diff --git a/www/plugins/es/js/services/settings-services.js b/www/plugins/es/js/services/settings-services.js index e7c76eeaa2f7a24ecaa82ef404523d81eccf7bc1..c80e1aeba2f046378420de3a5e7d796a712cb114 100644 --- a/www/plugins/es/js/services/settings-services.js +++ b/www/plugins/es/js/services/settings-services.js @@ -54,7 +54,8 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt api = new Api('esSettings'), previousRemoteData, listeners, - ignoreSettingsChanged = false + ignoreSettingsChanged = false, + failEnable = false ; that.api = api; @@ -147,6 +148,7 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt function onSettingsReset(data, deferred) { deferred = deferred || $q.defer(); angular.merge(data, defaultSettings); + failEnable = false; deferred.resolve(data); return deferred.promise; } @@ -190,7 +192,7 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt var wasEnable = listeners && listeners.length > 0; // Force to stop & restart, if ES node has changed - if (esHttp.isStarted() && !esHttp.node.isTemporary() && !esHttp.node.sameAsSettings(data)) { + if (esHttp.isStarted() && !esHttp.node.isFallback() && !esHttp.node.sameAsSettings(data)) { stop(); } @@ -314,13 +316,14 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt } // Enable - else if (enable && (!listeners || listeners.length === 0)) { + else if (enable && (!listeners || listeners.length === 0 || !esHttp.isStarted()) ) { return esHttp.start() .then(function(alive) { if (!alive) { csSettings.data.plugins.es.enable = false; - // Will ask user to enable ES plugins (WARN: is config.js allow it) + // Will ask user to enable ES plugins (WARN: if config.js allow it) csSettings.data.plugins.es.askEnable = true; + failEnable = true; api.state.raise.changed(false); console.error('[ES] [settings] Disable, has ES node could not be started'); @@ -357,10 +360,12 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt .then(function() { // Ask (once) user to enable ES plugin - if (csConfig.plugins && csConfig.plugins.es && csConfig.plugins.es.askEnable && // if config ask enable - csSettings.data.plugins.es && !csSettings.data.plugins.es.enable && // AND user settings has disable plugin + if (!failEnable && // If NOT trying to start just before + csConfig.plugins && csConfig.plugins.es && csConfig.plugins.es.askEnable && // AND if config ask enable + !that.isEnable() && // AND user settings has disable plugin csSettings.data.plugins.es.askEnable // AND user has not yet answer 'NO' ) { + return UIUtils.alert.confirm('ES_SETTINGS.CONFIRM.ASK_ENABLE', 'ES_SETTINGS.CONFIRM.ASK_ENABLE_TITLE', { cancelText: 'COMMON.BTN_NO', diff --git a/www/plugins/es/templates/settings/plugin_settings.html b/www/plugins/es/templates/settings/plugin_settings.html index 67d70c50e38d115d35f3709cd8a39b249de532fc..5c97942bf6f1e22e1fa6f59c7fc2f965e9e62455 100644 --- a/www/plugins/es/templates/settings/plugin_settings.html +++ b/www/plugins/es/templates/settings/plugin_settings.html @@ -21,8 +21,8 @@ {{'ES_SETTINGS.PEER' | translate}} </div> - <!-- node temporary changed --> - <ng-if ng-if="temporary"> + <!-- node fallback node --> + <ng-if ng-if="isFallbackNode"> <h4 class="gray text-wrap assertive" > <i class="icon ion-alert-circled"></i> <span ng-bind-html="'SETTINGS.PEER_CHANGED_TEMPORARY' | translate "></span> @@ -30,7 +30,7 @@ <div class="item-note assertive text-italic">{{server}}</div> </ng-if> - <span ng-if="!temporary" class="item-note" ng-class="{'dark': formData.enable}">{{server}}</span> + <span ng-if="!isFallbackNode" class="item-note" ng-class="{'dark': formData.enable}">{{server}}</span> </div> <span class="item item-divider" translate>ES_SETTINGS.NOTIFICATIONS.DIVIDER</span>