[TASK] Simplify labellayer & remove unnessary condition
This commit is contained in:
parent
1887a3270c
commit
aa89f06342
@ -154,35 +154,33 @@ define(['leaflet', 'rbush', 'helper', 'moment'],
|
|||||||
var lines = addLinksToMap(linkDict, linkScale, data.links, router);
|
var lines = addLinksToMap(linkDict, linkScale, data.links, router);
|
||||||
groupLines = L.featureGroup(lines).addTo(map);
|
groupLines = L.featureGroup(lines).addTo(map);
|
||||||
|
|
||||||
var nodesOnline = helper.subtract(data.nodes.online, data.nodes.new);
|
var nodesOnline = helper.subtract(data.nodes.online, data.nodes.new).filter(helper.hasLocation);
|
||||||
var nodesOffline = helper.subtract(data.nodes.offline, data.nodes.lost);
|
var nodesOffline = helper.subtract(data.nodes.offline, data.nodes.lost).filter(helper.hasLocation);
|
||||||
|
var nodesNew = data.nodes.new.filter(helper.hasLocation);
|
||||||
|
var nodesLost = data.nodes.lost.filter(helper.hasLocation);
|
||||||
|
|
||||||
var markersOnline = nodesOnline.filter(helper.hasLocation)
|
var markersOnline = nodesOnline.map(mkMarker(nodeDict, function () {
|
||||||
.map(mkMarker(nodeDict, function () {
|
return iconOnline;
|
||||||
return iconOnline;
|
}, router));
|
||||||
}, router));
|
|
||||||
|
|
||||||
var markersOffline = nodesOffline.filter(helper.hasLocation)
|
var markersOffline = nodesOffline.map(mkMarker(nodeDict, function () {
|
||||||
.map(mkMarker(nodeDict, function () {
|
return iconOffline;
|
||||||
return iconOffline;
|
}, router));
|
||||||
}, router));
|
|
||||||
|
|
||||||
var markersNew = data.nodes.new.filter(helper.hasLocation)
|
var markersNew = nodesNew.map(mkMarker(nodeDict, function () {
|
||||||
.map(mkMarker(nodeDict, function () {
|
return iconNew;
|
||||||
return iconNew;
|
}, router));
|
||||||
}, router));
|
|
||||||
|
|
||||||
var markersLost = data.nodes.lost.filter(helper.hasLocation)
|
var markersLost = nodesLost.map(mkMarker(nodeDict, function (d) {
|
||||||
.map(mkMarker(nodeDict, function (d) {
|
var age = moment(data.now).diff(d.lastseen, 'days', true);
|
||||||
if (d.lastseen.isAfter(moment(data.now).subtract(config.maxAgeAlert, 'days'))) {
|
if (age <= config.maxAgeAlert) {
|
||||||
return iconAlert;
|
return iconAlert;
|
||||||
}
|
}
|
||||||
|
if (age <= config.maxAge) {
|
||||||
if (d.lastseen.isAfter(moment(data.now).subtract(config.maxAge, 'days'))) {
|
return iconLost;
|
||||||
return iconLost;
|
}
|
||||||
}
|
return null;
|
||||||
return null;
|
}, router));
|
||||||
}, router));
|
|
||||||
|
|
||||||
groupOffline = L.featureGroup(markersOffline).addTo(map);
|
groupOffline = L.featureGroup(markersOffline).addTo(map);
|
||||||
groupLost = L.featureGroup(markersLost).addTo(map);
|
groupLost = L.featureGroup(markersLost).addTo(map);
|
||||||
@ -190,10 +188,10 @@ define(['leaflet', 'rbush', 'helper', 'moment'],
|
|||||||
groupNew = L.featureGroup(markersNew).addTo(map);
|
groupNew = L.featureGroup(markersNew).addTo(map);
|
||||||
|
|
||||||
this.data = {
|
this.data = {
|
||||||
online: nodesOnline.filter(helper.hasLocation),
|
online: nodesOnline,
|
||||||
offline: nodesOffline.filter(helper.hasLocation),
|
offline: nodesOffline,
|
||||||
new: data.nodes.new.filter(helper.hasLocation),
|
new: nodesNew,
|
||||||
lost: data.nodes.lost.filter(helper.hasLocation)
|
lost: nodesLost
|
||||||
};
|
};
|
||||||
this.updateLayer();
|
this.updateLayer();
|
||||||
},
|
},
|
||||||
|
@ -100,9 +100,7 @@ define(['d3-interpolate', 'snabbdom', 'filters/genericnode', 'helper'],
|
|||||||
});
|
});
|
||||||
|
|
||||||
var autoDict = count(nodes, ['autoupdater'], function (d) {
|
var autoDict = count(nodes, ['autoupdater'], function (d) {
|
||||||
if (d === null) {
|
if (d.enabled) {
|
||||||
return null;
|
|
||||||
} else if (d.enabled) {
|
|
||||||
return d.branch;
|
return d.branch;
|
||||||
}
|
}
|
||||||
return _.t('node.deactivated');
|
return _.t('node.deactivated');
|
||||||
|
Loading…
Reference in New Issue
Block a user