diff --git a/www/js/entities/peer.js b/www/js/entities/peer.js index 6ea32b1b30cbddca29410248e29d2cf7cfbb51c8..198a796e468e8b3e8cc6839060941ee30b1b872b 100644 --- a/www/js/entities/peer.js +++ b/www/js/entities/peer.js @@ -16,8 +16,10 @@ function Peer(json) { Peer.prototype.regex = { BMA: /^BASIC_MERKLED_API[ ]?/, BMAS: /^BMAS[ ]?/, + WS2P: /^WS2P[ ]?/, BMA_REGEXP: /^BASIC_MERKLED_API([ ]+([a-z_][a-z0-9-_.]*))?([ ]+([0-9.]+))?([ ]+([0-9a-f:]+))?([ ]+([0-9]+))$/, BMAS_REGEXP: /^BMAS([ ]+([a-z_][a-z0-9-_.]*))?([ ]+([0-9.]+))?([ ]+([0-9a-f:]+))?([ ]+([0-9]+))$/, + WS2P_REGEXP: /^WS2P[ ]+([a-z0-9]+)([ ]+([a-z_][a-z0-9-_.]*))?([ ]+([0-9.]+))?([ ]+([0-9a-f:]+))?([ ]+([0-9]+))$/, LOCAL_IP_ADDRESS: /^127[.]0[.]0.|192[.]168[.]|10[.]0[.]0[.]|172[.]16[.]/ }; diff --git a/www/js/services/http-services.js b/www/js/services/http-services.js index 0d2109b24e9bea32811b99fd2d9bdaac450f9da5..fdc299876fa45aa16d73b93ba0aa66d25c37357a 100644 --- a/www/js/services/http-services.js +++ b/www/js/services/http-services.js @@ -162,9 +162,9 @@ angular.module('cesium.http.services', ['cesium.cache.services']) return $q.when(delegate); } if (delegate.readyState == 3) { - return $q.reject('Unable to connect to Websocket ['+delegate.url+']'); + return $q.reject('Unable to connect to websocket ['+delegate.url+']'); } - console.debug('[http] Waiting websocket ['+path+'] openning...'); + console.debug('[http] Waiting websocket ['+path+'] opening...'); return $timeout(_waitOpen, 200); } diff --git a/www/plugins/map/js/controllers/network-controllers.js b/www/plugins/map/js/controllers/network-controllers.js index 8016ab9e3a6e27bc9fb1d8887c0f26982a05d072..dd3d3125d5a33c0e0d151dcc95b843a5e691a3e7 100644 --- a/www/plugins/map/js/controllers/network-controllers.js +++ b/www/plugins/map/js/controllers/network-controllers.js @@ -26,6 +26,7 @@ angular.module('cesium.map.network.controllers', ['cesium.services', 'cesium.map controller: 'MapNetworkViewCtrl' } }, + cache: false, data: { silentLocationChange: true } @@ -82,25 +83,26 @@ angular.module('cesium.map.network.controllers', ['cesium.services', 'cesium.map $scope.helptipPrefix = 'helptip-' + $scope.mapId; // make to override, to avoid error during help tour $scope.map = MapUtils.map({ - layers: { - overlays: { - member: { - type: 'featureGroup', - name: 'MAP.NETWORK.VIEW.LAYER.MEMBER', - visible: true - }, - mirror: { - type: 'featureGroup', - name: 'MAP.NETWORK.VIEW.LAYER.MIRROR', - visible: true - }, - offline: { - type: 'featureGroup', - name: 'MAP.NETWORK.VIEW.LAYER.OFFLINE', - visible: true - } + cache: 'map-network', + layers: { + overlays: { + member: { + type: 'featureGroup', + name: 'MAP.NETWORK.VIEW.LAYER.MEMBER', + visible: true + }, + mirror: { + type: 'featureGroup', + name: 'MAP.NETWORK.VIEW.LAYER.MIRROR', + visible: true + }, + offline: { + type: 'featureGroup', + name: 'MAP.NETWORK.VIEW.LAYER.OFFLINE', + visible: true } - }, + } + }, loading: true, markers: {} }); @@ -130,6 +132,14 @@ angular.module('cesium.map.network.controllers', ['cesium.services', 'cesium.map }; $scope.$on('$ionicView.enter', $scope.enter); + // View leave: store map options (center) to cache + $scope.leave = function() { + if ($scope.map.cache) { + MapUtils.cache.save($scope.map); + } + }; + $scope.$on('$ionicView.leave', $scope.leave); + var inheritedComputeOptions = $scope.computeOptions; $scope.computeOptions = function() { var options = inheritedComputeOptions(); diff --git a/www/plugins/map/js/controllers/wot-controllers.js b/www/plugins/map/js/controllers/wot-controllers.js index 4e17f135524e3e91bfffc9d1fc534b1a8fcfd156..4158af5551f711fa8e35f158aa2b4d6a977057fc 100644 --- a/www/plugins/map/js/controllers/wot-controllers.js +++ b/www/plugins/map/js/controllers/wot-controllers.js @@ -26,6 +26,7 @@ angular.module('cesium.map.wot.controllers', ['cesium.services', 'cesium.map.ser controller: 'MapWotViewCtrl' } }, + cache: false, data: { silentLocationChange: true } @@ -73,6 +74,7 @@ angular.module('cesium.map.wot.controllers', ['cesium.services', 'cesium.map.ser $scope.loading = true; $scope.mapId = 'map-wot-' + $scope.$id; $scope.map = MapUtils.map({ + cache: 'map-wot', layers: { overlays: { member: { @@ -95,7 +97,7 @@ angular.module('cesium.map.wot.controllers', ['cesium.services', 'cesium.map.ser bounds: {}, markers: {}, loading: true - }); + }, $scope.mapId); // [NEW] When opening the view $scope.enter = function(e, state) { @@ -103,7 +105,7 @@ angular.module('cesium.map.wot.controllers', ['cesium.services', 'cesium.map.ser // Load the map (and init if need) $scope.loadMap() - .then($scope.load); + .then($scope.load) } else { // Make sur to have previous center coordinate defined in the location URL @@ -112,6 +114,14 @@ angular.module('cesium.map.wot.controllers', ['cesium.services', 'cesium.map.ser }; $scope.$on('$ionicView.enter', $scope.enter); + // View leave: store map options (center) to cache + $scope.leave = function() { + if ($scope.map.cache) { + MapUtils.cache.save($scope.map); + } + }; + $scope.$on('$ionicView.leave', $scope.leave); + $scope.loadMap = function() { return leafletData.getMap($scope.mapId).then(function(map) { if (!$scope.map.loading) return map; // already loaded diff --git a/www/plugins/map/js/services/utils-services.js b/www/plugins/map/js/services/utils-services.js index 9598d691b6dc97eae8933ac6859f95675cb847a5..8e055e6982d574b215cbd05534347b3e4415ddb0 100644 --- a/www/plugins/map/js/services/utils-services.js +++ b/www/plugins/map/js/services/utils-services.js @@ -6,7 +6,7 @@ angular.module('cesium.map.utils.services', ['cesium.services', 'ui-leaflet']) var - googleApiKey = csConfig.plugins && csConfig.plugins.es && csConfig.plugins.es.googleApiKey; + googleApiKey = csConfig.plugins && csConfig.plugins.es && csConfig.plugins.es.googleApiKey, constants = { locations: { FRANCE: { @@ -14,12 +14,16 @@ angular.module('cesium.map.utils.services', ['cesium.services', 'ui-leaflet']) } }, LOCALIZE_ZOOM: 15 + }, + data = { + cache: {} }; constants.DEFAULT_CENTER = csSettings.data && csSettings.data.plugins && csSettings.data.plugins.map && csSettings.data.plugins.map.center || constants.locations.FRANCE; function initMap(options){ options = angular.merge({ center: angular.copy(constants.DEFAULT_CENTER), + cache: false, defaults: { scrollWheelZoom: true }, @@ -52,6 +56,12 @@ angular.module('cesium.map.utils.services', ['cesium.services', 'ui-leaflet']) } }, options || {}); + // Restore existing map options + if (options.cache && data.cache[options.cache]) { + console.debug("Restoring cache :", data.cache[options.cache]); + options = angular.merge(options, data.cache[options.cache]); + } + // Translate overlays name, if any var overlaysNames; if (options.layers.overlays) { @@ -115,6 +125,18 @@ angular.module('cesium.map.utils.services', ['cesium.services', 'ui-leaflet']) return false; } + function saveMapOptions(options) { + if (options.cache) { + data.cache[options.cache] = { + center: options.center, + bounds: options.bounds, + layers: { + baselayers: options.layers.baselayers + } + }; + } + } + // Create a default serach control, with default options function initSearchControl(options) { @@ -167,6 +189,9 @@ angular.module('cesium.map.utils.services', ['cesium.services', 'ui-leaflet']) search: initSearchControl, localizeMe: initLocalizeMeControl }, + cache: { + save: saveMapOptions + }, constants: constants };