From 23fe7f2e0a8f9362ef0a0ec92364b23158caa52d Mon Sep 17 00:00:00 2001 From: Martin Geno Date: Sat, 9 Jul 2016 02:58:47 +0200 Subject: [PATCH] preview --- public/app/app.styl | 3 +++ public/app/main.jade | 2 +- public/app/node.jade | 4 ++-- public/app/nodes/nodesGroup.js | 2 +- public/app/nodes/nodesSort.js | 2 +- public/components/config.js | 4 ++-- public/components/store.js | 33 +++++++++++++++++++-------------- 7 files changed, 29 insertions(+), 21 deletions(-) diff --git a/public/app/app.styl b/public/app/app.styl index 8f503a8..558eaac 100644 --- a/public/app/app.styl +++ b/public/app/app.styl @@ -5,3 +5,6 @@ form > .btn+.btn td.split span display block + +.map.node + height 300px diff --git a/public/app/main.jade b/public/app/main.jade index 4d2b2f0..d18652d 100644 --- a/public/app/main.jade +++ b/public/app/main.jade @@ -9,7 +9,7 @@ a(nav navbar-nav) Nodes li(ui-sref="app.changes",ui-sref-active="active") a(nav navbar-nav) Changes - li(ui-sref="app.map",ui-sref-active="active") + // li(ui-sref="app.map",ui-sref-active="active") a(nav navbar-nav) Map ui.nav.navbar-nav.navbar-right li diff --git a/public/app/node.jade b/public/app/node.jade index c175fe0..c7659bf 100644 --- a/public/app/node.jade +++ b/public/app/node.jade @@ -10,10 +10,10 @@ .form-group(ng-class="rowForm.hostname.$invalid ? 'has-error' : ''") label(for="formHostname") Hostname input.form-control(id="formHostname",placeholder="Hostname",type="text",name="hostname",pattern="[a-zA-Z0-9-]*",ng-model='node.nodeinfo.hostname',required) - leaflet(geojson=geojson,center=center,markers=markers) + // leaflet.map.node(geojson=geojson,center=center,markers=markers) button.btn.btn-default(type="submit") span.glyphicon.glyphicon-floppy-disk(aria-hidden="true") | Save - span.btn.btn-default(ng-click="gps()") + // span.btn.btn-default(ng-click="gps()") span.glyphicon.glyphicon-map-marker(aria-hidden="true") | GPS diff --git a/public/app/nodes/nodesGroup.js b/public/app/nodes/nodesGroup.js index 0ea23f3..0ddcb5e 100644 --- a/public/app/nodes/nodesGroup.js +++ b/public/app/nodes/nodesGroup.js @@ -12,7 +12,7 @@ angular.module('ffhb') }); function render(prom){ prom.then(function(data){ - var result = Object.keys(data.nodes).map(function(nodeid){ + var result = Object.keys(data.merged).map(function(nodeid){ data.merged[nodeid].nodeid = nodeid; return data.merged[nodeid]; }); diff --git a/public/app/nodes/nodesSort.js b/public/app/nodes/nodesSort.js index 65b1084..c7ccc52 100644 --- a/public/app/nodes/nodesSort.js +++ b/public/app/nodes/nodesSort.js @@ -11,7 +11,7 @@ angular.module('ffhb') }); function render(prom){ prom.then(function(data){ - var result = Object.keys(data.nodes).map(function(nodeid){ + var result = Object.keys(data.merged).map(function(nodeid){ data.merged[nodeid].nodeid = nodeid; return data.merged[nodeid]; }); diff --git a/public/components/config.js b/public/components/config.js index e4c46c0..afb61e5 100644 --- a/public/components/config.js +++ b/public/components/config.js @@ -2,11 +2,11 @@ angular.module('config', []) .factory('config', function() { return { - api: 'http://mgmt.ffhb.de/api', + api: 'https://mgmt.ffhb.de/api', map: { view: {lat: 53.0702, lng: 8.815} }, - geojson: 'https://raw.githubusercontent.com/FreifunkBremen/internal-maps/master/breminale.geojson', + geojson: 'https://meshviewer.breminale.ffhb.de/data/meshviewer.geojson', refresh: 60000 }; }); diff --git a/public/components/store.js b/public/components/store.js index 85b9adf..267680a 100644 --- a/public/components/store.js +++ b/public/components/store.js @@ -24,6 +24,7 @@ angular.module('ffhb') myservice._initialized = false; myservice._data = $cookieStore.get('data') ||{ nodes: {},nodesCount:0, + merged: {}, aliases: {},aliasesCount:0 }; var geojsonDeferred = $q.defer(); @@ -32,22 +33,26 @@ angular.module('ffhb') }); myservice.getGeojson = geojsonDeferred.promise; - myservice.refresh = function() { + myservice.refresh = function(notify) { var dataDeferred = $q.defer(); $http.get(config.api+'/nodes').success(function(nodes) { $http.get(config.api+'/aliases').success(function(aliases) { - Object.keys(nodes).map(function(key){ - if(myservice._data.nodes === undefined || myservice._data.nodes[key] === undefined){ - notifyNew(key); - } - if(myservice._data.nodes !== undefined && myservice._data.nodes[key].flags.offline){ - notifyOffline(key); - } - myservice._data.nodes[key] = nodes[key]; - }); + if(notify){ + Object.keys(nodes).map(function(key){ + if(myservice._data.nodes === undefined || myservice._data.nodes[key] === undefined){ + notifyNew(key); + } + if(myservice._data.nodes !== undefined && myservice._data.nodes[key] !== undefined && myservice._data.nodes[key].flags.offline){ + notifyOffline(key); + } + myservice._data.nodes[key] = nodes[key]; + }); + }else { + myservice._data.nodes = nodes; + } angular.copy(nodes, myservice._data.merged); Object.keys(aliases).map(function(key){ - var node = myservice._data.merged[key], + var node = myservice._data.nodes[key], alias = aliases[key]; node.nodeinfo.hostname = alias.hostname; if(!node.nodeinfo.owner){ @@ -98,7 +103,7 @@ angular.module('ffhb') myservice.getData = dataDeferred.promise; return dataDeferred.promise; }; - myservice.refresh(); + myservice.refresh(false); myservice.saveNode = function(nodeid){ var result = $q.defer(); @@ -109,7 +114,7 @@ angular.module('ffhb') 'owner':node.owner.contact }).then(function(){ result.resolve(true); - myservice.refresh(); + myservice.refresh(true); }); }else{ result.resolve(false); @@ -120,7 +125,7 @@ angular.module('ffhb') if(config.refresh){ $interval(function () { - myservice.refresh(); + myservice.refresh(true); }, config.refresh); }