diff --git a/README b/README index d4c2f7f..6e3b32e 100644 --- a/README +++ b/README @@ -26,3 +26,5 @@ Other Options: --topic MQTT Topic, default is 'msh/US/bayarea/#' +Screenshots +![Main PAge](/images/main.png) \ No newline at end of file diff --git a/meshview/store.py b/meshview/store.py index 3c5dec4..e0ff9df 100644 --- a/meshview/store.py +++ b/meshview/store.py @@ -506,19 +506,52 @@ async def get_nodes_mediumslow(): (Node.channel == "MediumSlow") ) ) + return result.scalars() +async def get_nodes(role=None, channel=None, hw_model=None): + """ + Fetches nodes from the database based on optional filtering criteria. -async def get_nodes(): - async with database.async_session() as session: - result = await session.execute( - select(Node) - .where(Node.last_update != "") - .order_by(Node.long_name) # Sorting by long_name - ) - return result.scalars() - + Parameters: + role (str, optional): The role of the node (converted to uppercase for consistency). + channel (str, optional): The communication channel associated with the node. + hw_model (str, optional): The hardware model of the node. + + Returns: + list: A list of Node objects that match the given criteria. + """ + try: + async with database.async_session() as session: + print(channel) # Debugging output (consider replacing with logging) + + # Start with a base query selecting all nodes + query = select(Node) + + # Apply filters based on provided parameters + if role is not None: + query = query.where(Node.role == role.upper()) # Ensure role is uppercase + if channel is not None: + query = query.where(Node.channel == channel) + if hw_model is not None: + query = query.where(Node.hw_model == hw_model) + + # Exclude nodes where last_update is an empty string + query = query.where(Node.last_update != "") + + # Order results by long_name in ascending order + query = query.order_by(Node.long_name.asc()) + + # Execute the query and retrieve results + result = await session.execute(query) + nodes = result.scalars().all() + + return nodes # Return the list of nodes + + except Exception as e: + print("error reading DB") # Consider using logging instead of print + return [] # Return an empty list in case of failure diff --git a/meshview/templates/base.html b/meshview/templates/base.html index 0c40b77..e99f6e3 100644 --- a/meshview/templates/base.html +++ b/meshview/templates/base.html @@ -34,7 +34,7 @@
Bay Area Mesh - http://bayme.sh
-
Quick Links:  Search for a node  - Conversations - See everything  - Mesh Graph LG - MS  - Nodes - Stats

+
Quick Links:  Search for a node  - Conversations - See everything  - Mesh Graph LF - MS  - Nodes - Stats

Loading...
diff --git a/meshview/templates/nodelist.html b/meshview/templates/nodelist.html index f175b60..dd97b38 100644 --- a/meshview/templates/nodelist.html +++ b/meshview/templates/nodelist.html @@ -33,7 +33,6 @@ tr:nth-child(odd) { - @@ -48,16 +47,15 @@ tr:nth-child(odd) { {% for node in nodes %} - - + - + - - - - - + + + + + {% endfor %} diff --git a/meshview/web.py b/meshview/web.py index a77b559..05a7658 100644 --- a/meshview/web.py +++ b/meshview/web.py @@ -1261,7 +1261,7 @@ async def graph_network_longfast(request): if edge_type[(src, dest)] in ('ni'): color = '#FF0000' elif edge_type[(src, dest)] in ('sni'): - color = '#00FF00' + color = '#040fb3' else: color = '#000000' edge_dir = "forward" @@ -1296,7 +1296,7 @@ async def graph_network_longfast(request): async def graph_network_mediumslow(request): try: root = request.query.get("root") - depth = int(request.query.get("depth", 5)) + depth = int(request.query.get("depth", 3)) hours = int(request.query.get("hours", 24)) minutes = int(request.query.get("minutes", 0)) @@ -1423,6 +1423,7 @@ async def graph_network_mediumslow(request): label=node_name, shape='box', color=color, + fontsize="10", width="0", height="0", href=f"/graph/mediumslow?root={node_id}&depth={depth-1}", )) @@ -1441,7 +1442,7 @@ async def graph_network_mediumslow(request): if edge_type[(src, dest)] in ('ni'): color = '#FF0000' elif edge_type[(src, dest)] in ('sni'): - color = '#00FF00' + color = '#040fb3' else: color = '#000000' edge_dir = "forward" @@ -1456,8 +1457,9 @@ async def graph_network_mediumslow(request): str(dest), color=color, tooltip=f'{await get_node_name(src)} -> {await get_node_name(dest)}', - penwidth=1.85, + penwidth=.5, dir=edge_dir, + arrowsize=".5", )) return web.Response( @@ -1472,7 +1474,13 @@ async def graph_network_mediumslow(request): @routes.get("/nodelist") async def nodelist(request): try: - nodes= await store.get_nodes() + role = request.query.get("role") + #print(role) + channel = request.query.get("channel") + print(channel) + hw_model = request.query.get("hw_model") + print(hw_model) + nodes= await store.get_nodes(role,channel, hw_model) template = env.get_template("nodelist.html") return web.Response( text=template.render(nodes=nodes),
Node ID Long Name Short Name HW Model
{{node.node_id }}{{ node.long_name }} {{node.long_name}} {{ node.short_name }}{{ node.hw_model }}{{node.hw_model if node.hw_model else "N/A"}} {{ node.firmware }}{{ node.role if node.role else "N/A" }}{{ node.last_lat if node.last_lat else "N/A" }}{{ node.last_long if node.last_long else "N/A" }}{{ node.channel }}{{ node.last_update.strftime('%-I:%M:%S %p - %d-%m-%Y') if node.last_update else "N/A" }}{{node.role if node.role else "N/A"}}{{ "{:.7f}".format(node.last_lat / 10**7) if node.last_lat else "N/A" }}{{ "{:.7f}".format(node.last_long / 10**7) if node.last_long else "N/A" }}{{node.channel if node.channel else "N/A"}}{{ node.last_update.strftime('%-I:%M:%S %p - %m-%d-%Y') if node.last_update else "N/A" }}