From c3aea99df5caa0002672d1a009aab82b63f2ec73 Mon Sep 17 00:00:00 2001 From: Martin Geno Date: Thu, 14 Jul 2016 16:13:57 +0200 Subject: [PATCH] add heatmap --- Gruntfile.js | 2 +- public/app/index.js | 6 +++--- public/app/map/index.js | 23 ++++++++++++++++++++++- public/index.html | 4 ++-- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 44bcd1c..dcf25ed 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -236,7 +236,7 @@ module.exports = function (grunt) { }, { expand: true, - cwd: 'public/bower_components/leaflet-draw/dist/images', + cwd: 'public/bower_components/leaflet/dist/images', dest: 'build/app/images', src: [ '*.*' diff --git a/public/app/index.js b/public/app/index.js index 3f4a33b..eaf9efe 100644 --- a/public/app/index.js +++ b/public/app/index.js @@ -31,10 +31,10 @@ angular.module('ffhb') templateUrl: 'app/changes.html', controller: 'ChangesCtrl' }) - .state('app.mapwithNodeid',{ - url:'/map/:nodeid', + .state('app.mapedit',{ + url:'/map/edit', templateUrl: 'app/map/index.html', - controller: 'MapCtrl' + controller: 'MapEditCtrl' }) .state('app.map',{ url:'/map', diff --git a/public/app/map/index.js b/public/app/map/index.js index 9c52d3f..d93a697 100644 --- a/public/app/map/index.js +++ b/public/app/map/index.js @@ -5,7 +5,7 @@ angular.module('ffhb') if($stateParams.nodeid){ $scope.nodeid = $stateParams.nodeid.toLowerCase(); } - var layerControl,nodeLayer,geoLayer; + var layerControl,geoLayer,nodeLayer,client24Layer,client5Layer; leafletData.getMap('globalmap').then(function(map) { layerControl = L.control.layers().addTo(map); map.setView([config.map.view.lat, config.map.view.lng],16); @@ -22,15 +22,30 @@ angular.module('ffhb') leafletData.getMap('globalmap').then(function(map) { if(nodeLayer!==undefined){ layerControl.removeLayer(nodeLayer); + nodeLayer.clearLayers(); + } + if(client24Layer!==undefined){ + layerControl.removeLayer(client24Layer); + client24Layer.clearLayers(); + } + if(client5Layer!==undefined){ + layerControl.removeLayer(client5Layer); + client5Layer.clearLayers(); } nodeLayer = L.markerClusterGroup({maxClusterRadius:20}); + client24Layer = L.heatLayer([],{max:30}); + client5Layer = L.heatLayer([],{max:30}); Object.keys(data.merged).map(function(nodeid){ var node = data.merged[nodeid]; if(node.nodeinfo.location !== undefined && node.nodeinfo.location.latitude !== undefined && node.nodeinfo.location.longitude !== undefined){ var className = 'node'; + if(node.flags && !node.flags.online){ + className += ' offline'; + } var wifi24='-',wifi5='-',ch24='-',ch5='-',tx24='-',tx5='-'; if(node.statistics && node.statistics.clients){ wifi24 = node.statistics.clients.wifi24; + if(wifi24 < config.map.icon.warn.wifi24 && wifi24 > 0){ className += ' client24'; } else if(wifi24 < config.map.icon.crit.wifi24 && wifi24 >= config.map.icon.warn.wifi24){ @@ -49,6 +64,8 @@ angular.module('ffhb') } } var nodemarker = L.marker([node.nodeinfo.location.latitude, node.nodeinfo.location.longitude],{icon: L.divIcon({className: className})}); + client24Layer.addLatLng([node.nodeinfo.location.latitude, node.nodeinfo.location.longitude, wifi24]); + client5Layer.addLatLng([node.nodeinfo.location.latitude, node.nodeinfo.location.longitude, wifi5]); nodemarker.bindLabel(node.nodeinfo.hostname+'
('+nodeid+')'+ ''+ ''+ @@ -63,6 +80,10 @@ angular.module('ffhb') } }); layerControl.addOverlay(nodeLayer,'Nodes'); + layerControl.addOverlay(client24Layer,'2.4 Ghz Clients'); + layerControl.addOverlay(client5Layer,'5 Ghz Clients'); + client24Layer.addTo(map); + client5Layer.addTo(map); nodeLayer.addTo(map); }); }); diff --git a/public/index.html b/public/index.html index 9d442a3..6530c4e 100644 --- a/public/index.html +++ b/public/index.html @@ -58,8 +58,7 @@ - - + @@ -67,6 +66,7 @@ +
ClChTx
2.4G'+wifi24+''+ch24+''+tx24+'