some bugfixes for route management
This commit is contained in:
parent
a5d91394e0
commit
18c33a823e
3 changed files with 34 additions and 5 deletions
|
@ -30,7 +30,7 @@
|
|||
</tr>
|
||||
{% for msg in mesh_messages %}
|
||||
<tr>
|
||||
<td>{{ msg.datetime }}</td>
|
||||
<td>{{ msg.datetime.date }} {{ msg.datetime.time|date:"H:i:s" }}</td>
|
||||
<td><a href="{% url "control.mesh_node.detail" pk=msg.src_node.address %}">{{ msg.src_node }}</a></td>
|
||||
<td>{{ msg.get_message_type_display }}</td>
|
||||
<td>
|
||||
|
|
|
@ -11,6 +11,23 @@
|
|||
<strong>Address:</strong> {{ node.address }}<br>
|
||||
<strong>Name:</strong> {% if node.name %}{{ node.name }}{% else %}<em>{% trans '(no name)' %}</em>{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
<strong>Uplink:</strong> <a href="{% url "control.mesh_node.detail" pk=node.uplink.address %}">{{ node.uplink }}</a><br>
|
||||
|
||||
<strong>Last signin:</strong>
|
||||
{{ node.last_signin.date }} {{ node.last_signin.time|date:"H:i:s" }}
|
||||
({% blocktrans trimmed with timesince=node.last_signin|timesince %}
|
||||
{{ timesince }} ago
|
||||
{% endblocktrans %})
|
||||
<br>
|
||||
|
||||
<strong>Last Message:</strong>
|
||||
{{ node.last_msg.date }} {{ node.last_msg.time|date:"H:i:s" }}
|
||||
({% blocktrans trimmed with timesince=node.last_msg|timesince %}
|
||||
{{ timesince }} ago
|
||||
{% endblocktrans %})
|
||||
<br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="button" href="{% url "control.mesh_node.edit" pk=node.pk %}">
|
||||
{% trans 'Edit' %}
|
||||
|
|
|
@ -72,7 +72,7 @@ class MeshConsumer(WebsocketConsumer):
|
|||
})
|
||||
|
||||
# add this node as a destination that this uplink handles (duh)
|
||||
self.add_dst_nodes((src_node.address, ))
|
||||
self.add_dst_nodes(nodes=(src_node, ))
|
||||
|
||||
return
|
||||
|
||||
|
@ -84,10 +84,10 @@ class MeshConsumer(WebsocketConsumer):
|
|||
self.log_received_message(src_node, msg)
|
||||
|
||||
if isinstance(msg, messages.MeshAddDestinationsMessage):
|
||||
self.add_dst_nodes(src_node.mac_addresses)
|
||||
self.add_dst_nodes(addresses=msg.mac_addresses)
|
||||
|
||||
if isinstance(msg, messages.MeshRemoveDestinationsMessage):
|
||||
self.remove_dst_nodes(src_node.mac_addresses)
|
||||
self.remove_dst_nodes(addresses=msg.mac_addresses)
|
||||
|
||||
def mesh_uplink_consumer(self, data):
|
||||
# message handler: if we are not the given uplink, leave this group
|
||||
|
@ -112,7 +112,19 @@ class MeshConsumer(WebsocketConsumer):
|
|||
data=msg.tojson()
|
||||
)
|
||||
|
||||
def add_dst_nodes(self, addresses):
|
||||
def add_dst_nodes(self, nodes=None, addresses=None):
|
||||
nodes = list(nodes) if nodes else []
|
||||
addresses = set(addresses) if addresses else set()
|
||||
|
||||
missing_addresses = addresses - set(node.address for node in nodes)
|
||||
|
||||
if missing_addresses:
|
||||
MeshNode.objects.bulk_create(
|
||||
[MeshNode(address=address) for address in missing_addresses],
|
||||
ignore_conflicts=True
|
||||
)
|
||||
addresses |= missing_addresses
|
||||
|
||||
for address in addresses:
|
||||
# create group name for this address
|
||||
group = get_mesh_comm_group(address)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue