From 8ce672c5abbfb03341fa5b8a5d94aa2a8c763939 Mon Sep 17 00:00:00 2001 From: Pablo Revilla Date: Wed, 7 May 2025 21:43:01 -0700 Subject: [PATCH] Merge all Graphs into one section --- meshview/templates/base.html | 4 +- meshview/templates/nodegraph.html | 164 +++++++++++++++++++----------- meshview/web.py | 29 ++---- sample.config.ini | 4 +- 4 files changed, 114 insertions(+), 87 deletions(-) diff --git a/meshview/templates/base.html b/meshview/templates/base.html index b45b3ac..bd75266 100644 --- a/meshview/templates/base.html +++ b/meshview/templates/base.html @@ -39,9 +39,7 @@ {% if site_config["site"]["nodes"] == "True" %}Nodes - {% endif %} {% if site_config["site"]["conversations"] == "True" %}Conversations - {% endif %} {% if site_config["site"]["everything"] == "True" %}See everything - {% endif %} - {% if site_config["site"]["graph_lf"] == "True" %} Mesh Graph: LF - {% endif %} - {% if site_config["site"]["graph_ms"] == "True" %}MS - {% endif %} - {% if site_config["site"]["graph_mf"] == "True" %}MF - {% endif %} + {% if site_config["site"]["graphs"] == "True" %}Mesh Graphs - {% endif %} {% if site_config["site"]["net"] == "True" %}Weekly Net - {% endif %} {% if site_config["site"]["map"] == "True" %}Map - {% endif %} {% if site_config["site"]["stats"] == "True" %}Stats - {% endif %} diff --git a/meshview/templates/nodegraph.html b/meshview/templates/nodegraph.html index b2485ca..78129b0 100644 --- a/meshview/templates/nodegraph.html +++ b/meshview/templates/nodegraph.html @@ -20,19 +20,19 @@ left: 10px; z-index: 10; display: flex; + flex-direction: column; gap: 5px; } -.search-container input { +.search-container input, +.search-container select, +.search-container button { padding: 8px; border-radius: 8px; border: 1px solid #ccc; } .search-container button { - padding: 8px 12px; - border-radius: 8px; - border: none; background-color: #007bff; color: white; cursor: pointer; @@ -80,13 +80,15 @@ {% endblock %} {% block body %} - -
+
+ +
+
Long Name:
Short Name:
@@ -99,11 +101,10 @@
Neighbor
- {% endblock %} diff --git a/meshview/web.py b/meshview/web.py index 3acbcf7..67aa072 100644 --- a/meshview/web.py +++ b/meshview/web.py @@ -1262,50 +1262,35 @@ async def top(request): content_type="text/plain", ) - - @routes.get("/chat") async def chat(request): try: - # Fetch packets for the given node ID and port number packets = await store.get_packets( node_id=0xFFFFFFFF, portnum=PortNum.TEXT_MESSAGE_APP, limit=100 ) - #print(f"Fetched {len(packets)} packets.") - # Convert packets to UI packets - #print("Processing packets...") ui_packets = [Packet.from_model(p) for p in packets] - - # Filter packets - #print("Filtering packets...") filtered_packets = [ - p for p in ui_packets if not re.match(r"seq \d+$", p.payload) + p for p in ui_packets if not re.fullmatch(r"seq \d+", p.payload) ] - - # Render template - #print("Rendering template...") + #print("Example packet:", filtered_packets) template = env.get_template("chat.html") return web.Response( - text=template.render(packets=filtered_packets, site_config = CONFIG), + text=template.render(packets=filtered_packets, site_config=CONFIG), content_type="text/html", ) - except Exception as e: - # Log the error and return an appropriate response - #print(f"Error in chat handler: {e}") + print("Error in /chat:", e) return web.Response( text="An error occurred while processing your request.", status=500, content_type="text/plain", ) - -# Assuming the route URL structure is /nodegraph/{channel} -@routes.get("/nodegraph/{channel}") +# Assuming the route URL structure is /nodegraph +@routes.get("/nodegraph") async def nodegraph(request): - channel = request.match_info.get('channel', 'LongFast') # Default to 'MediumSlow' if no channel is provided - nodes = await store.get_nodes(channel=channel) # Fetch nodes for the given channel + nodes = await store.get_nodes(days_active=3) # Fetch nodes for the given channel node_ids = set() edges_set = set() # Track unique edges edge_type = {} # Store type of each edge diff --git a/sample.config.ini b/sample.config.ini index 680b275..72170ea 100644 --- a/sample.config.ini +++ b/sample.config.ini @@ -15,9 +15,7 @@ message = Real time data from around the bay area and beyond. nodes=True conversations=True everything=True -graph_lf=True -graph_ms=True -graph_mf=False +graphs=True stats=True net=True map=True