1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-08 19:26:48 +00:00
webvirtcloud/interfaces/templates/create_iface_block.html
catborise 3a4488d34f fix(templates): pages parse without markup errors, element IDs are unique
Rendered through every URL on libvirt's test driver, the pages had
duplicate IDs and markup browsers repaired silently:

- Each flavor modal's "Advanced" button toggled #flav-add-collapse, the
  first modal's section; every modal now has its own. The flavor and
  template copies of the custom tab's control IDs, and the template
  tab's unused images input, are gone.
- The VM page's action icons and the XML editors were styled by
  repeated IDs; they use classes.
- Modal forms opened inside modal-body and closed after modal-footer;
  they wrap both. Stray end tags and duplicate attributes are removed,
  paragraphs no longer hold modals or rows, table heads have a row, and
  the create page closes its row and column.
- html lang is the active language instead of "en".

A test walks every URL as a superuser and fails on a repeated ID. The
console page still has no doctype: its full-height layout relies on
quirks mode and needs its own check.
2026-10-19 07:49:25 +03:00

150 lines
No EOL
9.4 KiB
HTML

{% load i18n %}
{% load bootstrap_icons %}
{% if request.user.is_superuser %}
<a href="#AddInterface" type="button" class="btn btn-success float-end" data-bs-toggle="modal">
<span aria-hidden="true">{% bs_icon 'plus' %} </span>
</a>
<!-- Modal Secret -->
<div class="modal fade" id="AddInterface" tabindex="-1" role="dialog" aria-labelledby="AddInterface" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{% trans "Create New Interface" %}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form method="post" action="" role="form" aria-label="Create New Interface form">{% csrf_token %}
<div class="modal-body">
<div class="row">
<label class="col-sm-3 col-form-label">{% trans "Name" %}</label>
<div class="col-sm-6">
<input type="text" name="name" class="form-control" placeholder="br0" maxlength="15" required pattern="[A-Za-z0-9_.\-]+"/>
</div>
</div>
<div class="row">
<label class="col-sm-3 col-form-label">{% trans "Start mode" %}</label>
<div class="col-sm-6">
<select name="start_mode" class="form-select">
<option value="none">{% trans "none" %}</option>
<option value="onboot">{% trans "onboot" %}</option>
<option value="hotplug">{% trans "hotplug" %}</option>
</select>
</div>
</div>
<div class="row">
<label class="col-sm-3 col-form-label">{% trans "Device" %}</label>
<div class="col-sm-6">
<select name="netdev" class="form-select">
{% for dev in netdevs %}
<option value="{{ dev }}">{{ dev }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="row">
<label class="col-sm-3 col-form-label">{% trans "Type" %}</label>
<div class="col-sm-6">
<select name="itype" class="form-select" id="itype">
<option value="bridge">{% trans "bridge" %}</option>
<option value="ethernet">{% trans "ethernet" %}</option>
</select>
</div>
</div>
<div class="row bridge_name_form_group">
<label class="col-sm-3 col-form-label">{% trans "STP" %}</label>
<div class="col-sm-6">
<select name="stp" class="form-select">
<option value="on">{% trans "on" %}</option>
<option value="off">{% trans "off" %}</option>
</select>
</div>
</div>
<div class="row bridge_name_form_group">
<label class="col-sm-3 col-form-label">{% trans "Delay" %}</label>
<div class="col-sm-6">
<input type="text" name="delay" class="form-control" value="0" maxlength="3" required pattern="[0-9]+"/>
</div>
</div>
<div class="tabbable">
<ul class="nav nav-tabs" aria-label="IP types">
<li class="nav-item" role="presentation">
<button class="nav-link active" data-bs-toggle="tab" data-bs-target="#ipv4tab" type="button" role="tab" aria-controls="ipv4tab" aria-selected="true">
{% trans "IPv4" %}
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#ipv6tab" type="button" role="tab" aria-controls="ipv6tab" aria-selected="false">
{% trans "IPv6" %}
</button>
</li>
</ul>
</div>
<div class="tab-content">
<div class="tab-pane active" id="ipv4tab">
<div class="modal-body">
<div class="row">
<label class="col-sm-3 col-form-label">{% trans "IPv4 Mode" %}</label>
<div class="col-sm-6">
<select name="ipv4_type" class="form-select" id="ipv4">
<option value="dhcp">{% trans "DHCP" %}</option>
<option value="static">{% trans "Static" %}</option>
<option value="none">{% trans "No configuration" %}</option>
</select>
</div>
</div>
<div class="row static_ipv4_form_group">
<label class="col-sm-3 col-form-label">{% trans "IPv4 Address" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" name="ipv4_addr" maxlength="31" pattern="[0-9\.\/]+|^$">
</div>
</div>
<div class="row static_ipv4_form_group">
<label class="col-sm-3 col-form-label">{% trans "IPv4 Gateway" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" name="ipv4_gw" maxlength="16" pattern="[0-9\.]+|^$">
</div>
</div>
</div>
</div>
<div class="tab-pane" id="ipv6tab">
<div class="modal-body">
<div class="row">
<label class="col-sm-3 col-form-label">{% trans "IPv6 Mode" %}</label>
<div class="col-sm-6">
<select name="ipv6_type" class="form-select" id="ipv6">
<option value="none">{% trans "No configuration" %}</option>
<option value="dhcp">{% trans "DHCP" %}</option>
<option value="static">{% trans "Static" %}</option>
</select>
</div>
</div>
<div class="row static_ipv6_form_group">
<label class="col-sm-3 col-form-label">{% trans "IPv6 Address" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" name="ipv6_addr" maxlength="100" pattern="[0-9a-fA-F\:\/]+|^$">
</div>
</div>
<div class="row static_ipv6_form_group">
<label class="col-sm-3 col-form-label">{% trans "IPv6 Gateway" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" name="ipv6_gw" maxlength="100" pattern="[0-9a-fA-F\:]+|^$">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
{% trans "Close" %}
</button>
<button type="submit" class="btn btn-primary" name="create">
{% trans "Create" %}
</button>
</div>
</form>
</div> <!-- /.modal-content -->
</div> <!-- /.modal-dialog -->
</div><!-- /.modal -->
{% endif %}