{#- The Device field of a serial side (prefix serial_ / serial_b_), set to `selected`: the mapping form's, and what GET /api/ports/select answers for its ↻ button (the port list again, while the rest of the form stays as it is). `local`: this node's own form (a cluster peer's form lists the peer's ports and has no ↻). `links`: {name: device} for a configured link that is not one of a port's own names (portlist.choice). "Other device path…" lets a path be typed (a port that is not listed, not plugged in yet): app.js then gives the select's name to the text box, so the path is posted as {prefix}port itself and an older cluster peer saves it as it is. -#} {% macro device_field(selected, prefix, ports, local=true, links=none) %} {%- set pick = port_choice(ports, selected, links) %} {%- set p = pick.port %} {%- set by_id = ports | selectattr('by_id') | list %} {%- set by_path = ports | selectattr('by_path') | list %}
{%- if local %} {%- endif %}
{%- if p and p.same_identity %}

⚠ {{ ngettext("%(num)s other connected port has the USB identity of %(port)s (%(id)s), so “Find this device by its USB identity” can't tell them apart.", "%(num)s other connected ports have the USB identity of %(port)s (%(id)s), so “Find this device by its USB identity” can't tell them apart.", p.same_identity | length, port=p.device, id=p.vid ~ ':' ~ p.pid ~ ((' [' ~ p.serial_number ~ ']') if p.serial_number else '')) }}{% if p.by_path %} {{ _("To keep to this adapter, pick its name under “By USB socket”.") }}{% endif %}

{%- endif %} {%- if p and p.ambiguous and pick.as == 'by_id' %}

⚠ {{ _("This by-id name is not unique: an identical adapter can take it at a reboot or a re-plug.") }}{% if p.by_path %} {{ _("Pick the adapter's name under “By USB socket” instead.") }}{% endif %}

{%- endif %}
{% endmacro %} {%- if fragment %}{{ device_field(selected, prefix, ports, true, links) }}{% endif %}