more mesh communication implementation, lots of fixes and stuff
This commit is contained in:
parent
df6efbc8d5
commit
4d3f54bbe8
8 changed files with 260 additions and 94 deletions
|
@ -306,7 +306,7 @@ class MeshMessageFilerForm(Form):
|
|||
required=False,
|
||||
label=_('message types'),
|
||||
)
|
||||
nodes = ModelMultipleChoiceField(
|
||||
src_nodes = ModelMultipleChoiceField(
|
||||
queryset=MeshNode.objects.all(),
|
||||
required=False,
|
||||
label=_('nodes'),
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
{{ form.message_types }}
|
||||
</div>
|
||||
<div class="field">
|
||||
{{ form.nodes }}
|
||||
{{ form.src_nodes }}
|
||||
</div>
|
||||
<div class="field">
|
||||
<button type="submit">Filer</button>
|
||||
|
@ -26,11 +26,12 @@
|
|||
<th>{% trans 'Node' %}</th>
|
||||
<th>{% trans 'Type' %}</th>
|
||||
<th>{% trans 'Data' %}</th>
|
||||
<th>{% trans 'Uplink' %}</th>
|
||||
</tr>
|
||||
{% for msg in mesh_messages %}
|
||||
<tr>
|
||||
<td>{{ msg.datetime }}</td>
|
||||
<td>{{ msg.node }}</td>
|
||||
<td>{{ msg.src_node }}</td>
|
||||
<td>{{ msg.get_message_type_display }}</td>
|
||||
<td>
|
||||
|
||||
|
@ -42,6 +43,7 @@
|
|||
{% endif %}
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td>{{ msg.uplink_node }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
{% block subcontent %}
|
||||
<table>
|
||||
<tr>
|
||||
<th>{% trans 'Address' %}</th>
|
||||
<th>{% trans 'Name' %}</th>
|
||||
<th>{% trans 'Node' %}</th>
|
||||
<th>{% trans 'Status' %}</th>
|
||||
<th>{% trans 'Chip' %}</th>
|
||||
<th>{% trans 'Firmware' %}</th>
|
||||
<th>{% trans 'Last msg' %}</th>
|
||||
|
@ -16,17 +16,30 @@
|
|||
</tr>
|
||||
{% for node in nodes %}
|
||||
<tr>
|
||||
<td>{{ node.address }}</td>
|
||||
<td>{{ node.name }}</td>
|
||||
<td>
|
||||
{{ node.firmware.get_chip_display }}
|
||||
{% if node.route %}
|
||||
<span style="color: green;">{% trans "online" %}</span>
|
||||
{% else %}
|
||||
<span style="color: red;">{% trans "offline" %}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ node }}</td>
|
||||
<td>
|
||||
{{ node.last_messages.CONFIG_FIRMWARE.parsed.get_chip_display }}
|
||||
rev{{ node.last_messages.CONFIG_FIRMWARE.parsed.revision|join:"." }}
|
||||
</td>
|
||||
<td>
|
||||
{{ node.firmware.version }} (IDF {{ node.firmware.idf_version }})
|
||||
{{ node.last_messages.CONFIG_FIRMWARE.parsed.version }}
|
||||
(IDF {{ node.last_messages.CONFIG_FIRMWARE.parsed.idf_version }})
|
||||
</td>
|
||||
<td>
|
||||
{% blocktrans trimmed with timesince=node.last_msg|timesince %}
|
||||
{{ timesince }} ago
|
||||
{% endblocktrans %}
|
||||
</td>
|
||||
<td>{{ node.last_msg }}</td>
|
||||
<td>{{ node.parent }}</td>
|
||||
<td>{{ node.route }}</td>
|
||||
<td>{{ node.last_messages.CONFIG_FIRMWARE.data }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from django.db.models import Max
|
||||
from django.views.generic import ListView
|
||||
from django.views.generic.edit import FormMixin
|
||||
|
||||
from c3nav.control.forms import MeshMessageFilerForm
|
||||
from c3nav.control.views.base import ControlPanelMixin
|
||||
|
@ -14,7 +13,7 @@ class MeshNodeListView(ControlPanelMixin, ListView):
|
|||
context_object_name = "nodes"
|
||||
|
||||
def get_queryset(self):
|
||||
return super().get_queryset().annotate(last_msg=Max('received_messages__datetime'))
|
||||
return super().get_queryset().annotate(last_msg=Max('received_messages__datetime')).prefetch_last_messages()
|
||||
|
||||
|
||||
class MeshMessageListView(ControlPanelMixin, ListView):
|
||||
|
@ -31,8 +30,8 @@ class MeshMessageListView(ControlPanelMixin, ListView):
|
|||
if self.form.is_valid():
|
||||
if self.form.cleaned_data['message_types']:
|
||||
qs = qs.filter(message_type__in=self.form.cleaned_data['message_types'])
|
||||
if self.form.cleaned_data['nodes']:
|
||||
qs = qs.filter(node__in=self.form.cleaned_data['nodes'])
|
||||
if self.form.cleaned_data['src_nodes']:
|
||||
qs = qs.filter(src_node__in=self.form.cleaned_data['src_nodes'])
|
||||
|
||||
return qs
|
||||
|
||||
|
@ -47,4 +46,3 @@ class MeshMessageListView(ControlPanelMixin, ListView):
|
|||
'form_data': form_data.urlencode(),
|
||||
})
|
||||
return ctx
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue