mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
On a phone the host's section menu wrapped to three lines, each new line starting with a divider. It is now one row that scrolls sideways, with the current section in sight (scroll_rows.js, which also takes over the VM page's tab rows from instance_page.js). The filter list, a filter's rules and the PCI and USB device tables were wider than a phone and hid their actions and users off screen; on a phone they now keep the name, the key column and the actions, as the other lists do. The overview's live CPU and memory figures, the chart axes and tooltips, and the VM page's stats now write numbers as the page's language does (a decimal comma in Turkish), like the cards beside them. The capacity cards said "0 bytes running"; they now say what they count: "0 bytes in running VMs". A pool's type is written as libvirt names it on both the list and its page, and the device search sits where the interfaces search does.
198 lines
13 KiB
HTML
198 lines
13 KiB
HTML
{% extends "base.html" %}
|
||
{% load i18n %}
|
||
{% load static %}
|
||
{% load bootstrap_icons %}
|
||
|
||
{% block title %}{% trans "Network filter" %} - {{ name }}{% endblock %}
|
||
|
||
{% block page_heading %}{{ compute.name }} - {% trans "Network filter" %}: {{ name }}{% endblock page_heading %}
|
||
|
||
{% block content %}
|
||
{% include "computes/host_nav.html" with section="nwfilters" detail=True %}
|
||
|
||
{% if uuid %}
|
||
<div class="card mb-3">
|
||
<div class="card-header">{% trans "Filter" %}</div>
|
||
<ul class="list-group list-group-flush">
|
||
<li class="list-group-item py-1 d-flex justify-content-between align-items-baseline gap-3">
|
||
<span class="text-body-secondary">{% trans "UUID" %}</span><span class="font-monospace text-break text-end">{{ uuid }}</span>
|
||
</li>
|
||
<li class="list-group-item py-1 d-flex justify-content-between align-items-baseline gap-3">
|
||
<span class="text-body-secondary">{% trans "Chain" %}</span><span class="font-monospace">{{ chain|default:"–" }}</span>
|
||
</li>
|
||
<li class="list-group-item py-1 d-flex justify-content-between align-items-baseline gap-3">
|
||
<span class="text-body-secondary">{% trans "Priority" %}</span><span>{% if priority is not None %}{{ priority }}{% else %}–{% endif %}</span>
|
||
</li>
|
||
<li class="list-group-item py-1 d-flex justify-content-between align-items-baseline gap-3">
|
||
<span class="text-body-secondary">{% trans "Directly used by" %}</span>
|
||
<span class="text-end">{% for vm in vms %}{% if vm.id %}<a href="{% url 'instances:instance' vm.id %}">{{ vm.name }}</a>{% else %}{{ vm.name }}{% endif %}{% if not forloop.last %}, {% endif %}{% empty %}–{% endfor %}</span>
|
||
</li>
|
||
<li class="list-group-item py-1 d-flex justify-content-between align-items-baseline gap-3">
|
||
<span class="text-body-secondary">{% trans "Referenced by" %}</span>
|
||
<span class="text-end">{% for other in referenced_by %}<a href="{% url 'nwfilter' compute.id other %}">{{ other }}</a>{% if not forloop.last %}, {% endif %}{% empty %}–{% endfor %}</span>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="card mb-3">
|
||
<div class="card-header d-flex flex-wrap align-items-center gap-2">
|
||
<span class="me-auto">{% trans "References" %}</span>
|
||
{% if ref_choices %}
|
||
<form method="post" class="d-flex gap-2">{% csrf_token %}
|
||
<select name="nwfilters_select" class="form-select form-select-sm w-auto" aria-label="{% trans "Filter to reference" %}" required>
|
||
{% for choice in ref_choices %}<option value="{{ choice }}">{{ choice }}</option>{% endfor %}
|
||
</select>
|
||
<button type="submit" class="btn btn-sm btn-primary text-nowrap" name="add_nwfilter_ref">{% bs_icon 'plus-lg' %} {% trans "Add" %}</button>
|
||
</form>
|
||
{% endif %}
|
||
</div>
|
||
{% if refs %}
|
||
<div class="table-responsive position-relative">
|
||
<table class="table table-hover align-middle mb-0">
|
||
<thead>
|
||
<tr>
|
||
<th scope="col">{% trans "Filter" %}</th>
|
||
<th scope="col">{% trans "Parameters" %}</th>
|
||
<th scope="col"><span class="visually-hidden">{% trans "Actions" %}</span></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{% for ref in refs %}
|
||
<tr>
|
||
<td class="text-nowrap">
|
||
{% if ref.filter in filter_names %}<a href="{% url 'nwfilter' compute.id ref.filter %}">{{ ref.filter }}</a>
|
||
{% else %}{{ ref.filter }} <span class="badge bg-danger-subtle text-danger-emphasis">{% trans "Missing" %}</span>{% endif %}
|
||
</td>
|
||
<td class="font-monospace small">{% for param, value in ref.parameters %}<div>{{ param }}={{ value }}</div>{% empty %}–{% endfor %}</td>
|
||
<td class="text-end">
|
||
<form method="post">{% csrf_token %}
|
||
<input type="hidden" name="index" value="{{ forloop.counter0 }}">
|
||
<input type="hidden" name="ref" value="{{ ref.text }}">
|
||
<button type="submit" class="btn btn-sm btn-outline-danger" name="del_nwfilter_ref" aria-label="{% blocktrans with ref=ref.filter %}Remove the reference to {{ ref }}{% endblocktrans %}"
|
||
data-confirm="{% blocktrans with ref=ref.filter %}Remove the reference to {{ ref }}? Its rules no longer apply through this filter.{% endblocktrans %}">{% bs_icon 'trash' %}</button>
|
||
</form>
|
||
</td>
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
{% else %}
|
||
<div class="card-body small text-body-secondary">{% trans "It references no other filter." %}</div>
|
||
{% endif %}
|
||
</div>
|
||
|
||
<div class="card mb-3">
|
||
<div class="card-header d-flex flex-wrap align-items-center gap-2">
|
||
<span class="me-auto">{% trans "Rules" %}</span>
|
||
<button type="button" class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#AddNWFilterRule">{% bs_icon 'plus-lg' %} {% trans "Add rule" %}</button>
|
||
</div>
|
||
{% if rules %}
|
||
<div class="table-responsive position-relative">
|
||
{# on a phone: no rule number, and the priority under the action #}
|
||
<table class="table table-hover align-middle mb-0">
|
||
<thead>
|
||
<tr>
|
||
<th scope="col" class="d-none d-md-table-cell">#</th>
|
||
<th scope="col">{% trans "Action" %}</th>
|
||
<th scope="col">{% trans "Direction" %}</th>
|
||
<th scope="col" class="d-none d-md-table-cell">{% trans "Priority" %}</th>
|
||
<th scope="col">{% trans "Matches" %}</th>
|
||
<th scope="col"><span class="visually-hidden">{% trans "Actions" %}</span></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{% for rule in rules %}
|
||
<tr>
|
||
<th scope="row" class="d-none d-md-table-cell">{{ forloop.counter }}</th>
|
||
<td>
|
||
{% if rule.action == "accept" %}<span class="badge bg-success-subtle text-success-emphasis">{% trans "Accept" %}</span>
|
||
{% elif rule.action == "drop" %}<span class="badge bg-danger-subtle text-danger-emphasis">{% trans "Drop" context "network filter rule" %}</span>
|
||
{% elif rule.action == "reject" %}<span class="badge bg-danger-subtle text-danger-emphasis">{% trans "Reject" context "network filter rule" %}</span>
|
||
{% elif rule.action == "return" %}<span class="badge text-bg-light border">{% trans "Return" context "network filter rule" %}</span>
|
||
{% elif rule.action == "continue" %}<span class="badge text-bg-light border">{% trans "Continue" context "network filter rule" %}</span>
|
||
{% else %}<span class="badge text-bg-light border">{{ rule.action }}</span>{% endif %}
|
||
<div class="small text-body-secondary d-md-none">{% trans "Priority" %} {% if rule.priority is not None %}{{ rule.priority }}{% else %}500{% endif %}</div>
|
||
</td>
|
||
<td>{% if rule.direction == "in" %}{% trans "To the VM" %}{% elif rule.direction == "out" %}{% trans "From the VM" %}{% elif rule.direction == "inout" %}{% trans "Both ways" %}{% else %}{{ rule.direction }}{% endif %}</td>
|
||
<td class="d-none d-md-table-cell">{% if rule.priority is not None %}{{ rule.priority }}{% else %}500{% endif %}</td>
|
||
<td class="small">
|
||
{% for protocol in rule.protocols %}
|
||
<div><span class="badge text-bg-light border">{{ protocol.name }}</span>{% for attribute, value in protocol.attributes %} <span class="font-monospace">{{ attribute }}={{ value }}</span>{% endfor %}</div>
|
||
{% empty %}
|
||
<span class="text-body-secondary">{% trans "Any traffic of the chain" %}</span>
|
||
{% endfor %}
|
||
{% if rule.statematch == "false" or rule.statematch == "0" %}<div class="text-body-secondary">{% trans "Without connection tracking" %}</div>{% endif %}
|
||
</td>
|
||
<td class="text-end">
|
||
<form method="post">{% csrf_token %}
|
||
<input type="hidden" name="index" value="{{ forloop.counter0 }}">
|
||
<input type="hidden" name="rule" value="{{ rule.text }}">
|
||
<button type="submit" class="btn btn-sm btn-outline-danger" name="del_nwfilter_rule" aria-label="{% blocktrans with number=forloop.counter %}Delete rule {{ number }}{% endblocktrans %}"
|
||
data-confirm="{% trans "Delete this rule? Interfaces that use the filter no longer get it." %}">{% bs_icon 'trash' %}</button>
|
||
</form>
|
||
</td>
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
{% else %}
|
||
<div class="card-body small text-body-secondary">{% trans "The filter has no rules of its own." %}</div>
|
||
{% endif %}
|
||
</div>
|
||
|
||
<section class="accordion mb-3" aria-labelledby="xml-heading">
|
||
<div class="accordion-item">
|
||
<h2 class="accordion-header" id="xml-heading">
|
||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#nwfilter-xml" aria-expanded="false" aria-controls="nwfilter-xml">
|
||
{% trans "XML definition" %}
|
||
</button>
|
||
</h2>
|
||
<div class="accordion-collapse collapse" id="nwfilter-xml">
|
||
<form method="post" class="accordion-body" aria-label="{% trans "Change the filter's XML" %}">{% csrf_token %}
|
||
<p class="small text-body-secondary">{% trans "A change applies at once, also to the running VMs that use the filter; it keeps the filter's name and UUID." %}</p>
|
||
<input type="hidden" name="edit_xml">
|
||
<input type="hidden" name="seen" value="{{ seen }}">
|
||
<div class="xmlheight mb-3"><textarea id="edit_editor" aria-label="{% trans "Filter XML" %}">{{ xml }}</textarea></div>
|
||
<div class="d-flex justify-content-end">
|
||
<button type="submit" class="btn btn-primary" name="edit_nwfilter">{% trans "Save" %}</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<div class="modal fade" id="AddNWFilterRule" tabindex="-1" aria-labelledby="AddNWFilterRuleLabel" aria-hidden="true">
|
||
<div class="modal-dialog modal-lg modal-fullscreen-sm-down">
|
||
<form method="post" class="modal-content">{% csrf_token %}
|
||
<div class="modal-header">
|
||
<h5 class="modal-title" id="AddNWFilterRuleLabel">{% trans "Add rule" %}</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{% trans "Close" %}"></button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<p class="small text-body-secondary" id="rule_editor_help">
|
||
{% trans "One rule: in is traffic to the VM, out from it; a lower priority applies first (500 if none is given)." %}
|
||
<a href="https://libvirt.org/formatnwfilter.html#supported-protocols" target="_blank" rel="noopener">{% trans "The protocols and their attributes" %}</a>
|
||
</p>
|
||
<input type="hidden" name="nwfilterrule_xml">
|
||
<div class="xmlheight"><textarea id="rule_editor" aria-label="{% trans "Rule XML" %}" aria-describedby="rule_editor_help"><rule action='accept' direction='in' priority='500'>
|
||
<tcp dstportstart='443'/>
|
||
</rule></textarea></div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}</button>
|
||
<button type="submit" class="btn btn-primary" name="add_nwfilter_rule">{% trans "Add rule" %}</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
{% endif %}
|
||
{% endblock %}
|
||
|
||
{% block script %}
|
||
{% if uuid %}
|
||
<script src="{% static 'js/ace/ace.js' %}"></script>
|
||
<script src="{% static 'js/nwfilter_page.js' %}"></script>
|
||
{% endif %}
|
||
{% endblock %}
|