From 2ff4a9a64a293cc8c3f2e941761677812923aca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Tue, 3 Oct 2023 19:09:14 +0200 Subject: [PATCH] some more stuff for mesh control --- .../templates/control/mesh_messages.html | 42 +++++++++++++++---- .../templates/control/mesh_node_detail.html | 35 ++++++++++++++++ .../control/templates/control/mesh_nodes.html | 4 +- src/c3nav/control/urls.py | 3 +- src/c3nav/control/views/mesh.py | 9 +++- 5 files changed, 80 insertions(+), 13 deletions(-) create mode 100644 src/c3nav/control/templates/control/mesh_node_detail.html diff --git a/src/c3nav/control/templates/control/mesh_messages.html b/src/c3nav/control/templates/control/mesh_messages.html index 0f978313..36806408 100644 --- a/src/c3nav/control/templates/control/mesh_messages.html +++ b/src/c3nav/control/templates/control/mesh_messages.html @@ -31,19 +31,43 @@ {% for msg in mesh_messages %} {{ msg.datetime }} - {{ msg.src_node }} + {{ msg.src_node }} {{ msg.get_message_type_display }} + {% if msg.get_message_type_display == "CONFIG_FIRMWARE" %} + Chip: {{ msg.parsed.get_chip_display }} rev{{ msg.parsed.revision|join:"." }} +
+ Firmware: {{ msg.parsed.project_name }} {{ msg.parsed.version }} (IDF {{ msg.parsed.idf_version }}) +
+ Compile Date: {{ msg.parsed.compile_date }} {{ msg.parsed.compile_time }} +
+ SHA256: {{ msg.parsed.app_elf_sha256 }} - {% for key, value in msg.data.items %} - {% if key != "src" and key != "dst" and key != "msg_id" %} -
- {{ key }}: {{ value }} -
- {% endif %} - {% endfor %} + {% elif msg.get_message_type_display == "CONFIG_UPLINK" %} + Enabled: {{ msg.parsed.enabled }}, + SSID: {{ msg.parsed.ssid }}, + Channel: {{ msg.parsed.channel }}
+ Host: {{ msg.parsed.host }}, + Port: {{ msg.parsed.port }}, + UDP: {{ msg.parsed.udp }}, + SSL: {{ msg.parsed.ssl }} + + {% elif msg.get_message_type_display == "CONFIG_LED" %} + LED config: {{ msg.parsed.led_config }} + + {% elif msg.get_message_type_display == "CONFIG_POSITION" %} + X={{ msg.parsed.x_pos }}, Y={{ msg.parsed.y_pos }}, Z={{ msg.parsed.z_pos }} + {% else %} + {% for key, value in msg.data.items %} + {% if key != "src" and key != "dst" and key != "msg_id" %} +
+ {{ key }}: {{ value }} +
+ {% endif %} + {% endfor %} + {% endif %} - {{ msg.uplink_node }} + {{ msg.uplink_node }} {% endfor %} diff --git a/src/c3nav/control/templates/control/mesh_node_detail.html b/src/c3nav/control/templates/control/mesh_node_detail.html new file mode 100644 index 00000000..e9d68112 --- /dev/null +++ b/src/c3nav/control/templates/control/mesh_node_detail.html @@ -0,0 +1,35 @@ +{% extends 'control/base.html' %} +{% load i18n %} + +{% block heading %}{% trans 'Mesh Node' %} {{ node }}{% endblock %} + +{% block subcontent %} +
+
+

Firmware

+ Chip: {{ node.last_messages.CONFIG_FIRMWARE.parsed.get_chip_display }} rev{{ node.last_messages.CONFIG_FIRMWARE.parsed.revision|join:"." }} +
+ Firmware: {{ node.last_messages.CONFIG_FIRMWARE.parsed.project_name }} {{ node.last_messages.CONFIG_FIRMWARE.parsed.version }} (IDF {{ node.last_messages.CONFIG_FIRMWARE.parsed.idf_version }}) +
+ Compile Date: {{ node.last_messages.CONFIG_FIRMWARE.parsed.compile_date }} {{ node.last_messages.CONFIG_FIRMWARE.parsed.compile_time }} +
+ SHA256: {{ node.last_messages.CONFIG_FIRMWARE.parsed.app_elf_sha256 }} +
+
+

