some work on creating the CONFIG_BOARD form
This commit is contained in:
parent
330a32adf8
commit
e70bd7e0e2
7 changed files with 125 additions and 30 deletions
|
@ -16,8 +16,42 @@
|
|||
{% block subcontent %}
|
||||
<form method="POST" style="max-width:400px;">
|
||||
{% csrf_token %}
|
||||
{{ form }}
|
||||
<noscript><input type="hidden" name="noscript" value"1"></noscript>
|
||||
{{ form.as_div }}
|
||||
{{ form.conditionals | json_script:"form-conditionals" }}
|
||||
<noscript><input type="hidden" name="noscript" value="1"></noscript>
|
||||
<script>
|
||||
var form_conditionals = JSON.parse(document.getElementById('form-conditionals').innerHTML)
|
||||
function update_form() {
|
||||
var field, other_field, value, show;
|
||||
for (field of document.querySelectorAll("select, input[name]")) {
|
||||
show = true;
|
||||
for (elem of form_conditionals) {
|
||||
if (field.name.startsWith(elem.prefix)) {
|
||||
other_field = document.getElementsByName(elem.field)[0];
|
||||
value = (other_field.type == "checkbox") ? other_field.checked : other_field.value;
|
||||
|
||||
console.log({"field": field.name, "filter": elem, "value": value});
|
||||
if (!elem.values.includes(value)) {
|
||||
console.log('no show');
|
||||
show = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
field.parentNode.style.display = show ? "" : "none";
|
||||
}
|
||||
}
|
||||
var done_fields = [];
|
||||
for (elem of form_conditionals) {
|
||||
if (done_fields.includes(elem.field)) continue;
|
||||
done_fields.push(elem.field);
|
||||
field = document.getElementsByName(elem.field)[0];
|
||||
field.addEventListener("input", update_form);
|
||||
field.addEventListener("change", update_form);
|
||||
|
||||
}
|
||||
update_form();
|
||||
</script>
|
||||
<button type="submit">{% trans 'Send' %}</button>
|
||||
</form>
|
||||
|
||||
|
|
|
@ -34,9 +34,10 @@
|
|||
<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>
|
||||
{% if msg.get_message_type_display == "CONFIG_FIRMWARE" %}
|
||||
{% if msg.get_message_type_display == "CONFIG_HARDWARE" %}
|
||||
<strong>Chip:</strong> {{ msg.parsed.get_chip_display }} rev{{ msg.parsed.revision_major }}.{{ msg.parsed.revision_minor }}
|
||||
<br>
|
||||
|
||||
{% elif msg.get_message_type_display == "CONFIG_FIRMWARE" %}
|
||||
<strong>Firmware:</strong> {{ msg.parsed.app_desc.project_name }} {{ msg.parsed.app_desc.version }} (IDF {{ msg.parsed.app_desc.idf_version }})
|
||||
<br>
|
||||
<strong>Compile Date:</strong> {{ msg.parsed.app_desc.compile_date }} {{ msg.parsed.app_desc.compile_time }}
|
||||
|
|
|
@ -40,11 +40,13 @@
|
|||
</a>
|
||||
</p>
|
||||
|
||||
<h4>Hardware</h4>
|
||||
<p>
|
||||
<strong>Chip:</strong> {{ node.last_messages.CONFIG_HARDWARE.parsed.get_chip_display }}
|
||||
rev{{ node.last_messages.CONFIG_HARDWARE.parsed.revision_major }}.{{ node.last_messages.CONFIG_HARDWARE.parsed.revision_minor }}
|
||||
</p>
|
||||
<h4>Firmware</h4>
|
||||
<p>
|
||||
<strong>Chip:</strong> {{ node.last_messages.CONFIG_FIRMWARE.parsed.get_chip_display }}
|
||||
rev{{ node.last_messages.CONFIG_FIRMWARE.parsed.revision_major }}.{{ node.last_messages.CONFIG_FIRMWARE.parsed.revision_minor }}
|
||||
<br>
|
||||
<strong>Firmware:</strong> {{ node.last_messages.CONFIG_FIRMWARE.parsed.app_desc.project_name }} {{ node.last_messages.CONFIG_FIRMWARE.parsed.version }} (IDF {{ node.last_messages.CONFIG_FIRMWARE.parsed.app_desc.idf_version }})
|
||||
<br>
|
||||
<strong>Compile Date:</strong> {{ node.last_messages.CONFIG_FIRMWARE.parsed.app_desc.compile_date }} {{ node.last_messages.CONFIG_FIRMWARE.parsed.app_desc.compile_time }}
|
||||
|
|
|
@ -45,8 +45,8 @@
|
|||
<tr>
|
||||
<td><a href="{% url "control.mesh.node.detail" pk=node.address %}">{{ node }}</a></td>
|
||||
<td>
|
||||
{{ node.last_messages.CONFIG_FIRMWARE.parsed.get_chip_display }}
|
||||
<small>rev{{ node.last_messages.CONFIG_FIRMWARE.parsed.revision_major }}.{{ node.last_messages.CONFIG_FIRMWARE.parsed.revision_minor }}</small>
|
||||
{{ node.last_messages.CONFIG_HARDWARE.parsed.get_chip_display }}
|
||||
<small>rev{{ node.last_messages.CONFIG_HARDWARE.parsed.revision_major }}.{{ node.last_messages.CONFIG_HARDWARE.parsed.revision_minor }}</small>
|
||||
</td>
|
||||
<td>
|
||||
{{ node.last_messages.CONFIG_FIRMWARE.parsed.app_desc.version }}
|
||||
|
|
|
@ -145,6 +145,10 @@ class MeshMessageSendView(ControlPanelMixin, FormView):
|
|||
messages.success(self.request, _('Message sent successfully(?)'))
|
||||
super().form_valid(form)
|
||||
uuid = uuid4()
|
||||
from pprint import pprint
|
||||
pprint(form.get_msg_data())
|
||||
pprint(MeshMessage.fromjson(form.get_msg_data()))
|
||||
1/0
|
||||
self.request.session["mesh_msg_%s" % uuid] = {
|
||||
"success_url": self.get_success_url(),
|
||||
"recipients": form.get_recipients(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue