This commit is contained in:
Martin Geno 2016-07-09 02:58:47 +02:00
parent b5555f043d
commit 23fe7f2e0a
7 changed files with 29 additions and 21 deletions

View File

@ -5,3 +5,6 @@ form > .btn+.btn
td.split td.split
span span
display block display block
.map.node
height 300px

View File

@ -9,7 +9,7 @@
a(nav navbar-nav) Nodes a(nav navbar-nav) Nodes
li(ui-sref="app.changes",ui-sref-active="active") li(ui-sref="app.changes",ui-sref-active="active")
a(nav navbar-nav) Changes 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 a(nav navbar-nav) Map
ui.nav.navbar-nav.navbar-right ui.nav.navbar-nav.navbar-right
li li

View File

@ -10,10 +10,10 @@
.form-group(ng-class="rowForm.hostname.$invalid ? 'has-error' : ''") .form-group(ng-class="rowForm.hostname.$invalid ? 'has-error' : ''")
label(for="formHostname") Hostname 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) 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") button.btn.btn-default(type="submit")
span.glyphicon.glyphicon-floppy-disk(aria-hidden="true") span.glyphicon.glyphicon-floppy-disk(aria-hidden="true")
| Save | Save
span.btn.btn-default(ng-click="gps()") // span.btn.btn-default(ng-click="gps()")
span.glyphicon.glyphicon-map-marker(aria-hidden="true") span.glyphicon.glyphicon-map-marker(aria-hidden="true")
| GPS | GPS

View File

@ -12,7 +12,7 @@ angular.module('ffhb')
}); });
function render(prom){ function render(prom){
prom.then(function(data){ 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; data.merged[nodeid].nodeid = nodeid;
return data.merged[nodeid]; return data.merged[nodeid];
}); });

View File

@ -11,7 +11,7 @@ angular.module('ffhb')
}); });
function render(prom){ function render(prom){
prom.then(function(data){ 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; data.merged[nodeid].nodeid = nodeid;
return data.merged[nodeid]; return data.merged[nodeid];
}); });

View File

@ -2,11 +2,11 @@
angular.module('config', []) angular.module('config', [])
.factory('config', function() { .factory('config', function() {
return { return {
api: 'http://mgmt.ffhb.de/api', api: 'https://mgmt.ffhb.de/api',
map: { map: {
view: {lat: 53.0702, lng: 8.815} 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 refresh: 60000
}; };
}); });

View File

@ -24,6 +24,7 @@ angular.module('ffhb')
myservice._initialized = false; myservice._initialized = false;
myservice._data = $cookieStore.get('data') ||{ myservice._data = $cookieStore.get('data') ||{
nodes: {},nodesCount:0, nodes: {},nodesCount:0,
merged: {},
aliases: {},aliasesCount:0 aliases: {},aliasesCount:0
}; };
var geojsonDeferred = $q.defer(); var geojsonDeferred = $q.defer();
@ -32,22 +33,26 @@ angular.module('ffhb')
}); });
myservice.getGeojson = geojsonDeferred.promise; myservice.getGeojson = geojsonDeferred.promise;
myservice.refresh = function() { myservice.refresh = function(notify) {
var dataDeferred = $q.defer(); var dataDeferred = $q.defer();
$http.get(config.api+'/nodes').success(function(nodes) { $http.get(config.api+'/nodes').success(function(nodes) {
$http.get(config.api+'/aliases').success(function(aliases) { $http.get(config.api+'/aliases').success(function(aliases) {
if(notify){
Object.keys(nodes).map(function(key){ Object.keys(nodes).map(function(key){
if(myservice._data.nodes === undefined || myservice._data.nodes[key] === undefined){ if(myservice._data.nodes === undefined || myservice._data.nodes[key] === undefined){
notifyNew(key); notifyNew(key);
} }
if(myservice._data.nodes !== undefined && myservice._data.nodes[key].flags.offline){ if(myservice._data.nodes !== undefined && myservice._data.nodes[key] !== undefined && myservice._data.nodes[key].flags.offline){
notifyOffline(key); notifyOffline(key);
} }
myservice._data.nodes[key] = nodes[key]; myservice._data.nodes[key] = nodes[key];
}); });
}else {
myservice._data.nodes = nodes;
}
angular.copy(nodes, myservice._data.merged); angular.copy(nodes, myservice._data.merged);
Object.keys(aliases).map(function(key){ Object.keys(aliases).map(function(key){
var node = myservice._data.merged[key], var node = myservice._data.nodes[key],
alias = aliases[key]; alias = aliases[key];
node.nodeinfo.hostname = alias.hostname; node.nodeinfo.hostname = alias.hostname;
if(!node.nodeinfo.owner){ if(!node.nodeinfo.owner){
@ -98,7 +103,7 @@ angular.module('ffhb')
myservice.getData = dataDeferred.promise; myservice.getData = dataDeferred.promise;
return dataDeferred.promise; return dataDeferred.promise;
}; };
myservice.refresh(); myservice.refresh(false);
myservice.saveNode = function(nodeid){ myservice.saveNode = function(nodeid){
var result = $q.defer(); var result = $q.defer();
@ -109,7 +114,7 @@ angular.module('ffhb')
'owner':node.owner.contact 'owner':node.owner.contact
}).then(function(){ }).then(function(){
result.resolve(true); result.resolve(true);
myservice.refresh(); myservice.refresh(true);
}); });
}else{ }else{
result.resolve(false); result.resolve(false);
@ -120,7 +125,7 @@ angular.module('ffhb')
if(config.refresh){ if(config.refresh){
$interval(function () { $interval(function () {
myservice.refresh(); myservice.refresh(true);
}, config.refresh); }, config.refresh);
} }