mesh route results
This commit is contained in:
parent
c724833542
commit
0343030980
7 changed files with 170 additions and 47 deletions
|
@ -24,10 +24,10 @@ function connect() {
|
|||
window.setTimeout(connect, 500);
|
||||
}
|
||||
ws.onmessage = (event) => {
|
||||
var data = JSON.parse(event.data), line, text;
|
||||
var data = JSON.parse(event.data), line, text, cell, link_tag;
|
||||
switch(data.type) {
|
||||
case 'mesh.log_entry':
|
||||
line = document.createElement("tr"), cell, link_tag;
|
||||
line = document.createElement("tr");
|
||||
|
||||
cell = document.createElement("td");
|
||||
cell.innerText = data.timestamp;
|
||||
|
@ -37,7 +37,7 @@ function connect() {
|
|||
cell.innerText = data.channel;
|
||||
if (data.uplink) {
|
||||
cell.append(document.createElement("br"));
|
||||
link_tag = document.createElement("a")
|
||||
link_tag = document.createElement("a");
|
||||
link_tag.href = "/control/mesh/" + data.uplink;
|
||||
link_tag.innerText = data.uplink;
|
||||
if (node_names[data.uplink]) {
|
||||
|
@ -48,7 +48,7 @@ function connect() {
|
|||
line.appendChild(cell);
|
||||
|
||||
cell = document.createElement("td");
|
||||
link_tag = document.createElement("a")
|
||||
link_tag = document.createElement("a");
|
||||
link_tag.href = "/control/mesh/" + data.node;
|
||||
link_tag.innerText = data.node;
|
||||
if (node_names[data.node]) {
|
||||
|
@ -73,6 +73,54 @@ function connect() {
|
|||
document.getElementById("sending-status-"+data.recipient).appendChild(line);
|
||||
{% endif %}
|
||||
break;
|
||||
|
||||
case 'mesh.msg_received':
|
||||
{% if send_uuid and msg_type == "MESH_ROUTE_REQUEST" %}
|
||||
if (data.msg.route) {
|
||||
link_tag = document.createElement("a");
|
||||
link_tag.href = "/control/mesh/" + data.msg.src;
|
||||
link_tag.innerText = data.msg.src;
|
||||
if (node_names[data.msg.src]) {
|
||||
link_tag.innerText += " ("+node_names[data.msg.src]+")";
|
||||
}
|
||||
if (data.msg.route === "00:00:00:00:00:00") {
|
||||
line = document.createElement("li");
|
||||
line.appendChild(link_tag);
|
||||
document.getElementById("no-routes").appendChild(line);
|
||||
} else {
|
||||
line = document.createElement("tr");
|
||||
|
||||
cell = document.createElement("td");
|
||||
cell.appendChild(link_tag);
|
||||
line.appendChild(cell);
|
||||
|
||||
cell = document.createElement("td");
|
||||
link_tag = document.createElement("a");
|
||||
link_tag.href = "/control/mesh/" + data.msg.route;
|
||||
link_tag.innerText = data.msg.route;
|
||||
if (node_names[data.msg.route]) {
|
||||
link_tag.innerText += " ("+node_names[data.msg.route]+")";
|
||||
}
|
||||
cell.append(link_tag);
|
||||
line.appendChild(cell);
|
||||
|
||||
document.getElementById("route-responses").appendChild(line);
|
||||
}
|
||||
} else {
|
||||
for (var i=0;i<data.msg.trace.length;i++) {
|
||||
line = document.createElement("li");
|
||||
link_tag = document.createElement("a");
|
||||
link_tag.href = "/control/mesh/" + data.msg.trace[i];
|
||||
link_tag.innerText = data.msg.trace[i];
|
||||
if (node_names[data.msg.trace[i]]) {
|
||||
link_tag.innerText += " ("+node_names[data.msg.trace[i]]+")";
|
||||
}
|
||||
line.appendChild(link_tag);
|
||||
document.getElementById("route-trace").appendChild(line);
|
||||
}
|
||||
}
|
||||
{% endif %}
|
||||
break;
|
||||
}
|
||||
|
||||
console.log(data);
|
||||
|
|
|
@ -9,18 +9,45 @@
|
|||
|
||||
{% block subcontent %}
|
||||
<p><a class="button" href="{{ success_url }}">Go back</a></p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Recipient</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
{% for address, name in recipients %}
|
||||
<tr>
|
||||
<td>{{ address }}{% if name %} ({{ name }}){% endif %}</td>
|
||||
<td id="sending-status-{{ address }}"></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<div class="columns">
|
||||
<div>
|
||||
<h4>Sending progress</h4>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Recipient</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
{% for address, name in recipients %}
|
||||
<tr>
|
||||
<td>{{ address }}{% if name %} ({{ name }}){% endif %}</td>
|
||||
<td id="sending-status-{{ address }}"></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
{% if msg_type == "MESH_ROUTE_REQUEST" %}
|
||||
<div>
|
||||
<h4>Routes</h4>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans 'Node' %}</th>
|
||||
<th>{% trans 'Route' %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="route-responses"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<h4>No Route</h4>
|
||||
<ul id="no-routes"></ul>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Trace</h4>
|
||||
<ul id="route-trace"></ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% include "control/fragment_mesh_websocket.html" %}
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -14,6 +14,7 @@ from c3nav.control.views.base import ControlPanelMixin
|
|||
from c3nav.mesh.forms import MeshMessageForm, MeshNodeForm
|
||||
from c3nav.mesh.messages import MeshMessageType
|
||||
from c3nav.mesh.models import MeshNode, NodeMessage
|
||||
from c3nav.mesh.utils import get_node_names
|
||||
|
||||
|
||||
class MeshNodeListView(ControlPanelMixin, ListView):
|
||||
|
@ -137,9 +138,7 @@ class MeshMessageSendingView(ControlPanelMixin, TemplateView):
|
|||
data = self.request.session["mesh_msg_%s" % uuid]
|
||||
except KeyError:
|
||||
raise Http404
|
||||
node_names = {
|
||||
node.address: node.name for node in MeshNode.objects.all()
|
||||
}
|
||||
node_names = get_node_names()
|
||||
return {
|
||||
**super().get_context_data(),
|
||||
"node_names": node_names,
|
||||
|
@ -156,7 +155,5 @@ class MeshLogView(ControlPanelMixin, TemplateView):
|
|||
def get_context_data(self, **kwargs):
|
||||
return {
|
||||
**super().get_context_data(),
|
||||
"node_names": {
|
||||
node.address: node.name for node in MeshNode.objects.all()
|
||||
}
|
||||
}
|
||||
"node_names": get_node_names(),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue