1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +00:00

fix(templates): a wide table scrolls in its own box on a narrow screen

Twenty tables had no .table-responsive wrapper, so on a phone the user
list, compute list, VM lists, network and network filter pages scrolled
sideways as a whole. Each table now scrolls inside its box, as the
other ten already did. The page test walks the network page too, and
checks that every table on every page has the wrapper.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
catborise 2026-10-21 12:49:52 +03:00
parent 6ddde9376c
commit e324e79fcb
15 changed files with 1038 additions and 982 deletions

View file

@ -1,97 +1,99 @@
{% load i18n %}
{% load bootstrap_icons %}
<table class="table table-hover sortable-theme-bootstrap" data-sortable>
<thead>
<tr>
<th scope="col" data-sortable="false"><a class="link-primary" href="#" id="hide-all-instances" onclick="hide_all_host_instances()">#</a></th>
<th scope="col">{% trans "Name" %}<br>{% trans "Description" %}</th>
<th scope="col" class="d-none d-sm-table-cell">{% trans "User"%}</th>
<th scope="col">{% trans "Status" %}</th>
{% if app_settings.VM_DRBD_STATUS == 'True' %}
<th scope="col">{% trans "Role/Disk" %}</th>
{% endif %}
<th scope="col" class="d-none d-sm-table-cell">{% trans "VCPU" %}</th>
<th scope="col" class="d-none d-sm-table-cell">{% trans "Memory" %}</th>
<th scope="col" style="width:200px;" data-sortable="false">{% trans "Actions" %} & {% trans "Mem Usage" %}</th>
</tr>
</thead>
{% for compute in computes %}
<tbody class="searchable">
{% if compute.instance_set.count > 0 %}
<tr class="table-secondary fw-bold border-bottom border-dark">
<td>
<span id="collapse_host_instances_{{ compute.id }}" onclick="hide_host_instances('{{ compute.id }}');" class="bi bi-chevron-up" ></span>
</td>
<td>
<a class="link-dark" href="{% url 'overview' compute.id %}">{{ compute.name }}</a>
<span id="inst_count_badge_{{ compute.id }}" class="badge bg-secondary d-none">{{ compute.instance_set.count }}</span>
</td>
<td class="d-none d-sm-table-cell"></td>
<td>
{% if compute.status is True %}
<span class="badge bg-success-subtle text-success-emphasis">{% trans "Connected" %}</span>
{% else %}
<span class="badge bg-danger-subtle text-danger-emphasis">{% trans "Not Connected" %}</span>
{% endif %}
</td>
{% if app_settings.VM_DRBD_STATUS == 'True' %}
<div class="table-responsive">
<table class="table table-hover sortable-theme-bootstrap" data-sortable>
<thead>
<tr>
<th scope="col" data-sortable="false"><a class="link-primary" href="#" id="hide-all-instances" onclick="hide_all_host_instances()">#</a></th>
<th scope="col">{% trans "Name" %}<br>{% trans "Description" %}</th>
<th scope="col" class="d-none d-sm-table-cell">{% trans "User"%}</th>
<th scope="col">{% trans "Status" %}</th>
{% if app_settings.VM_DRBD_STATUS == 'True' %}
<th scope="col">{% trans "Role/Disk" %}</th>
{% endif %}
<th scope="col" class="d-none d-sm-table-cell">{% trans "VCPU" %}</th>
<th scope="col" class="d-none d-sm-table-cell">{% trans "Memory" %}</th>
<th scope="col" style="width:200px;" data-sortable="false">{% trans "Actions" %} & {% trans "Mem Usage" %}</th>
</tr>
</thead>
{% for compute in computes %}
<tbody class="searchable">
{% if compute.instance_set.count > 0 %}
<tr class="table-secondary fw-bold border-bottom border-dark">
<td>
<span id="collapse_host_instances_{{ compute.id }}" onclick="hide_host_instances('{{ compute.id }}');" class="bi bi-chevron-up" ></span>
</td>
<td>
<a class="link-dark" href="{% url 'overview' compute.id %}">{{ compute.name }}</a>
<span id="inst_count_badge_{{ compute.id }}" class="badge bg-secondary d-none">{{ compute.instance_set.count }}</span>
</td>
<td class="d-none d-sm-table-cell"></td>
{% endif %}
{% if compute.status is True %}
<td class="d-none d-sm-table-cell text-center">{{ compute.cpu_count }}</td>
<td class="d-none d-sm-table-cell text-right">{{ compute.ram_size|filesizeformat }}</td>
<td>
<div class="progress">
<div class="progress-bar bg-success" role="progressbar" aria-label="{% trans "Mem Usage" %}" style="width: {{ compute.ram_usage }}%"
aria-valuenow="{{ compute.ram_usage }}" aria-valuemin="0" aria-valuemax="100">{{ compute.ram_usage }}%
</div>
</div>
</td>
{% else %}
<td class="d-none d-sm-table-cell"></td>
<td class="d-none d-sm-table-cell"></td>
<td></td>
{% endif %}
</tr>
{% for instance in compute.instance_set.all %}
<tr host="{{ compute.id }}">
<td class="text-right">{{ forloop.counter }} </td>
<td>
<a class="link-primary" href="{% url 'instances:instance' instance.id %}">{{ instance.name }}</a>
<br>
{% if instance.info %}<p class="m-0 small fst-italic">{{ instance.title }}</p>{% endif %}
</td>
<td>
<em>
{% if instance.userinstance_set.all.count > 0 %}
{{ instance.userinstance_set.all.0.user }}
{% if instance.userinstance_set.all.count > 1 %}
(+{{ instance.userinstance_set.all.count|add:"-1" }})
{% endif %}
{% endif %}
</em>
</td>
<td>
{% include 'instance_state.html' %}
{% if compute.status is True %}
<span class="badge bg-success-subtle text-success-emphasis">{% trans "Connected" %}</span>
{% else %}
<span class="badge bg-danger-subtle text-danger-emphasis">{% trans "Not Connected" %}</span>
{% endif %}
</td>
{% if app_settings.VM_DRBD_STATUS == 'True' %}
<td>
{% if instance.drbd == "Primary/OK" or instance.drbd == "Secondary/OK" %}<span class="badge bg-success-subtle text-success-emphasis">{% else %}<span class="badge bg-danger-subtle text-danger-emphasis">{% endif %}{{ instance.drbd }}</span>
</td>
<td class="d-none d-sm-table-cell"></td>
{% endif %}
<td>{{ instance.info.3 }}</td>
<td>{% if instance.info %}{% widthratio instance.info.2 1024 1 %} MB{% endif %}</td>
<td class="text-nowrap">
{% include 'instance_actions.html' %}
{% if compute.status is True %}
<td class="d-none d-sm-table-cell text-center">{{ compute.cpu_count }}</td>
<td class="d-none d-sm-table-cell text-right">{{ compute.ram_size|filesizeformat }}</td>
<td>
<div class="progress">
<div class="progress-bar bg-success" role="progressbar" aria-label="{% trans "Mem Usage" %}" style="width: {{ compute.ram_usage }}%"
aria-valuenow="{{ compute.ram_usage }}" aria-valuemin="0" aria-valuemax="100">{{ compute.ram_usage }}%
</div>
</div>
</td>
{% else %}
<td class="d-none d-sm-table-cell"></td>
<td class="d-none d-sm-table-cell"></td>
<td></td>
{% endif %}
</tr>
{% endfor %}
{% endif %}
</tbody>
{% empty %}
<tbody></tbody>{# sortable.js needs a table body #}
{% endfor %}
</table>
{% for instance in compute.instance_set.all %}
<tr host="{{ compute.id }}">
<td class="text-right">{{ forloop.counter }} </td>
<td>
<a class="link-primary" href="{% url 'instances:instance' instance.id %}">{{ instance.name }}</a>
<br>
{% if instance.info %}<p class="m-0 small fst-italic">{{ instance.title }}</p>{% endif %}
</td>
<td>
<em>
{% if instance.userinstance_set.all.count > 0 %}
{{ instance.userinstance_set.all.0.user }}
{% if instance.userinstance_set.all.count > 1 %}
(+{{ instance.userinstance_set.all.count|add:"-1" }})
{% endif %}
{% endif %}
</em>
</td>
<td>
{% include 'instance_state.html' %}
</td>
{% if app_settings.VM_DRBD_STATUS == 'True' %}
<td>
{% if instance.drbd == "Primary/OK" or instance.drbd == "Secondary/OK" %}<span class="badge bg-success-subtle text-success-emphasis">{% else %}<span class="badge bg-danger-subtle text-danger-emphasis">{% endif %}{{ instance.drbd }}</span>
</td>
{% endif %}
<td>{{ instance.info.3 }}</td>
<td>{% if instance.info %}{% widthratio instance.info.2 1024 1 %} MB{% endif %}</td>
<td class="text-nowrap">
{% include 'instance_actions.html' %}
</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
{% empty %}
<tbody></tbody>{# sortable.js needs a table body #}
{% endfor %}
</table>
</div>
{% block script %}
<script>

View file

@ -1,57 +1,59 @@
{% load i18n %}
<table class="table table-hover sortable-theme-bootstrap" data-sortable>
<thead>
<tr>
<th scope="col">{% trans 'Name' %}<br>{% trans 'Description' %}</th>
{% if request.user.is_superuser %}
<th scope="col">{% trans 'Host' %}<br>{% trans 'User' %}</th>
{% endif %}
<th scope="col">{% trans 'Status' %}</th>
{% if app_settings.VM_DRBD_STATUS == 'True' %}
<th scope="col">{% trans 'Role/Disk' %}</th>
{% endif %}
<th scope="col">{% trans 'VCPU' %}</th>
<th scope="col">{% trans 'Memory' %}</th>
<th scope="col" data-sortable="false">{% trans 'Actions' %}</th>
</tr>
</thead>
<tbody class="searchable">
{% for instance in instances %}
<tr>
<td>
<a class="link-primary" href="{% url 'instances:instance' instance.id %}">
{{ instance.name }}
</a>
<br>
{% if instance.info %}<p class="m-0 small font-italic">{{ instance.title }}</p>{% endif %}
</td>
{% if request.user.is_superuser %}
<div class="table-responsive">
<table class="table table-hover sortable-theme-bootstrap" data-sortable>
<thead>
<tr>
<th scope="col">{% trans 'Name' %}<br>{% trans 'Description' %}</th>
{% if request.user.is_superuser %}
<th scope="col">{% trans 'Host' %}<br>{% trans 'User' %}</th>
{% endif %}
<th scope="col">{% trans 'Status' %}</th>
{% if app_settings.VM_DRBD_STATUS == 'True' %}
<th scope="col">{% trans 'Role/Disk' %}</th>
{% endif %}
<th scope="col">{% trans 'VCPU' %}</th>
<th scope="col">{% trans 'Memory' %}</th>
<th scope="col" data-sortable="false">{% trans 'Actions' %}</th>
</tr>
</thead>
<tbody class="searchable">
{% for instance in instances %}
<tr>
<td>
<a href="{% url 'overview' instance.compute.id %}">{{ instance.compute.name }}</a><br>
<small><em>
{% if instance.userinstance_set.all.count > 0 %}
{{ instance.userinstance_set.all.0.user }}
{% if instance.userinstance_set.all.count > 1 %}
(+{{ instance.userinstance_set.all.count|add:"-1" }})
{% endif %}
{% endif %}
</em></small>
<a class="link-primary" href="{% url 'instances:instance' instance.id %}">
{{ instance.name }}
</a>
<br>
{% if instance.info %}<p class="m-0 small font-italic">{{ instance.title }}</p>{% endif %}
</td>
{% endif %}
<td>
{% include 'instance_state.html' %}
</td>
{% if app_settings.VM_DRBD_STATUS == 'True' %}
<td>
{% if instance.drbd == "Primary/OK" or instance.drbd == "Secondary/OK" %}<span class="badge bg-success-subtle text-success-emphasis">{% else %}<span class="badge bg-danger-subtle text-danger-emphasis">{% endif %}{{ instance.drbd }}</span>
</td>
{% endif %}
<td>{{ instance.info.3 }}</td>
<td>{% if instance.info %}{% widthratio instance.info.2 1024 1 %} MB{% endif %}</td>
<td class="text-nowrap">
{% include 'instance_actions.html' %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if request.user.is_superuser %}
<td>
<a href="{% url 'overview' instance.compute.id %}">{{ instance.compute.name }}</a><br>
<small><em>
{% if instance.userinstance_set.all.count > 0 %}
{{ instance.userinstance_set.all.0.user }}
{% if instance.userinstance_set.all.count > 1 %}
(+{{ instance.userinstance_set.all.count|add:"-1" }})
{% endif %}
{% endif %}
</em></small>
</td>
{% endif %}
<td>
{% include 'instance_state.html' %}
</td>
{% if app_settings.VM_DRBD_STATUS == 'True' %}
<td>
{% if instance.drbd == "Primary/OK" or instance.drbd == "Secondary/OK" %}<span class="badge bg-success-subtle text-success-emphasis">{% else %}<span class="badge bg-danger-subtle text-danger-emphasis">{% endif %}{{ instance.drbd }}</span>
</td>
{% endif %}
<td>{{ instance.info.3 }}</td>
<td>{% if instance.info %}{% widthratio instance.info.2 1024 1 %} MB{% endif %}</td>
<td class="text-nowrap">
{% include 'instance_actions.html' %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>

View file

@ -15,49 +15,51 @@
<div class="modal-body">
<form method="post" aria-label="Select compute for instance create form">{% csrf_token %}
<div class="row">
<table class="table">
<thead>
<tr style="cursor:default;pointer-events:none">
<th>{% trans "Name" %}</th>
<th>{% trans "VCPU" %}
<th>{% trans "CPU Usage" %}</th>
<th>{% trans "Memory" %}</th>
<th>{% trans "Mem Usage" %}</th>
<th>{% trans "Action" %}</th>
</tr>
</thead>
<tbody>
{% for compute in computes %}
{% if compute.status is True %}
<tr style="text-decoration: none">
<td>{{ compute.name }}</td>
<td>{{ compute.cpu_count }}</td>
<td class="cpu-usage" data-url="{% url 'compute_graph' compute.id %}">
<div class="progress">
<div class="progress-bar bg-primary" role="progressbar" aria-label="{% trans "Mem Usage" %}" style="width: 0%"
aria-valuemin="0" aria-valuemax="100" aria-label="{% trans "CPU Usage" %}">
<div class="table-responsive">
<table class="table">
<thead>
<tr style="cursor:default;pointer-events:none">
<th>{% trans "Name" %}</th>
<th>{% trans "VCPU" %}
<th>{% trans "CPU Usage" %}</th>
<th>{% trans "Memory" %}</th>
<th>{% trans "Mem Usage" %}</th>
<th>{% trans "Action" %}</th>
</tr>
</thead>
<tbody>
{% for compute in computes %}
{% if compute.status is True %}
<tr style="text-decoration: none">
<td>{{ compute.name }}</td>
<td>{{ compute.cpu_count }}</td>
<td class="cpu-usage" data-url="{% url 'compute_graph' compute.id %}">
<div class="progress">
<div class="progress-bar bg-primary" role="progressbar" aria-label="{% trans "Mem Usage" %}" style="width: 0%"
aria-valuemin="0" aria-valuemax="100" aria-label="{% trans "CPU Usage" %}">
</div>
</div>
</div>
<small class="cpu-usage-value"></small>
</td>
<td>{{ compute.ram_size|filesizeformat }}</td>
<td>
<div class="progress">
<div class="progress-bar bg-primary" role="progressbar" aria-label="{% trans "Mem Usage" %}" style="width: {{ compute.ram_usage }}%"
aria-valuenow="{{ compute.ram_usage }}" aria-valuemin="0" aria-valuemax="100">{{ compute.ram_usage }}%
<small class="cpu-usage-value"></small>
</td>
<td>{{ compute.ram_size|filesizeformat }}</td>
<td>
<div class="progress">
<div class="progress-bar bg-primary" role="progressbar" aria-label="{% trans "Mem Usage" %}" style="width: {{ compute.ram_usage }}%"
aria-valuenow="{{ compute.ram_usage }}" aria-valuemin="0" aria-valuemax="100">{{ compute.ram_usage }}%
</div>
</div>
</div>
</td>
<td class="col-1">
<button class="btn btn-success btn-sm" type="button" onclick="goto_compute('{{ compute.id }}');">
{% trans "Choose" %}
</button>
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</td>
<td class="col-1">
<button class="btn btn-success btn-sm" type="button" onclick="goto_compute('{{ compute.id }}');">
{% trans "Choose" %}
</button>
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
</div>
</form>
</div>

View file

@ -248,99 +248,101 @@
<span class="fw-bold">{% trans "Instance Volume" %}</span>
{% include 'add_instance_volume.html' %}
</div>
<table class="table table-hover">
<thead>
<tr>
<th scope="col">{% trans "Device" %}</th>
<th scope="col">{% trans "Used" %}</th>
<th scope="col">{% trans "Capacity" %}</th>
<th scope="col">{% trans "Storage" %}</th>
<th scope="col">{% trans "Source" %}</th>
<th scope="col">{% trans "Action" %}</th>
</tr>
</thead>
<tbody>
{% for disk in instance.config_disks %}
<tr>
<td>
<button type="submit" class="btn btn-sm btn-secondary"
name="details{{ forloop.counter0 }}"
title="{% trans 'Details' %}"
tabindex="1"
data-trigger="focus"
data-bs-toggle="popover"
data-bs-html="true"
data-bs-content="<strong>{% trans 'Bus' %}:</strong> {{ disk.bus }} <br/>
<strong>{% trans 'Format' %}:</strong> {{ disk.format }} <br/>
<strong>{% trans 'Cache' %}:</strong> {{ disk.cache }} <br/>
<strong>{% trans 'Serial' %}:</strong> {{ disk.serial }} <br/>
<strong>{% trans 'Readonly' %}:</strong> {{ disk.readonly }} <br/>
<strong>{% trans 'Shareable' %}:</strong> {{ disk.shareable }}</br>
<strong>{% trans 'IO Mode' %}:</strong> {{ disk.io }} <br/>
<strong>{% trans 'Discard' %}:</strong> {{ disk.discard }} <br/>
<strong>{% trans 'Detect Zeroes' %}:</strong> {{ disk.detect_zeroes }}">
<span>{% bs_icon 'info' %} </span>
</button>
{{ disk.dev }}
</td>
{% if disk.storage is None %}
<td colspan="4">
<div class="alert alert-danger">
{% trans "Error getting disk info" %}
</div>
</td>
{% else %}
<td>{{ disk.used | filesizeformat}}</td>
<td>{{ disk.size | filesizeformat }}</td>
<td>{{ disk.storage }}</td>
<td>{{ disk.path }}</td>
{% endif %}
<td class="text-nowrap">
<form class="d-inline" action="{% url 'instances:edit_volume' instance.id %}" method="post" role="form" aria-label="Edit instance volume form">
{% csrf_token %}
<input type="hidden" name="path" value="{{ disk.path }}">
<input type="hidden" name="dev" value="{{ disk.dev }}">
<input type="hidden" name="storage" value="{{ disk.storage }}">
<input type="hidden" name="name" value="{{ disk.image }}">
{% include 'instances/edit_instance_volume.html' with id=forloop.counter0 %}
</form>
<form class="d-inline" action="{% url 'instances:detach_vol' instance.id %}" method="post">
{% csrf_token %}
<input type="hidden" name="path" value="{{ disk.path }}">
<input type="hidden" name="dev" value="{{ disk.dev }}">
<input type="hidden" name="storage" value="{{ disk.storage }}">
<input type="hidden" name="name" value="{{ disk.image }}">
{% if instance.status == 5 %}
<button type="submit" class="btn btn-sm btn-secondary" value="{{ disk.dev }}" title="{% trans "Detach" %}" onclick="return confirm('{% trans "Are you sure to detach volume?" %}')">
{% bs_icon 'eject' %}
</button>
{% else %}
<button class="btn btn-sm btn-secondary disabled" disabled value="{{ disk.dev }}" title="{% trans "Detach" %}" onclick="return confirm('{% trans "Are you sure? This may lead data corruption!" %}')">
{% bs_icon 'eject' %}
</button>
{% endif %}
</form>
<form class="d-inline" action="{% url 'instances:delete_vol' instance.id %}" method="post">
{% csrf_token %}
<input type="hidden" name="path" value="{{ disk.path }}">
<input type="hidden" name="dev" value="{{ disk.dev }}">
<input type="hidden" name="storage" value="{{ disk.storage }}">
<input type="hidden" name="name" value="{{ disk.image }}">
{% if instance.status == 5 %}
<button type="submit" class="btn btn-sm btn-secondary" title="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure to delete volume?" %}')">
{% bs_icon 'trash' %}
</button>
{% else %}
<button class="btn btn-sm btn-secondary disabled" disabled title="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure? This may lead data corruption!" %}')">
{% bs_icon 'trash' %}
</button>
{% endif %}
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">{% trans "Device" %}</th>
<th scope="col">{% trans "Used" %}</th>
<th scope="col">{% trans "Capacity" %}</th>
<th scope="col">{% trans "Storage" %}</th>
<th scope="col">{% trans "Source" %}</th>
<th scope="col">{% trans "Action" %}</th>
</tr>
</thead>
<tbody>
{% for disk in instance.config_disks %}
<tr>
<td>
<button type="submit" class="btn btn-sm btn-secondary"
name="details{{ forloop.counter0 }}"
title="{% trans 'Details' %}"
tabindex="1"
data-trigger="focus"
data-bs-toggle="popover"
data-bs-html="true"
data-bs-content="<strong>{% trans 'Bus' %}:</strong> {{ disk.bus }} <br/>
<strong>{% trans 'Format' %}:</strong> {{ disk.format }} <br/>
<strong>{% trans 'Cache' %}:</strong> {{ disk.cache }} <br/>
<strong>{% trans 'Serial' %}:</strong> {{ disk.serial }} <br/>
<strong>{% trans 'Readonly' %}:</strong> {{ disk.readonly }} <br/>
<strong>{% trans 'Shareable' %}:</strong> {{ disk.shareable }}</br>
<strong>{% trans 'IO Mode' %}:</strong> {{ disk.io }} <br/>
<strong>{% trans 'Discard' %}:</strong> {{ disk.discard }} <br/>
<strong>{% trans 'Detect Zeroes' %}:</strong> {{ disk.detect_zeroes }}">
<span>{% bs_icon 'info' %} </span>
</button>
{{ disk.dev }}
</td>
{% if disk.storage is None %}
<td colspan="4">
<div class="alert alert-danger">
{% trans "Error getting disk info" %}
</div>
</td>
{% else %}
<td>{{ disk.used | filesizeformat}}</td>
<td>{{ disk.size | filesizeformat }}</td>
<td>{{ disk.storage }}</td>
<td>{{ disk.path }}</td>
{% endif %}
<td class="text-nowrap">
<form class="d-inline" action="{% url 'instances:edit_volume' instance.id %}" method="post" role="form" aria-label="Edit instance volume form">
{% csrf_token %}
<input type="hidden" name="path" value="{{ disk.path }}">
<input type="hidden" name="dev" value="{{ disk.dev }}">
<input type="hidden" name="storage" value="{{ disk.storage }}">
<input type="hidden" name="name" value="{{ disk.image }}">
{% include 'instances/edit_instance_volume.html' with id=forloop.counter0 %}
</form>
<form class="d-inline" action="{% url 'instances:detach_vol' instance.id %}" method="post">
{% csrf_token %}
<input type="hidden" name="path" value="{{ disk.path }}">
<input type="hidden" name="dev" value="{{ disk.dev }}">
<input type="hidden" name="storage" value="{{ disk.storage }}">
<input type="hidden" name="name" value="{{ disk.image }}">
{% if instance.status == 5 %}
<button type="submit" class="btn btn-sm btn-secondary" value="{{ disk.dev }}" title="{% trans "Detach" %}" onclick="return confirm('{% trans "Are you sure to detach volume?" %}')">
{% bs_icon 'eject' %}
</button>
{% else %}
<button class="btn btn-sm btn-secondary disabled" disabled value="{{ disk.dev }}" title="{% trans "Detach" %}" onclick="return confirm('{% trans "Are you sure? This may lead data corruption!" %}')">
{% bs_icon 'eject' %}
</button>
{% endif %}
</form>
<form class="d-inline" action="{% url 'instances:delete_vol' instance.id %}" method="post">
{% csrf_token %}
<input type="hidden" name="path" value="{{ disk.path }}">
<input type="hidden" name="dev" value="{{ disk.dev }}">
<input type="hidden" name="storage" value="{{ disk.storage }}">
<input type="hidden" name="name" value="{{ disk.image }}">
{% if instance.status == 5 %}
<button type="submit" class="btn btn-sm btn-secondary" title="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure to delete volume?" %}')">
{% bs_icon 'trash' %}
</button>
{% else %}
<button class="btn btn-sm btn-secondary disabled" disabled title="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure? This may lead data corruption!" %}')">
{% bs_icon 'trash' %}
</button>
{% endif %}
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="clearfix"></div>
</div>
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="network">
@ -352,165 +354,167 @@
<div class="row mt-3">
<div class="col-lg-12 mt-3">
<h5 class="fw-bold">{% trans "Network Devices" %}</h5>
<table class="table">
<thead>
<tr>
<th scope="col">{% trans 'Name' %}</th>
<th scope="col" class="d-none d-table-cell d-sm-table-cell" colspan="2">{% trans 'Info' %}</th>
<th scope="colgroup" colspan="3" class="col-sm-2">{% trans 'Actions' %}</th>
</tr>
</thead>
<tbody>
{% for network in instance.config_networks %}
<tr>
<td rowspan="2">eth{{ forloop.counter0 }}({{ network.target|default:"no target" }})
<form action="{% url 'instances:set_link_state' instance.id %}" method="post" aria-label="set instance link state form">
{% csrf_token %}
<input name="mac" value="{{ network.mac }}" hidden/>
<input name="set_link_state" value="{{ network.state }}" hidden/>
<input type="checkbox" {% if network.state == 'up' %} checked{% endif %} onclick='submit();' />
<strong>{% trans 'active' %}</strong>
<small>{{ network.type }}</small>
</form>
</td>
<td>
<div class="input-group">
<span class="input-group-text">{% trans 'MAC' %}</span>
<input type="text" class="form-control" value="{{ network.mac }}" aria-label="mac" aria-describedby="mac" readonly>
</div>
</td>
<td class="d-none d-table-cell">
<div class="input-group">
<span class="input-group-text">{% trans 'Filter' %}</span>
<input type="text" class="form-control" value="{{ network.filterref|default:'None' }}" aria-label="filter" aria-describedby="filter" readonly>
</div>
</td>
<td>
<div class="input-group">
<span class="input-group-text">{% trans 'Source' %}</span>
<input type="text" class="form-control" value="{{ network.nic }}" aria-label="source" aria-describedby="source" readonly>
</div>
</td>
<td>
<form action="{% url 'instances:change_network' instance.id %}" method="post" name="edit_network{{ forloop.counter0 }}" role="form">{% csrf_token %}
<button class="btn btn-sm btn-primary"
type="button"
title="{% trans "Edit NIC" %}"
data-bs-target="#editInstanceNetwork{{ forloop.counter0 }}"
data-bs-toggle="modal">
<span aria-hidden="true">{% bs_icon 'pencil-square' %} </span>
</button>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th scope="col">{% trans 'Name' %}</th>
<th scope="col" class="d-none d-table-cell d-sm-table-cell" colspan="2">{% trans 'Info' %}</th>
<th scope="colgroup" colspan="3" class="col-sm-2">{% trans 'Actions' %}</th>
</tr>
</thead>
<tbody>
{% for network in instance.config_networks %}
<tr>
<td rowspan="2">eth{{ forloop.counter0 }}({{ network.target|default:"no target" }})
<form action="{% url 'instances:set_link_state' instance.id %}" method="post" aria-label="set instance link state form">
{% csrf_token %}
<input name="mac" value="{{ network.mac }}" hidden/>
<input name="set_link_state" value="{{ network.state }}" hidden/>
<input type="checkbox" {% if network.state == 'up' %} checked{% endif %} onclick='submit();' />
<strong>{% trans 'active' %}</strong>
<small>{{ network.type }}</small>
</form>
</td>
<td>
<div class="input-group">
<span class="input-group-text">{% trans 'MAC' %}</span>
<input type="text" class="form-control" value="{{ network.mac }}" aria-label="mac" aria-describedby="mac" readonly>
</div>
</td>
<td class="d-none d-table-cell">
<div class="input-group">
<span class="input-group-text">{% trans 'Filter' %}</span>
<input type="text" class="form-control" value="{{ network.filterref|default:'None' }}" aria-label="filter" aria-describedby="filter" readonly>
</div>
</td>
<td>
<div class="input-group">
<span class="input-group-text">{% trans 'Source' %}</span>
<input type="text" class="form-control" value="{{ network.nic }}" aria-label="source" aria-describedby="source" readonly>
</div>
</td>
<td>
<form action="{% url 'instances:change_network' instance.id %}" method="post" name="edit_network{{ forloop.counter0 }}" role="form">{% csrf_token %}
<button class="btn btn-sm btn-primary"
type="button"
title="{% trans "Edit NIC" %}"
data-bs-target="#editInstanceNetwork{{ forloop.counter0 }}"
data-bs-toggle="modal">
<span aria-hidden="true">{% bs_icon 'pencil-square' %} </span>
</button>
<div class="modal fade" id="editInstanceNetwork{{ forloop.counter0 }}" role="dialog" aria-labelledby="editInstanceNetworkLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{% trans "Edit Instance Network" %}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="container">
<div class="row">
<label class="col-form-label">{% trans "MAC" %}</label>
<div class="input-group">
<input class="form-control" type="text" name="net-old-mac-{{ forloop.counter0 }}" value="{{ network.mac }}" readonly/>
<input class="form-control" type="text" name="net-mac-{{ forloop.counter0 }}" value="{{ network.mac }}"/>
<div class="modal fade" id="editInstanceNetwork{{ forloop.counter0 }}" role="dialog" aria-labelledby="editInstanceNetworkLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{% trans "Edit Instance Network" %}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="container">
<div class="row">
<label class="col-form-label">{% trans "MAC" %}</label>
<div class="input-group">
<input class="form-control" type="text" name="net-old-mac-{{ forloop.counter0 }}" value="{{ network.mac }}" readonly/>
<input class="form-control" type="text" name="net-mac-{{ forloop.counter0 }}" value="{{ network.mac }}"/>
</div>
</div>
<div class="row">
<label class="col-form-label">{% trans "Net Source" %}</label>
<div class="input-group">
<input class="form-control" type="text" value="{{ network.nic }}" readonly/>
<select class="form-select" name="net-source-{{ forloop.counter0 }}">
{% for c_net in networks_host %}
<option value="net:{{ c_net }}" {% if c_net == network.nic %} selected {% endif %}>{% trans 'Network' %} {{ c_net }}</option>
{% endfor %}
{% for c_iface in interfaces_host %}
<option value="iface:{{ c_iface }}" {% if c_iface == network.nic %} selected {% endif %}>{% trans 'Interface' %} {{ c_iface }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="row">
<label class="col-form-label">{% trans "NWFilter" %}</label>
<div class="input-group">
<input class="form-control" type="text" value="{{ network.filterref }}" readonly/>
<select class="form-select" name="net-nwfilter-{{ forloop.counter0 }}">
<option value="">{% trans "None" %}</option>
{% for c_filters in nwfilters_host %}
<option value="{{ c_filters }}" {% if c_filters == network.filterref %} selected {% endif %}>{{ c_filters }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="row">
<label class="col-form-label">{% trans "Model" %} </label>
<div class="input-group">
<input class="form-control" type="text" value="{{ network.model }}" readonly/>
<select class="form-select" name="net-model-{{ forloop.counter0 }}">
{% for model in net_models_host %}
<option value="{{ model }}" {% if model == network.model %} selected {% endif %}>{{ model }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="row">
<label class="col-form-label">{% trans "Net Source" %}</label>
<div class="input-group">
<input class="form-control" type="text" value="{{ network.nic }}" readonly/>
<select class="form-select" name="net-source-{{ forloop.counter0 }}">
{% for c_net in networks_host %}
<option value="net:{{ c_net }}" {% if c_net == network.nic %} selected {% endif %}>{% trans 'Network' %} {{ c_net }}</option>
{% endfor %}
{% for c_iface in interfaces_host %}
<option value="iface:{{ c_iface }}" {% if c_iface == network.nic %} selected {% endif %}>{% trans 'Interface' %} {{ c_iface }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="row">
<label class="col-form-label">{% trans "NWFilter" %}</label>
<div class="input-group">
<input class="form-control" type="text" value="{{ network.filterref }}" readonly/>
<select class="form-select" name="net-nwfilter-{{ forloop.counter0 }}">
<option value="">{% trans "None" %}</option>
{% for c_filters in nwfilters_host %}
<option value="{{ c_filters }}" {% if c_filters == network.filterref %} selected {% endif %}>{{ c_filters }}</option>
{% endfor %}
</select>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" type="button" data-bs-dismiss="modal">{% trans 'Close' %}</button>
<button class="btn btn-success" name="change_network" title="{% trans "Apply network changes" %}">{% trans "Apply" %}</button>
</div>
<div class="row">
<label class="col-form-label">{% trans "Model" %} </label>
<div class="input-group">
<input class="form-control" type="text" value="{{ network.model }}" readonly/>
<select class="form-select" name="net-model-{{ forloop.counter0 }}">
{% for model in net_models_host %}
<option value="{{ model }}" {% if model == network.model %} selected {% endif %}>{{ model }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" type="button" data-bs-dismiss="modal">{% trans 'Close' %}</button>
<button class="btn btn-success" name="change_network" title="{% trans "Apply network changes" %}">{% trans "Apply" %}</button>
</div>
</div>
</div>
</form>
</td>
<td>
<form action="{% url 'instances:set_qos' instance.id %}" method="post" name="add_qos{{ forloop.counter0 }}" role="form" aria-label="Add network qos form">
{% csrf_token %}
<input type="text" name="net-mac-{{ forloop.counter0 }}" value="{{ network.mac }}" hidden/>
{% include 'add_network_qos.html' with id=forloop.counter0 %}
</form>
</td>
<td>
<form action="{% url 'instances:delete_network' instance.id %}" method="post" name="delete_network" role="form">{% csrf_token %}
<button class="btn btn-sm btn-danger" value="{{ network.mac }}" name="delete_network" title="{% trans "Delete Device" %}"
onclick="return confirm('{% trans "Are you sure?" %}')">
{% bs_icon 'trash' %}
</button>
</form>
</td>
</tr>
<tr>
<td>
<div class="input-group">
<span class="input-group-text">{% trans 'IPv4' %}</span>
<input type="text" class="form-control" value="{% for ipv4 in network.ipv4|default:'unknown' %}{{ ipv4 }}{% endfor %}" aria-label="ipv4" aria-describedby="ipv4" readonly>
</div>
</form>
</td>
<td>
<form action="{% url 'instances:set_qos' instance.id %}" method="post" name="add_qos{{ forloop.counter0 }}" role="form" aria-label="Add network qos form">
{% csrf_token %}
<input type="text" name="net-mac-{{ forloop.counter0 }}" value="{{ network.mac }}" hidden/>
{% include 'add_network_qos.html' with id=forloop.counter0 %}
</form>
</td>
<td>
<form action="{% url 'instances:delete_network' instance.id %}" method="post" name="delete_network" role="form">{% csrf_token %}
<button class="btn btn-sm btn-danger" value="{{ network.mac }}" name="delete_network" title="{% trans "Delete Device" %}"
onclick="return confirm('{% trans "Are you sure?" %}')">
{% bs_icon 'trash' %}
</button>
</form>
</td>
</tr>
<tr>
<td>
<div class="input-group">
<span class="input-group-text">{% trans 'IPv4' %}</span>
<input type="text" class="form-control" value="{% for ipv4 in network.ipv4|default:'unknown' %}{{ ipv4 }}{% endfor %}" aria-label="ipv4" aria-describedby="ipv4" readonly>
</div>
</td>
<td>
<div class="input-group">
<span class="input-group-text">{% trans 'IPv6' %}</span>
<input type="text" class="form-control" value="{% for ipv6 in network.ipv6|default:'unknown' %}{{ ipv6 }}{% endfor %}" aria-label="ipv6" aria-describedby="ipv6" readonly>
</div>
</td>
<td colspan="3">
<div class="input-group">
<span class="input-group-text px-2">{% trans 'Model' %}</span>
<input type="text" class="form-control px-2" value="{{ network.model }}" aria-label="model" aria-describedby="model" readonly>
</div>
</td>
</tr>
<tr>
<td class="py-1 bg-primary text-white" colspan="9">
{% if network.type == 'direct' %}
<small>{% trans 'In most configurations, macvtap does not work for host to guest network communication' %}</small>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</td>
<td>
<div class="input-group">
<span class="input-group-text">{% trans 'IPv6' %}</span>
<input type="text" class="form-control" value="{% for ipv6 in network.ipv6|default:'unknown' %}{{ ipv6 }}{% endfor %}" aria-label="ipv6" aria-describedby="ipv6" readonly>
</div>
</td>
<td colspan="3">
<div class="input-group">
<span class="input-group-text px-2">{% trans 'Model' %}</span>
<input type="text" class="form-control px-2" value="{{ network.model }}" aria-label="model" aria-describedby="model" readonly>
</div>
</td>
</tr>
<tr>
<td class="py-1 bg-primary text-white" colspan="9">
{% if network.type == 'direct' %}
<small>{% trans 'In most configurations, macvtap does not work for host to guest network communication' %}</small>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
@ -520,57 +524,59 @@
<p><strong>{% trans "QoS Configuration" %}</strong></p>
</div>
<div class="col-12 col-sm-12">
<table class="table table-hover">
<thead>
<tr class="d-flex">
<th scope="col" class="col-2">{% trans "MAC" %}/{% trans "Direction" %}</th>
<th scope="col" class="col-2">{% trans "Average" %}</th>
<th scope="col" class="col-3">{% trans "Peak" %}</th>
<th scope="col" class="col-3">{% trans "Burst" %}</th>
<th scope="col" class="col-2">{% trans "Actions" %}</th>
</tr>
</thead>
<tbody>
{% for q, attrs in instance.config_qos.items %}
{% for att in attrs %}
<tr class="d-flex">
<form action="{% url 'instances:set_qos' instance.id %}" method="post" role="form" aria-label="Instance QoS configuration form">
{% csrf_token %}
<td class="col-2"><label class="col-form-label">{{ q }} {{ att.direction | capfirst }}</label></td>
<td class="col-2"><input id="qos_average" class="form-control" name="qos_average"
value="{{ att.average|default:'' }}"/>
</td>
<td class="col-3"><input id="qos_peak" class="form-control" name="qos_peak"
value="{{ att.peak|default:'' }}"/>
</td>
<td class="col-3"><input id="qos_burst" class="form-control" name="qos_burst"
value="{{ att.burst|default:'' }}"/>
</td>
<td class="col-sm-2">
<input name="qos_direction" value="{{ att.direction }}" hidden/>
<input name="net-mac" value="{{ q }}" hidden/>
<button type="submit" class="btn btn-sm btn-primary"
name="set_qos" data-bs-toggle="modal"
title="{% trans "Edit QoS" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
<span>{% bs_icon 'save' %} </span>
</button>
</form>
<form action="{% url 'instances:unset_qos' instance.id %}" method="post" role="form" aria-label="Instance QoS configuration form">
{% csrf_token %}
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr class="d-flex">
<th scope="col" class="col-2">{% trans "MAC" %}/{% trans "Direction" %}</th>
<th scope="col" class="col-2">{% trans "Average" %}</th>
<th scope="col" class="col-3">{% trans "Peak" %}</th>
<th scope="col" class="col-3">{% trans "Burst" %}</th>
<th scope="col" class="col-2">{% trans "Actions" %}</th>
</tr>
</thead>
<tbody>
{% for q, attrs in instance.config_qos.items %}
{% for att in attrs %}
<tr class="d-flex">
<form action="{% url 'instances:set_qos' instance.id %}" method="post" role="form" aria-label="Instance QoS configuration form">
{% csrf_token %}
<td class="col-2"><label class="col-form-label">{{ q }} {{ att.direction | capfirst }}</label></td>
<td class="col-2"><input id="qos_average" class="form-control" name="qos_average"
value="{{ att.average|default:'' }}"/>
</td>
<td class="col-3"><input id="qos_peak" class="form-control" name="qos_peak"
value="{{ att.peak|default:'' }}"/>
</td>
<td class="col-3"><input id="qos_burst" class="form-control" name="qos_burst"
value="{{ att.burst|default:'' }}"/>
</td>
<td class="col-sm-2">
<input name="qos_direction" value="{{ att.direction }}" hidden/>
<input name="net-mac" value="{{ q }}" hidden/>
<button type="submit" class="btn btn-sm btn-danger"
name="unset_qos"
title="{% trans "Delete QoS" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
{% bs_icon 'trash' %}
<button type="submit" class="btn btn-sm btn-primary"
name="set_qos" data-bs-toggle="modal"
title="{% trans "Edit QoS" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
<span>{% bs_icon 'save' %} </span>
</button>
</form>
</td>
</tr>
</form>
<form action="{% url 'instances:unset_qos' instance.id %}" method="post" role="form" aria-label="Instance QoS configuration form">
{% csrf_token %}
<input name="qos_direction" value="{{ att.direction }}" hidden/>
<input name="net-mac" value="{{ q }}" hidden/>
<button type="submit" class="btn btn-sm btn-danger"
name="unset_qos"
title="{% trans "Delete QoS" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
{% bs_icon 'trash' %}
</button>
</form>
</td>
</tr>
{% endfor %}
{% endfor %}
{% endfor %}
</tbody>
</table>
</tbody>
</table>
</div>
</div>
</div>
{% endif %}