Uplink

+ Enabled: {{ node.last_messages.CONFIG_UPLINK.parsed.enabled }}, + SSID: {{ node.last_messages.CONFIG_UPLINK.parsed.ssid }}, + Channel: {{ node.last_messages.CONFIG_UPLINK.parsed.channel }}
+ Host: {{ node.last_messages.CONFIG_UPLINK.parsed.host }}, + Port: {{ node.last_messages.CONFIG_UPLINK.parsed.port }}, + UDP: {{ node.last_messages.CONFIG_UPLINK.parsed.udp }}, + SSL: {{ node.last_messages.CONFIG_UPLINK.parsed.ssl }} + +

Position

+ X={{ node.last_messages.CONFIG_POSITION.parsed.x_pos }}, Y={{ node.last_messages.CONFIG_POSITION.parsed.y_pos }}, Z={{ node.last_messages.CONFIG_POSITION.parsed.z_pos }} + +

LED config

+ {{ node.last_messages.CONFIG_LED.parsed.led_config }} +
+
+{% endblock %} diff --git a/src/c3nav/control/templates/control/mesh_nodes.html b/src/c3nav/control/templates/control/mesh_nodes.html index 2964819f..e71d9327 100644 --- a/src/c3nav/control/templates/control/mesh_nodes.html +++ b/src/c3nav/control/templates/control/mesh_nodes.html @@ -15,7 +15,7 @@ {% for node in nodes %} - {{ node }} + {{ node }} {{ node.last_messages.CONFIG_FIRMWARE.parsed.get_chip_display }} rev{{ node.last_messages.CONFIG_FIRMWARE.parsed.revision|join:"." }} @@ -34,7 +34,7 @@ {{ timesince }} ago {% endblocktrans %} - {{ node.uplink }} + {{ node.uplink }} {% endfor %} diff --git a/src/c3nav/control/urls.py b/src/c3nav/control/urls.py index 19fcb10d..d2d31416 100644 --- a/src/c3nav/control/urls.py +++ b/src/c3nav/control/urls.py @@ -1,6 +1,6 @@ from django.urls import path -from c3nav.control.views.mesh import MeshNodeListView, MeshMessageListView +from c3nav.control.views.mesh import MeshNodeListView, MeshMessageListView, MeshNodeDetailView from c3nav.control.views.mapupdates import map_updates from c3nav.control.views.announcements import announcement_list, announcement_detail from c3nav.control.views.access import grant_access, grant_access_qr @@ -17,5 +17,6 @@ urlpatterns = [ path('mapupdates/', map_updates, name='control.map_updates'), path('mesh/', MeshNodeListView.as_view(), name='control.mesh_nodes'), path('mesh/messages/', MeshMessageListView.as_view(), name='control.mesh_messages'), + path('mesh//', MeshNodeDetailView.as_view(), name='control.mesh_node.detail'), path('', ControlPanelIndexView.as_view(), name='control.index'), ] diff --git a/src/c3nav/control/views/mesh.py b/src/c3nav/control/views/mesh.py index 04b8891d..36b70ce2 100644 --- a/src/c3nav/control/views/mesh.py +++ b/src/c3nav/control/views/mesh.py @@ -1,5 +1,5 @@ from django.db.models import Max -from django.views.generic import ListView +from django.views.generic import ListView, DetailView from c3nav.control.forms import MeshMessageFilerForm from c3nav.control.views.base import ControlPanelMixin @@ -16,6 +16,13 @@ class MeshNodeListView(ControlPanelMixin, ListView): return super().get_queryset().annotate(last_msg=Max('received_messages__datetime')).prefetch_last_messages() +class MeshNodeDetailView(ControlPanelMixin, DetailView): + model = MeshNode + template_name = "control/mesh_node_detail.html" + pk_url_kwargs = "address" + context_object_name = "node" + + class MeshMessageListView(ControlPanelMixin, ListView): model = NodeMessage template_name = "control/mesh_messages.html"