Add tooltips to neighbors.

This commit is contained in:
Jason Michalski
2024-05-19 20:50:51 -07:00
parent a2a338a133
commit afad368dac
2 changed files with 16 additions and 5 deletions

View File

@@ -78,8 +78,10 @@
L.polyline(trace).addTo(map);
L.marker(trace[0]).addTo(map);
{% for n in neighbors %}
L.circleMarker({{n | tojson}}).addTo(map);
L.polyline([trace[0], {{n | tojson}}], {color: 'red'}).addTo(map);
var m = L.circleMarker({{n.location | tojson}});
m.bindPopup('SNR: {{n.snr}}<br/><a href="/packet_list/{{n.node_id}}">{{n.node_id | node_id_to_hex}}</a>');
m.addTo(map);
L.polyline([trace[0], {{n.location | tojson}}], {color: 'red'}).addTo(map);
{% endfor %}
</script>
{% endif %}

View File

@@ -41,15 +41,24 @@ async def build_neighbors(node_id):
return []
_, payload = decode_payload.decode(packet)
neighbors = []
results = {}
async with asyncio.TaskGroup() as tg:
for n in payload.neighbors:
results[n.node_id] = {
'node_id': n.node_id,
'snr': n.snr,
}
neighbors.append(tg.create_task(store.get_node(n.node_id)))
result = []
print(results)
for node in [n.result() for n in neighbors]:
if node.last_lat and node.last_long:
result.append((node.last_lat * 1e-7, node.last_long * 1e-7))
return result
results[node.node_id]['location'] = (node.last_lat * 1e-7, node.last_long * 1e-7)
else:
del results[node.node_id]
return list(results.values())
def node_id_to_hex(node_id):