Add node role to the info box.

This commit is contained in:
Jason Michalski
2024-06-15 19:31:46 -07:00
parent b24b829fb1
commit 96db2e0970
3 changed files with 11 additions and 1 deletions

View File

@@ -17,6 +17,7 @@ class Node(Base):
long_name: Mapped[str]
short_name: Mapped[str]
hw_model: Mapped[str]
role: Mapped[str] = mapped_column(nullable=True)
last_lat: Mapped[int] = mapped_column(BigInteger, nullable=True)
last_long: Mapped[int] = mapped_column(BigInteger, nullable=True)

View File

@@ -2,6 +2,7 @@ import datetime
from sqlalchemy import select
from meshtastic.config_pb2 import Config
from meshtastic.portnums_pb2 import PortNum
from meshtastic.mesh_pb2 import User, HardwareModel
from meshview import database
@@ -71,12 +72,17 @@ async def process_envelope(topic, env):
hw_model = HardwareModel.Name(user.hw_model)
except ValueError:
hw_model = "unknown"
try:
role = Config.DeviceConfig.Role.Name(user.role)
except ValueError:
role = "unknown"
if node := result.scalar_one_or_none():
node.node_id = node_id
node.long_name = user.long_name
node.short_name = user.short_name
node.hw_model = hw_model
node.role = role
else:
node = Node(
id=user.id,
@@ -84,8 +90,9 @@ async def process_envelope(topic, env):
long_name=user.long_name,
short_name=user.short_name,
hw_model=hw_model,
role=role,
)
session.add(node)
session.add(node)
if env.packet.decoded.portnum == PortNum.POSITION_APP:
position = decode_payload.decode_payload(

View File

@@ -44,6 +44,8 @@
<dd>{{node.short_name}}</dd>
<dt>hw model</dt>
<dd>{{node.hw_model}}</dd>
<dt>role</dt>
<dd>{{node.role}}</dd>
</dl>
{% if has_telemetry %}
<a href="/graph/power/{{node_id}}"><img src="/graph/power/{{node_id}}" height="200em" width="200em"/></a>