diff --git a/www/css/style.css b/www/css/style.css index 75e098f2bb928f76f1b95150f1e2ff18cb0adbc8..a5ab7ae7c852d22dbcb2d25d4256f5a9fa5162d1 100644 --- a/www/css/style.css +++ b/www/css/style.css @@ -142,25 +142,10 @@ display:none; } - -.item-peer:hover .badge.badge-energized, -.item-peer:hover .badge.badge-balanced -{ - color: #fff !important; -} - -.list .item-peer .badge.badge-secondary, -.list .item-peer .badge .badge-secondary { - top: 31px; - font-size: 10px; - padding-right: 6px; -} - .settings .item-divider { background-color: #f5f5f5; } - .no-margin { margin: 0 !important; } @@ -169,16 +154,30 @@ Network/Peer items **********/ -.item-peer { + +.list .item-peer { padding-top: 9px; padding-bottom: 3px; } -.item-peer .badge { +.list .item-peer .badge { top: 14px; right: 6%; } +.list .item-peer:hover .badge.badge-energized, +.list .item-peer:hover .badge.badge-balanced +{ + color: #fff !important; +} + +.list .item-peer .badge.badge-secondary, +.list .item-peer .badge .badge-secondary { + top: 31px; + font-size: 10px; + padding-right: 6px; +} + /********** Block items **********/ diff --git a/www/index.html b/www/index.html index d8fb8f3e8b410c5613e7668095abab15d9c09d95..bf26b77bba58d438856d193833f54f4aef4adec6 100644 --- a/www/index.html +++ b/www/index.html @@ -201,7 +201,8 @@ <!-- Map plugin --> <script src="dist/dist_js/plugins/map/js/plugin.js"></script> <script src="dist/dist_js/plugins/map/js/services.js"></script> - <script src="dist/dist_js/plugins/map/js/services/data-services.js"></script> + <script src="dist/dist_js/plugins/map/js/services/wot-services.js"></script> + <script src="dist/dist_js/plugins/map/js/services/network-services.js"></script> <script src="dist/dist_js/plugins/map/js/services/utils-services.js"></script> <script src="dist/dist_js/plugins/map/js/controllers/wot-controllers.js"></script> <script src="dist/dist_js/plugins/map/js/controllers/network-controllers.js"></script> diff --git a/www/js/controllers/network-controllers.js b/www/js/controllers/network-controllers.js index a15753985bafd3c0d0fbeef2f0f2e14d310453c3..bd0daf4174c3c312a5ae1d636345a274a8f4745f 100644 --- a/www/js/controllers/network-controllers.js +++ b/www/js/controllers/network-controllers.js @@ -89,7 +89,6 @@ function NetworkLookupController($scope, $state, $ionicHistory, $ionicPopover, UIUtils.onError('ERROR.GET_CURRENCY_FAILED')(err); $scope.networkStarted = false; }); - }; $scope.$on('$ionicParentView.enter', $scope.enter); @@ -422,9 +421,10 @@ function PeerViewController($scope, $q, UIUtils, csWot, BMA) { $scope.loading = true; $scope.$on('$ionicView.enter', function(e, state) { + var isDefaultNode = !state.stateParams || !state.stateParams.server; var server = state.stateParams && state.stateParams.server || BMA.server; - var useSsl = state.stateParams && state.stateParams.ssl == "true" || BMA.useSsl; - var useTor = state.stateParams.tor == "true" || BMA.useTor; + var useSsl = state.stateParams && state.stateParams.ssl == "true" || (isDefaultNode ? BMA.useSsl : false); + var useTor = state.stateParams.tor == "true" || (isDefaultNode ? BMA.useTor : false); return $scope.load(server, useSsl, useTor) .then(function() { diff --git a/www/plugins/map/css/style.css b/www/plugins/map/css/style.css index ae0e4aa695a25d66703b017b152dff92217b1eda..f7cf16a0af44d85396b3d2e9f15d73814f13c042 100644 --- a/www/plugins/map/css/style.css +++ b/www/plugins/map/css/style.css @@ -12,6 +12,7 @@ .legend .outline { border: 0; } + .legend i { width: 16px; height: 16px; @@ -20,37 +21,40 @@ opacity: 0.7; } - -/* Control: Seach - see */ -/*.leaflet-marker-icon {*/ - /*color: #fff;*/ - /*font-size: 16px;*/ - /*line-height: 16px;*/ - /*text-align: center;*/ - /*vertical-align: middle;*/ - /*box-shadow: 2px 1px 4px rgba(0,0,0,0.3);*/ - /*border-radius: 8px;*/ - /*border:1px solid #fff;*/ -/*}*/ .search-tip { white-space: nowrap; } -.search-tip b { - color: #fff; + +/********** + Map network: Peer items +**********/ + +.leaflet-popup .item-peer { + padding-top: 9px; + padding-bottom: 3px; } -.search-tip.member b { - background: #38aadd; /* blue */ + +.leaflet-popup .item.item-icon-left > i.avatar:first-child { + left: 9px; + top: 0; } -.search-tip.wallet b { - background: #a3a3a3; /* lightgray */ + +.leaflet-popup .item-peer .badge { + top: inherit; + bottom: 0px; + right: 5px; + font-size: 12px; } -.search-tip.group b { - background: #71ae26; /* lightgray */ + +.leaflet-popup .item-peer .badge.badge-secondary, +.leaflet-popup .item-peer .badge .badge-secondary { + top: inherit; + bottom: -16px; + right: 5px; + font-size: 9px; + padding-right: 0px; } -.search-tip b { - display: inline-block; - clear: left; - float: right; - padding: 0; - margin-left: 4px; + +.leaflet-popup .item-peer { + overflow: visible; } diff --git a/www/plugins/map/i18n/locale-fr-FR.json b/www/plugins/map/i18n/locale-fr-FR.json index c255003e9730a683343456c56d94c00022524bdf..97bbbd0a815b757a833b401fbade4560b5670565 100644 --- a/www/plugins/map/i18n/locale-fr-FR.json +++ b/www/plugins/map/i18n/locale-fr-FR.json @@ -1,16 +1,19 @@ { "MAP": { + "COMMON": { + "SEARCH_DOTS": "Rechercher...", + }, "NETWORK": { "LOOKUP": { "BTN_MAP": "Carte", "BTN_MAP_HELP": "Ouvrir la carte des noeuds" }, "VIEW": { - "TITLE": "Carte des membres", - "SEARCH_DOTS": "Rechercher...", - "LEGEND": { - "MEMBER": "Membre", - "WALLET": "Non-membres" + "TITLE": "Carte des noeuds", + "LAYER": { + "MEMBER": "NÅ“uds membre", + "MIRROR": "NÅ“uds mirroir", + "OFFLINE": "NÅ“uds hors ligne" } } }, @@ -22,9 +25,9 @@ "VIEW": { "TITLE": "Carte des membres", "SEARCH_DOTS": "Rechercher...", - "LEGEND": { - "MEMBER": "Membre", - "WALLET": "Non-membres" + "LAYER": { + "MEMBER": "Membres", + "WALLET": "Simples portefeuilles" } } }, diff --git a/www/plugins/map/js/controllers/network-controllers.js b/www/plugins/map/js/controllers/network-controllers.js index 21e9c03a695e5bd2cc5bd82c26130a453328cc02..3ec8deed8dfeadd20decd475e2f0cecb7a5fdfab 100644 --- a/www/plugins/map/js/controllers/network-controllers.js +++ b/www/plugins/map/js/controllers/network-controllers.js @@ -35,143 +35,78 @@ angular.module('cesium.map.network.controllers', ['cesium.services', 'cesium.map }) // [NEW] Manage events from the page #/app/wot/map - .controller('MapNetworkViewCtrl', function($scope, $q, $interpolate, $translate, $state, $filter, $templateCache, $timeout, $ionicHistory, - esGeo, UIUtils, MapData, MapUtils, leafletData) { + .controller('MapNetworkViewCtrl', function($scope, $controller, $q, $interpolate, $translate, $state, $filter, $templateCache, $timeout, $ionicHistory, + esGeo, UIUtils, csNetwork, MapUtils, leafletData) { 'ngInject'; + // Initialize the super class and extend it. + angular.extend(this, $controller('NetworkLookupCtrl', {$scope: $scope})); + var + formatPubkey = $filter('formatPubkey'), + markerTemplate = $templateCache.get('plugins/map/templates/network/popup_marker.html'), // Create a hidden layer, to hold search markers - markersSearchLayer = L.layerGroup({visible: false}); + searchLayer = L.layerGroup({visible: false}), + icons= { + member: { + type: 'awesomeMarker', + icon: 'person', + markerColor: 'blue' + }, + mirror: { + type: 'awesomeMarker', + icon: 'android-desktop', + markerColor: 'lightgray' + }, + offline: { + type: 'awesomeMarker', + icon: 'ion-close-circled', + markerColor: 'red' + } + } + ; - $scope.loading = true; $scope.mapId = 'map-network-' + $scope.$id; - $scope.map = MapUtils.map({ layers: { overlays: { member: { type: 'group', - name: 'MAP.WOT.VIEW.LEGEND.MEMBER', + name: 'MAP.NETWORK.VIEW.LAYER.MEMBER', visible: true }, - wallet: { + mirror: { type: 'group', - name: 'MAP.WOT.VIEW.LEGEND.WALLET', + name: 'MAP.NETWORK.VIEW.LAYER.MIRROR', visible: true + }, + offline: { + type: 'group', + name: 'MAP.NETWORK.VIEW.LAYER.OFFLINE', + visible: false } } } }); - // [NEW] When opening the view + var inheritedEnter = $scope.enter; $scope.enter = function(e, state) { - if ($scope.loading) { - console.log("[map] Opening the view... (first time)"); + if ($scope.networkStarted) return; - // remember state, to be able to refresh location - $scope.stateName = state && state.stateName; - $scope.stateParams = angular.copy(state && state.stateParams||{}); + console.log("[map] [network] Opening the view..."); + // remember state, to be able to refresh location + $scope.stateName = state && state.stateName; + $scope.stateParams = angular.copy(state && state.stateParams||{}); - // Read center from state params - var center = MapUtils.center(state.stateParams); + // Read center from state params + $scope.stateCenter = MapUtils.center(state.stateParams); - // Load data - return $scope.load(center); - } + // inherited + return inheritedEnter(e, state); }; $scope.$on('$ionicView.enter', $scope.enter); - // Load markers data - $scope.load = function(center) { - $scope.loading = true; - - // removeIf(no-device) - UIUtils.loading.show(); - // endRemoveIf(no-device) - - return MapData.load() - .then(function(res) { - if (!res || !res.length) { - $scope.loading = false; - return; - } - - var formatPubkey = $filter('formatPubkey'); - var markerTemplate = $templateCache.get('plugins/map/templates/wot/popup_marker.html'); - - // Sort with member first - res = _.sortBy(res, function(hit) { - var score = 0; - score += (!hit.uid) ? 100 : 0; - return -score; - }); - - var markers = res.reduce(function(res, hit) { - var type = hit.uid ? 'member' : 'wallet'; - var shortPubkey = formatPubkey(hit.issuer); - var marker = { - layer: type, - icon: MapUtils.icon(type), - title: hit.title + ' | ' + shortPubkey, - lat: hit.geoPoint.lat, - lng: hit.geoPoint.lon, - getMessageScope: function() { - var scope = $scope.$new(); - scope.hit = hit; - return scope; - }, - focus: false, - message: markerTemplate - }; - res[hit.issuer] = marker; - - // Create a search marker (will be hide) - var searchText = hit.title + ((hit.uid && hit.uid != hit.title) ? (' | ' + hit.uid) : '') + ' | ' + shortPubkey; - var searchMarker = angular.merge({ - type: type, - opacity: 0, - icon: L.divIcon({ - className: type + ' ng-hide', - iconSize: L.point(0, 0) - }) - }, {title: searchText, issuer: hit.issuer, uid: hit.uid, name: hit.title}); - markersSearchLayer.addLayer(new L.Marker({ - lat: hit.geoPoint.lat, - lng: hit.geoPoint.lon - }, - searchMarker)); - return res; - }, {}); - - $scope.map.markers = markers; - $scope.loading = false; - UIUtils.loading.hide(); - - return leafletData.getMap($scope.mapId); - }) - .then(function(map) { - // Update map center (if need) - var needCenterUpdate = center && !angular.equals($scope.map.center, center); - if (needCenterUpdate) { - MapUtils.updateCenter(map, center); - } - - // Add localize me control - MapUtils.control.localizeMe().addTo(map); - - // Add search control - var searchTip = $interpolate($templateCache.get('plugins/map/templates/wot/item_search_tooltip.html')); - MapUtils.control.search({ - layer: markersSearchLayer, - propertyName: 'title', - buildTip: function(text, val) { - return searchTip(val.layer.options); - } - }).addTo(map); - }); - }; - // Update the browser location, to be able to refresh the page $scope.updateLocation = function() { @@ -193,17 +128,6 @@ angular.module('cesium.map.network.controllers', ['cesium.services', 'cesium.map ); }; - $scope.localizeMe = function() { - return esGeo.point.current() - .then(function(res) { - $scope.map.center = { - lat: res.lat, - lng: res.lon, - zoom: 14 - }; - }) - .catch(UIUtils.onError('MAP.ERROR.LOCALIZE_ME_FAILED')); - }; // removeIf(device) $scope.onMapCenterChanged = function() { @@ -214,4 +138,109 @@ angular.module('cesium.map.network.controllers', ['cesium.services', 'cesium.map $scope.$watch('map.center', $scope.onMapCenterChanged, true); // endRemoveIf(device) + $scope.showHelpTip = function() { + // override subclass + }; + + $scope.updateView = function(data) { + console.debug("[map] [peers] Updating UI"); + + $scope.search.results = data.peers; + $scope.search.memberPeersCount = data.memberPeersCount; + // Always tru if network not started (e.g. after leave+renter the view) + $scope.search.loading = !$scope.networkStarted || csNetwork.isBusy(); + + if (!$scope.search.results || !$scope.search.results.length) return; // nothing + + + $q.all(data.peers.reduce(function(res, peer){ + // skip TOR peer + if (peer.isTor()) return res; // already define + if (peer.lat && peer.lng) return res.concat(peer); // already define + var ip = peer.getHost(); + return res.concat(esGeo.point.searchByIP(ip) + .then(function(position){ + return angular.merge(peer, position); + }) + .catch(function(err) { + console.debug('No position found for IP ['+ip+']', err); + return; + })); + }, [])) + .then(function(res) { + var counter = 0; + //var markers = {}; + var markers = []; + _.forEach(res, function(peer) { + if (peer && peer.lat && peer.lng) { + var type = peer.uid ? 'member' : 'mirror'; + var marker = { + layer: type, + icon: icons[type], + opacity: peer.uid ? 0.9 : 0.6, + title: peer.dns || peer.server, + lat: peer.lat, + lng: peer.lng, + draggable: true, + getMessageScope: function() { + var scope = $scope.$new(); + scope.peer = peer; + return scope; + }, + focus: false, + message: markerTemplate + }; + //markers[''+counter++] = marker; + markers.push(marker); + } + }); + + leafletData.getMap($scope.mapId) + .then(function(map) { + + $scope.map.markers = markers; + + // Update map center (if need) + var needCenterUpdate = $scope.stateCenter && !angular.equals($scope.map.center, $scope.stateCenter); + if (needCenterUpdate) { + MapUtils.updateCenter(map, $scope.stateCenter); + delete $scope.stateCenter; + } + + // Add localize me control + /*MapUtils.control.localizeMe().addTo(map); + + // Add search control + var searchTip = $interpolate($templateCache.get('plugins/map/templates/network/item_search_tooltip.html')); + MapUtils.control.search({ + layer: markersSearchLayer, + propertyName: 'title', + buildTip: function(text, val) { + return searchTip(val.layer.options); + } + }).addTo(map);*/ + }); + }) + ; + + // Create a search marker (will be hide) + /* var searchText = hit.title + ((hit.uid && hit.uid != hit.title) ? (' | ' + hit.uid) : '') + ' | ' + shortPubkey; + var searchMarker = angular.merge({ + type: type, + opacity: 0, + icon: L.divIcon({ + className: type + ' ng-hide', + iconSize: L.point(0, 0) + }) + }, {title: searchText, pubkey: hit.pubkey, uid: hit.uid, name: hit.title}); + markersSearchLayer.addLayer(new L.Marker({ + lat: hit.geoPoint.lat, + lng: hit.geoPoint.lon + }, + searchMarker));*/ + //console.log($scope.map.markers); + + + }; + }); diff --git a/www/plugins/map/js/controllers/wot-controllers.js b/www/plugins/map/js/controllers/wot-controllers.js index 9c15dd00061c131b2872ba715c76d10648ba0ad4..6307b24063f7dc13ff6519b13cb4d26b4be17fd2 100644 --- a/www/plugins/map/js/controllers/wot-controllers.js +++ b/www/plugins/map/js/controllers/wot-controllers.js @@ -36,27 +36,48 @@ angular.module('cesium.map.wot.controllers', ['cesium.services', 'cesium.map.ser // [NEW] Manage events from the page #/app/wot/map .controller('MapWotViewCtrl', function($scope, $q, $translate, $state, $filter, $templateCache, $interpolate, $timeout, $ionicHistory, - esGeo, UIUtils, MapUtils, MapData, leafletData) { + esGeo, UIUtils, MapUtils, mapWot, leafletData) { 'ngInject'; var // Create a hidden layer, to hold search markers - markersSearchLayer = L.layerGroup({visible: false}); + markersSearchLayer = L.layerGroup({visible: false}), + icons= { + member: { + type: 'awesomeMarker', + icon: 'person', + markerColor: 'blue' + }, + wallet: { + type: 'awesomeMarker', + icon: 'key', + markerColor: 'lightgray' + }, + group: { + type: 'awesomeMarker', + icon: 'person-stalker', + markerColor: 'green' + }, + registry: { + type: 'awesomeMarker', + icon: 'person-stalker', // TODO + markerColor: 'green' // TODO + } + }; - $scope.init = false; $scope.loading = true; $scope.mapId = 'map-wot-' + $scope.$id; $scope.map = MapUtils.map({ layers: { overlays: { - member: { + wallet: { type: 'group', - name: 'MAP.WOT.VIEW.LEGEND.MEMBER', + name: 'MAP.WOT.VIEW.LAYER.WALLET', visible: true }, - wallet: { + member: { type: 'group', - name: 'MAP.WOT.VIEW.LEGEND.WALLET', + name: 'MAP.WOT.VIEW.LAYER.MEMBER', visible: true } } @@ -89,7 +110,7 @@ angular.module('cesium.map.wot.controllers', ['cesium.services', 'cesium.map.ser UIUtils.loading.show(); // endRemoveIf(no-device) - return MapData.load() + return mapWot.load() .then(function(res) { if (!res || !res.length) { $scope.loading = false; @@ -100,18 +121,19 @@ angular.module('cesium.map.wot.controllers', ['cesium.services', 'cesium.map.ser var markerTemplate = $templateCache.get('plugins/map/templates/wot/popup_marker.html'); // Sort with member first - res = _.sortBy(res, function(hit) { + /*res = _.sortBy(res, function(hit) { var score = 0; score += (!hit.uid) ? 100 : 0; return -score; - }); + });*/ var markers = res.reduce(function(res, hit) { var type = hit.uid ? 'member' : 'wallet'; var shortPubkey = formatPubkey(hit.issuer); var marker = { layer: type, - icon: MapUtils.icon(type), + icon: icons[type], + opacity: 0.8, title: hit.title + ' | ' + shortPubkey, lat: hit.geoPoint.lat, lng: hit.geoPoint.lon, @@ -150,6 +172,8 @@ angular.module('cesium.map.wot.controllers', ['cesium.services', 'cesium.map.ser return leafletData.getMap($scope.mapId); }) .then(function(map) { + if (!map) return; + // Update map center (if need) var needCenterUpdate = center && !angular.equals($scope.map.center, center); if (needCenterUpdate) { @@ -192,18 +216,6 @@ angular.module('cesium.map.wot.controllers', ['cesium.services', 'cesium.map.ser ); }; - $scope.localizeMe = function() { - return esGeo.point.current() - .then(function(res) { - $scope.map.center = { - lat: res.lat, - lng: res.lon, - zoom: 14 - }; - }) - .catch(UIUtils.onError('MAP.ERROR.LOCALIZE_ME_FAILED')); - }; - // removeIf(device) $scope.onMapCenterChanged = function() { if (!$scope.loading) { diff --git a/www/plugins/map/js/services.js b/www/plugins/map/js/services.js index 0d80396e44a950cf213d0cf2d3000cdfb73fd6d4..02aec430c30330b0372f5f5479769c44041d0482 100644 --- a/www/plugins/map/js/services.js +++ b/www/plugins/map/js/services.js @@ -1,7 +1,8 @@ angular.module('cesium.map.services', [ // Services - 'cesium.map.data.services', + 'cesium.map.wot.services', + 'cesium.map.network.services', 'cesium.map.utils.services' ]) ; diff --git a/www/plugins/map/js/services/network-services.js b/www/plugins/map/js/services/network-services.js new file mode 100644 index 0000000000000000000000000000000000000000..5b48ba35a88b2e5a3de7dc16c664191d278c417d --- /dev/null +++ b/www/plugins/map/js/services/network-services.js @@ -0,0 +1,60 @@ + +angular.module('cesium.map.network.services', ['cesium.services']) + +.factory('mapNetwork', function(csHttp, esHttp, csNetwork) { + 'ngInject'; + + var + that = this, + constants = { + DEFAULT_LOAD_SIZE: 1000 + }, + fields = { + profile: ["issuer", "title", "description", "geoPoint"] + }; + + that.raw = { + + }; + + function load(options) { + + csNetwork.start() + var request = { + query: createFilterQuery(options), + from: options.from, + size: options.size, + _source: fields.profile + }; + + return that.raw.profile.postSearch(request) + .then(function(res) { + if (!res.hits || !res.hits.total) return []; + + var commaRegexp = new RegExp('[,]'); + + res = res.hits.hits.reduce(function(res, hit) { + var item = hit._source; + + if (!item.geoPoint || !item.geoPoint.lat || !item.geoPoint.lon) return res; + + // Convert lat/lon to float (if need) + if (item.geoPoint.lat && typeof item.geoPoint.lat === 'string') { + item.geoPoint.lat = parseFloat(item.geoPoint.lat.replace(commaRegexp, '.')); + } + if (item.geoPoint.lon && typeof item.geoPoint.lon === 'string') { + item.geoPoint.lon = parseFloat(item.geoPoint.lon.replace(commaRegexp, '.')); + } + + return res.concat(item); + }, []); + + return csWot.extendAll(res, 'issuer'); + }); + } + + return { + load: load + }; + +}); diff --git a/www/plugins/map/js/services/utils-services.js b/www/plugins/map/js/services/utils-services.js index aa19c3ccc50c50419c29041018ca82a173cd5162..a69d1a3e792f8ee2a53d38153f549fbb65ef3e3c 100644 --- a/www/plugins/map/js/services/utils-services.js +++ b/www/plugins/map/js/services/utils-services.js @@ -10,28 +10,6 @@ angular.module('cesium.map.utils.services', ['cesium.services', 'ui-leaflet']) lat: 46.5588603, lng: 4.229736328124999, zoom: 6 } }, - icons: { - member: { - type: 'awesomeMarker', - icon: 'person', - markerColor: 'blue' - }, - wallet: { - type: 'awesomeMarker', - icon: 'key', - markerColor: 'lightgray' - }, - group: { - type: 'awesomeMarker', - icon: 'person-stalker', - markerColor: 'green' - }, - registry: { - type: 'awesomeMarker', - icon: 'person-stalker', // TODO - markerColor: 'green' // TODO - } - }, LOCALIZE_ZOOM: 14 }; constants.DEFAULT_CENTER = csSettings.data && csSettings.data.plugins && csSettings.data.plugins.map && csSettings.data.plugins.map.center || constants.locations.FRANCE; @@ -81,10 +59,6 @@ angular.module('cesium.map.utils.services', ['cesium.services', 'ui-leaflet']) }, 300); } - function initIcon(type) { - return constants.icons[type]; - } - function initCenter(options) { if (!options) return; var center; @@ -146,7 +120,6 @@ angular.module('cesium.map.utils.services', ['cesium.services', 'ui-leaflet']) return { map: initMap, - icon: initIcon, center: initCenter, updateCenter: updateMapCenter, control: { diff --git a/www/plugins/map/js/services/data-services.js b/www/plugins/map/js/services/wot-services.js similarity index 90% rename from www/plugins/map/js/services/data-services.js rename to www/plugins/map/js/services/wot-services.js index 12802e21906eb36b28a272351b993237e2c03555..264099f25eba85ede15d2af25368cbe333e61e66 100644 --- a/www/plugins/map/js/services/data-services.js +++ b/www/plugins/map/js/services/wot-services.js @@ -1,8 +1,7 @@ -angular.module('cesium.map.data.services', ['cesium.services']) +angular.module('cesium.map.wot.services', ['cesium.services']) -// [NEW] Manage events from the page #/app/wot/map -.factory('MapData', function(csHttp, esHttp, csWot) { +.factory('mapWot', function(csHttp, esHttp, csWot) { 'ngInject'; var diff --git a/www/plugins/map/templates/network/popup_marker.html b/www/plugins/map/templates/network/popup_marker.html index 7e31eecb1861814fa30689a0b2f244ba0867f726..6379f2f2cdc6a0c6fb09901f320fc62f1af3e92e 100644 --- a/www/plugins/map/templates/network/popup_marker.html +++ b/www/plugins/map/templates/network/popup_marker.html @@ -1,18 +1,33 @@ -<div class="item no-border no-padding" ng-class="::{'item-avatar': hit.avatar}"> - <img ng-if="::hit.avatar" class="avatar" ng-src="{{::hit.avatar.src}}"> - <div class="item-content item-avatar-left-padding padding-top"> - <h2 class="dark"><a ui-sref="app.wot_identity({pubkey: hit.issuer, uid: hit.uid})">{{::hit.title}}</a></h2> +<div class="item no-border item-peer item-icon-left no-padding-top"> + + <i class="icon ion-android-desktop" + ng-class="{'balanced': peer.online && peer.hasMainConsensusBlock, 'energized': peer.online && peer.hasConsensusBlock, 'gray': peer.online && !peer.hasConsensusBlock && !peer.hasMainConsensusBlock, 'stable': !peer.online}" + ng-if="!peer.uid || !peer.avatar"></i> + <b class="icon-secondary ion-person" ng-if="!peer.avatar && peer.uid" + ng-class="{'balanced': peer.online && peer.hasMainConsensusBlock, 'energized': peer.online && peer.hasConsensusBlock, 'gray': peer.online && !peer.hasConsensusBlock && !peer.hasMainConsensusBlock, 'stable': !peer.online}" + style="left: 26px; top: -3px;"></b> + <i class="avatar" ng-if="peer.uid && peer.avatar" style="background-image: url('{{peer.avatar.src}}')"></i> + <b class="icon-secondary assertive ion-close-circled" ng-if="!peer.online" style="left: 37px; top: -10px;"></b> + + + <h2 class="dark"><a ng-click="selectPeer(peer)">{{peer.dns||peer.server}}</a></h2> + <h5 class="gray" ng-if="peer.dns && peer.dns != peer.server">{{peer.server}}</h5> <h4> - <span ng-if="::hit.uid" class="positive"> - <i class="icon ion-person"></i> - {{::hit.uid}} - </span> - <span class="assertive" ng-if="!hit.uid"> - {{::'WOT.NOT_MEMBER_PARENTHESIS'|translate}} - </span> + <a ui-sref="app.wot_identity({pubkey: peer.pubkey, uid: peer.uid})"> + <span ng-if="peer.uid" class="positive"> + <i class="ion-person"></i> + {{peer.name||peer.uid}} + </span> + <span ng-if="!peer.uid" class="gray" title="{{peer.pubkey}}"><i class="ion-key"></i> {{peer.pubkey|formatPubkey}} |</span> + </a> + <span ng-if="!peer.uid" class="assertive">{{'PEER.MIRROR'|translate}}</span> </h4> - <h4> - <span class="gray" title="{{::hit.issuer}}"><i class="icon ion-key"></i> {{::hit.issuer|formatPubkey}}</span> - </h4> - </div> + + + <span class="badge" ng-class="{'badge-balanced': peer.hasMainConsensusBlock, 'badge-energized': peer.hasConsensusBlock }">{{peer.currentNumber|formatInteger}}</span> + <span class="badge badge-secondary" ng-if="peer.consensusBlockDelta && expertMode"> + <i class="ion-clock"></i> + {{peer.consensusBlockDelta|formatDurationTime}}</span> + </div> + diff --git a/www/plugins/map/templates/network/view_map.html b/www/plugins/map/templates/network/view_map.html index 13769ef9224eccf56321a092ec9743a877464a3c..1e5338cfffd48c7ad290ae3de0c574870c1ecb0f 100644 --- a/www/plugins/map/templates/network/view_map.html +++ b/www/plugins/map/templates/network/view_map.html @@ -1,10 +1,8 @@ <ion-view left-buttons="leftButtons"> <ion-nav-title> - </ion-nav-title> <ion-nav-buttons side="secondary"> - </ion-nav-buttons> <ion-content data-tap-disabled="true"> @@ -12,8 +10,7 @@ height="100%" center="map.center" markers="map.markers" - layers="map.layers" - controls="map.controls"> + layers="map.layers"> </leaflet> </ion-content> </ion-view> diff --git a/www/plugins/map/templates/wot/view_map.html b/www/plugins/map/templates/wot/view_map.html index 13769ef9224eccf56321a092ec9743a877464a3c..e60fb9807d9c46ff404882f7fa67077805c9de37 100644 --- a/www/plugins/map/templates/wot/view_map.html +++ b/www/plugins/map/templates/wot/view_map.html @@ -12,8 +12,7 @@ height="100%" center="map.center" markers="map.markers" - layers="map.layers" - controls="map.controls"> + layers="map.layers"> </leaflet> </ion-content> </ion-view>