diff --git a/meshview/templates/map.html b/meshview/templates/map.html index 7b06398..5cfd7fc 100644 --- a/meshview/templates/map.html +++ b/meshview/templates/map.html @@ -57,23 +57,23 @@ var bounds = L.latLngBounds(); var channels = new Set(); // Stores unique channels - var nodes = [ - {% for node in nodes %} - { - lat: {{ node.last_lat / 10**7 if node.last_lat else "null" }}, - long: {{ node.last_long / 10**7 if node.last_long else "null" }}, - long_name: "{{ node.long_name | escape }}", - short_name: "{{ node.short_name | escape }}", - channel: "{{ node.channel | escape }}", - hw_model: "{{ node.hw_model | escape }}", - role: "{{ node.role | escape }}", - last_update: "{{ node.last_update | escape }}", - firmware: "{{ node.firmware | escape }}", - id: "{{ node.node_id }}", - isRouter: "{{ 'router' in node.role.lower() }}" - }, - {% endfor %} - ]; +var nodes = [ +{% for node in nodes %} +{ + lat: {{ (node.last_lat / 10**7)|round(7) }}, + long: {{ (node.last_long / 10**7)|round(7) if node.last_long is not none else "null" }}, + long_name: {{ (node.long_name or "") | tojson }}, + short_name: {{ (node.short_name or "") | tojson }}, + channel: {{ (node.channel or "") | tojson }}, + hw_model: {{ (node.hw_model or "") | tojson }}, + role: {{ (node.role or "") | tojson }}, + last_update: {{ node.last_update | default("", true) | tojson }}, + firmware: {{ (node.firmware or "") | tojson }}, + id: {{ (node.node_id or "") | tojson }}, + isRouter: "{{ 'router' in node.role.lower() }}" +}{{ "," if not loop.last else "" }} +{% endfor %} +]; function timeAgo(date) { var now = new Date(); @@ -197,4 +197,4 @@ -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/meshview/templates/top.html b/meshview/templates/top.html index 8e37faf..f43a201 100644 --- a/meshview/templates/top.html +++ b/meshview/templates/top.html @@ -81,7 +81,12 @@ select { {% endblock %} {% block body %} -

Top Traffic Nodes

+

Top Traffic Nodes (last 24 hours)

+ + +

This chart shows a bell curve (normal distribution) based on the total "Times Seen" values for all nodes. It helps visualize how frequently nodes are heard, relative to the average.

@@ -89,10 +94,6 @@ select {

Mean: - Standard Deviation:

- -
diff --git a/meshview/web.py b/meshview/web.py index f7b3a06..f9e71cd 100644 --- a/meshview/web.py +++ b/meshview/web.py @@ -28,6 +28,7 @@ from meshview import decode_payload from meshview import models from meshview import store from meshview.store import get_total_node_count +import traceback CONFIG = config.CONFIG @@ -1188,15 +1189,25 @@ async def net(request): @routes.get("/map") async def map(request): try: - nodes= await store.get_nodes() + nodes = await store.get_nodes() + + # Filter out nodes with no latitude + nodes = [node for node in nodes if node.last_lat is not None] + + # Optional datetime formatting + for node in nodes: + if hasattr(node, "last_update") and isinstance(node.last_update, datetime.datetime): + node.last_update = node.last_update.isoformat() + print (node.last_update) template = env.get_template("map.html") - print_memory_usage() + return web.Response( - text=template.render(nodes=nodes, site_config = CONFIG), + text=template.render(nodes=nodes, site_config=CONFIG), content_type="text/html", ) except Exception as e: - + import traceback + traceback.print_exc() return web.Response( text="An error occurred while processing your request.", status=500, @@ -1204,6 +1215,7 @@ async def map(request): ) + # Print memory usage def print_memory_usage(): process = psutil.Process(os.getpid())