diff --git a/src/c3nav/mesh/static/mesh/js/searchable-select.js b/src/c3nav/mesh/static/mesh/js/searchable-select.js new file mode 100644 index 00000000..cf8b136a --- /dev/null +++ b/src/c3nav/mesh/static/mesh/js/searchable-select.js @@ -0,0 +1,38 @@ +(function () { + function filterOption(option, value) { + if (value === '' || option.text.toLowerCase().includes(value)) { + option.style.display = ''; + return true; + } else { + option.style.display = 'none'; + return false; + } + } + + function performSearch(select, value) { + value = value.toLowerCase().trim(); + for (const child of select.children) { + if (child.nodeName === 'OPTGROUP') { + let any_visible = false; + for (const option of child.children) { + if (option.nodeName !== 'OPTION') continue; + any_visible |= filterOption(option, value); + } + if (!any_visible) { + child.style.display = 'none'; + } else { + child.style.display = ''; + } + } else if (child.nodeName === 'OPTION') { + filterOption(child, value); + } + } + } + + function SearchableSelect(select, search) { + search.addEventListener('input', e => performSearch(select, search.value)); + performSearch(select, search.value); + } + + window.SearchableSelect = SearchableSelect; +})(); \ No newline at end of file diff --git a/src/c3nav/mesh/templates/mesh/mesh_message_send.html b/src/c3nav/mesh/templates/mesh/mesh_message_send.html index 1d29af89..8065d98c 100644 --- a/src/c3nav/mesh/templates/mesh/mesh_message_send.html +++ b/src/c3nav/mesh/templates/mesh/mesh_message_send.html @@ -1,4 +1,5 @@ {% extends 'mesh/base.html' %} +{% load static %} {% load i18n %} {% block heading %} @@ -14,11 +15,28 @@ {% endblock %} {% block subcontent %} +
{% csrf_token %} {{ form.as_div }} {{ form.conditionals | json_script:"form-conditionals" }} + + + + + {% include 'control/fragment_pagination.html' %} @@ -68,25 +91,28 @@ Minor: {{ msg.parsed.content.minor }} {% elif msg.message_type == "CONFIG_HARDWARE" %} - Chip: {{ msg.parsed.content.chip.pretty_name }} rev{{ msg.parsed.content.revision_major }}.{{ msg.parsed.content.revision_minor }} + Chip: {{ msg.parsed.content.chip.pretty_name }} rev + {{ msg.parsed.content.revision_major }}.{{ msg.parsed.content.revision_minor }} {% elif msg.message_type == "CONFIG_BOARD" %} Board: {{ msg.parsed.content.board_config.board.pretty_name }} {% if msg.parsed.content.led %} -
- Status LED: {{ msg.parsed.content.led }} +
+ Status LED: {{ msg.parsed.content.led }} {% endif %} {% if msg.parsed.content.uwb %} -
- UWB: {{ msg.parsed.content.led }} +
+ UWB: {{ msg.parsed.content.led }} {% endif %} {% elif msg.message_type == "CONFIG_FIRMWARE" %} - Firmware: {{ msg.parsed.content.app_desc.project_name }} {{ msg.parsed.content.app_desc.version }} (IDF {{ msg.parsed.content.app_desc.idf_version }}) + Firmware: {{ msg.parsed.content.app_desc.project_name }} + {{ msg.parsed.content.app_desc.version }} (IDF {{ msg.parsed.content.app_desc.idf_version }})
- Compile Date: {{ msg.parsed.content.app_desc.compile_date }} {{ msg.parsed.content.app_desc.compile_time }} + Compile Date: {{ msg.parsed.content.app_desc.compile_date }} + {{ msg.parsed.content.app_desc.compile_time }}
SHA256: {{ msg.parsed.content.app_desc.app_elf_sha256 }} @@ -103,7 +129,8 @@ LED config: {{ msg.parsed.led_config }} {% elif msg.message_type == "CONFIG_POSITION" %} - X={{ msg.parsed.content.x_pos }}, Y={{ msg.parsed.content.y_pos }}, Z={{ msg.parsed.content.z_pos }} + X={{ msg.parsed.content.x_pos }}, Y= + {{ msg.parsed.content.y_pos }}, Z={{ msg.parsed.content.z_pos }} {% elif msg.message_type == "MESH_ADD_DESTINATIONS" or msg.message_type == "MESH_REMOVE_DESTINATIONS" %} adresses:
@@ -171,9 +198,9 @@ {% else %} {% for key, value in msg.data.items %} {% if key != "src" and key != "dst" and key != "msg_type" %} -
- {{ key }}: {{ value }} -
+
+ {{ key }}: {{ value }} +
{% endif %} {% endfor %} {% endif %}