diff --git a/admin/templates/admin/log_result.html b/admin/templates/admin/log_result.html new file mode 100644 index 00000000..5db8c402 --- /dev/null +++ b/admin/templates/admin/log_result.html @@ -0,0 +1,2 @@ +{% load i18n %}{# how a log row's action ended (logs.html) #} +{% if log.success is None %}{% trans "Unknown" %}{% elif log.success %}{% trans "Done" %}{% else %}{% trans "Failed" %}{% endif %} diff --git a/admin/templates/admin/logs.html b/admin/templates/admin/logs.html index d0103224..50d765a0 100644 --- a/admin/templates/admin/logs.html +++ b/admin/templates/admin/logs.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load i18n %} +{% load static %} {% load django_bootstrap5 %} {% load bootstrap_icons %} @@ -15,7 +16,7 @@ {% block content %}
{# the search runs on the server over every row; the download takes the same rows #} -
- + {% if q or failed %}{% trans "Clear the filters" %}{% endif %} {% if not logs %}
@@ -32,29 +33,30 @@ {% else %}
+ {# on a phone: the date, who, which VM, and what, with how it ended under it #} - + - + - - + + {% for log in logs %} - - + + - + - - - + + + {% endfor %} @@ -64,3 +66,4 @@ {% if logs %}{% bootstrap_pagination logs extra=query pages_to_show=5 extra_classes="flex-wrap" %}{% endif %} {% endblock %} +{% block script %}{% endblock %} diff --git a/admin/templates/admin/tag_list.html b/admin/templates/admin/tag_list.html index 9cb9cf3c..b4bcab3e 100644 --- a/admin/templates/admin/tag_list.html +++ b/admin/templates/admin/tag_list.html @@ -10,7 +10,7 @@ {% block content %}

{% trans "The tags of VMs and hosts. A tag is made when it is first given, on a VM's Options tab or a host's form." %}

{% if not tags %} -
{% bs_icon 'info-circle' %} {% trans "No tags yet" %}
+

{% trans "No tags yet" %}

{% else %}
diff --git a/admin/templates/admin/tombstone_list.html b/admin/templates/admin/tombstone_list.html index 1c340930..20e71aed 100644 --- a/admin/templates/admin/tombstone_list.html +++ b/admin/templates/admin/tombstone_list.html @@ -10,9 +10,7 @@ {% block content %}

{% trans "VMs that vanished from their compute. Their owners, tags, protection and schedules come back if the same UUID shows up again before the record expires; their backups come back with them." %}

{% if not tombstones %} -
- {% bs_icon 'info-circle' %} {% trans "No removed VMs" %} -
+

{% trans "No removed VMs" %}

{% else %}
diff --git a/computes/templates/computes/bulk_migrate.html b/computes/templates/computes/bulk_migrate.html index 811748b6..d3ea487e 100644 --- a/computes/templates/computes/bulk_migrate.html +++ b/computes/templates/computes/bulk_migrate.html @@ -37,7 +37,7 @@ {% if not parallel %}
{% trans "The worker runs one job at a time: set Worker Concurrency to 2 or more on the Settings page." %}
{% elif not instances %} -
{% trans "The host has no VMs." %}
+

{% trans "The host has no VMs." %}

{% else %}
{% csrf_token %}{% submission_key %} {% if entering %}{% endif %} diff --git a/computes/templates/computes/list.html b/computes/templates/computes/list.html index 224f56aa..445d41b1 100644 --- a/computes/templates/computes/list.html +++ b/computes/templates/computes/list.html @@ -14,9 +14,7 @@
{% include "computes/attention.html" %} {% if not computes %} -
- {% bs_icon 'exclamation-triangle'%} {% trans "Warning" %}: {% trans "You don't have any computes" %} -
+

{% trans "You don't have any computes" %}

{% else %} {# the totals of the hosts the panel reaches #}
@@ -57,8 +55,8 @@
- - + + @@ -87,18 +85,20 @@ {% endif %} {% if given %} - - {% else %} - + {# on a phone the VM and vCPU columns are hidden: the totals above have them #} + + {% endif %}
## {% blocktrans %}Date ({{ time_zone }}){% endblocktrans %} {% trans "User" %}{% trans "Host" %}{% trans "Host" %} {% trans "Instance" %} {% trans "Message" %}{% trans "Result" %}{% trans "IP" %}{% trans "Result" %}{% trans "IP" %}
{{ log.id }}{{ log.date|date:"Y-m-d H:i:s" }}{{ log.id }}{{ log.date|date:"Y-m-d" }} {{ log.date|date:"H:i:s" }} {{ log.user }}{{ log.host }}{{ log.host }} {% if log.vm_pk %}{{ log.instance }}{% else %}{{ log.instance }}{% endif %}{{ log.message }}{% if log.success is None %}{% trans "Unknown" %}{% elif log.success %}{% trans "Done" %}{% else %}{% trans "Failed" %}{% endif %}{{ log.ip|default:"" }}{{ log.message }}
{% include "admin/log_result.html" %}
{% include "admin/log_result.html" %}{{ log.ip|default:"" }}
{% trans "Host" %}{% trans "VMs" %}{% trans "vCPUs" %}{% trans "VMs" %}{% trans "vCPUs" %} {% trans "Memory" %} {% trans "Actions" %}
+ {{ given.vm_count }}
{% blocktrans with running=given.vms.running %}{{ running }} running{% endblocktrans %}
+ {% include "computes/capacity_vcpus.html" %} {% include "computes/capacity_memory.html" %} {% if compute.status is True %}{% trans "The capacity could not be read." %}{% else %}{% trans "No capacity while the host cannot be reached." %}{% endif %}{% if compute.status is True %}{% trans "The capacity could not be read." %}{% else %}{% trans "No capacity while the host cannot be reached." %}{% endif %} {# fixed: the menu would be cut off by the table's scrolling box #} diff --git a/interfaces/templates/interfaces.html b/interfaces/templates/interfaces.html index de16d7b0..7a81d3c2 100644 --- a/interfaces/templates/interfaces.html +++ b/interfaces/templates/interfaces.html @@ -16,9 +16,7 @@ {% if changeable is False %}{% include 'interfaces_unchangeable.html' %}{% endif %} {% if ifaces_all is None %}{# not read: the error above says why #}{% elif not ifaces_all %} -
- {% bs_icon 'exclamation-triangle' %} {% trans "libvirt lists no interfaces of this host." %} -
+

{% trans "libvirt lists no interfaces of this host." %}

{% else %} {# a card per interface, as the networks', under its type; a type's heading shows while any of its cards does #} diff --git a/locale/tr/LC_MESSAGES/django.mo b/locale/tr/LC_MESSAGES/django.mo index 34f1c3a3..73667346 100644 Binary files a/locale/tr/LC_MESSAGES/django.mo and b/locale/tr/LC_MESSAGES/django.mo differ diff --git a/locale/tr/LC_MESSAGES/django.po b/locale/tr/LC_MESSAGES/django.po index 7d84f193..9211e0f7 100644 --- a/locale/tr/LC_MESSAGES/django.po +++ b/locale/tr/LC_MESSAGES/django.po @@ -2893,11 +2893,6 @@ msgstr "Aygıtlar" msgid "Problem occurred with host %(name)s: %(error)s" msgstr "%(name)s sunucusuyla ilgili bir sorun oluştu: %(error)s" -#: computes/templates/computes/instances.html:44 -#: computes/templates/computes/list.html:20 -msgid "Warning" -msgstr "Uyarı" - #: computes/templates/computes/list.html:20 msgid "You don't have any computes" msgstr "Hiç sunucunuz yok" @@ -9292,10 +9287,6 @@ msgstr "Tüm türler" msgid "All states" msgstr "Tüm durumlar" -#: operations/templates/operations/jobs.html:47 -msgid "Reset" -msgstr "Sıfırla" - #: operations/templates/operations/jobs.html:53 msgid "No jobs" msgstr "İş yok" diff --git a/locale/zh/LC_MESSAGES/django.mo b/locale/zh/LC_MESSAGES/django.mo index 27303405..4e54cc06 100644 Binary files a/locale/zh/LC_MESSAGES/django.mo and b/locale/zh/LC_MESSAGES/django.mo differ diff --git a/locale/zh/LC_MESSAGES/django.po b/locale/zh/LC_MESSAGES/django.po index a65eb68d..e9e580dd 100644 --- a/locale/zh/LC_MESSAGES/django.po +++ b/locale/zh/LC_MESSAGES/django.po @@ -2751,11 +2751,6 @@ msgstr "设备" msgid "Problem occurred with host %(name)s: %(error)s" msgstr "主机 %(name)s 出现问题:%(error)s" -#: computes/templates/computes/instances.html:44 -#: computes/templates/computes/list.html:20 -msgid "Warning" -msgstr "警告" - #: computes/templates/computes/list.html:20 msgid "You don't have any computes" msgstr "您还没有任何计算节点" @@ -8737,10 +8732,6 @@ msgstr "所有类型" msgid "All states" msgstr "所有状态" -#: operations/templates/operations/jobs.html:47 -msgid "Reset" -msgstr "重置" - #: operations/templates/operations/jobs.html:53 msgid "No jobs" msgstr "没有任务" diff --git a/networks/templates/networks.html b/networks/templates/networks.html index ef115643..3aa6a26b 100644 --- a/networks/templates/networks.html +++ b/networks/templates/networks.html @@ -12,9 +12,7 @@ {% include "computes/host_nav.html" with section="networks" %} {% if networks is None %}{# not read: the error above says why #}{% elif not networks %} -
- {% bs_icon 'exclamation-triangle' %} {% trans "This host has no networks." %} -
+

{% trans "This host has no networks." %}

{% else %} {# a card per network, as the host Overview's Hardware and Software cards #}
diff --git a/nwfilters/templates/nwfilters.html b/nwfilters/templates/nwfilters.html index f00a7be7..3f34030c 100644 --- a/nwfilters/templates/nwfilters.html +++ b/nwfilters/templates/nwfilters.html @@ -13,9 +13,7 @@ {% include "computes/host_nav.html" with section="nwfilters" %} {% if nwfilters is None %}{# not read: the error above says why #}{% elif not nwfilters %} -
- {% bs_icon 'exclamation-triangle' %} {% trans "This host has no network filters." %} -
+

{% trans "This host has no network filters." %}

{% else %}
diff --git a/operations/templates/operations/jobs.html b/operations/templates/operations/jobs.html index a4b44e0a..d4c5e64c 100644 --- a/operations/templates/operations/jobs.html +++ b/operations/templates/operations/jobs.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% load i18n %} {% load django_bootstrap5 %} +{% load static %} {% load bootstrap_icons %} {% load operations %} @@ -18,8 +19,8 @@
{% trans "Jobs" %} {{ page.paginator.count }} - {% if request.user.is_superuser %} - + {% if request.user.is_superuser %}{% if rows or filtered %}{# while there is a job to filter #} +
@@ -43,11 +44,10 @@
- - {% trans "Reset" %} + {% if filtered %}{% trans "Clear the filters" %}{% endif %}
- {% endif %} + {% endif %}{% endif %}
{% if not rows %}
{% trans "No jobs" %}
@@ -105,5 +105,6 @@ {% endif %} {% endblock %} {% block script %} + {% if follow %}{% include "operations/follow_active.html" %}{% endif %} {% endblock script %} diff --git a/operations/tests/test_views.py b/operations/tests/test_views.py index ca4c750b..0031bdbb 100644 --- a/operations/tests/test_views.py +++ b/operations/tests/test_views.py @@ -81,6 +81,18 @@ class JobsPageTestCase(TransactionTestCase): self.assertContains(self.client.get(reverse("operations:jobs"), {"compute": "c"}), link) self.assertNotContains(self.client.get(reverse("operations:jobs"), {"state": "failed"}), link) + def test_the_filters_show_while_there_is_a_job_to_filter(self): + from lxml import html as lxml_html + + self.client.force_login(self.admin) + page = lambda **query: lxml_html.fromstring(self.client.get(reverse("operations:jobs"), query).content) + self.assertTrue(page().xpath("//form[@data-filter-form]")) + self.assertFalse(page().xpath("//form[@data-filter-form]//a")) # nothing to clear + # none matches: the filters stay, with the way back + self.assertTrue(page(state="failed").xpath("//form[@data-filter-form]//a[@href=$u]", u=reverse("operations:jobs"))) + Operation.objects.all().delete() + self.assertFalse(page().xpath("//form[@data-filter-form]")) + def test_a_finished_job_opens_what_it_made(self): from lxml import html as lxml_html diff --git a/operations/views.py b/operations/views.py index 9cd7f94d..64f6677b 100644 --- a/operations/views.py +++ b/operations/views.py @@ -52,6 +52,7 @@ def jobs(request): return render(request, "operations/jobs.html", {"page": page, "rows": rows, "worker_last_seen": seen, "worker_unavailable": unavailable, "filters": request.GET, "active_states": Operation.ACTIVE, + "filtered": any(request.GET.get(field) for field in ("compute", "username", "state", "kind")), "follow": any(op.state in Operation.ACTIVE for op in page.object_list), "states": Operation.ACTIVE + Operation.TERMINAL, "kinds": sorted((name, _(kind.label)) for name, kind in jobs_module.KINDS.items()), diff --git a/static/js/filter_form.js b/static/js/filter_form.js new file mode 100644 index 00000000..c786213c --- /dev/null +++ b/static/js/filter_form.js @@ -0,0 +1,15 @@ +// A list's filter form (data-filter-form) asks the server again once a choice +// changes or Enter is pressed in a text box: it has no button of its own. +document.querySelectorAll("form[data-filter-form]").forEach(function (form) { + form.addEventListener("change", function (event) { + if (event.target.matches("select, input[type='checkbox']")) { + form.requestSubmit(); + } + }); + form.addEventListener("keydown", function (event) { + if (event.key === "Enter" && !event.isComposing && event.target.matches("input:not([type]), input[type='text'], input[type='search']")) { + event.preventDefault(); + form.requestSubmit(); + } + }); +}); diff --git a/storages/templates/storages.html b/storages/templates/storages.html index b69fd6f0..110b0ce4 100644 --- a/storages/templates/storages.html +++ b/storages/templates/storages.html @@ -16,9 +16,7 @@
{% if storages is None %}{# not read: the error above says why #}{% elif not storages %} -
- {% bs_icon 'exclamation-triangle' %} {% trans "This host has no storage pools." %} -
+

{% trans "This host has no storage pools." %}

{% else %} {# a card per pool, as the host Overview's Hardware and Software cards #}
diff --git a/virtsecrets/templates/secrets.html b/virtsecrets/templates/secrets.html index 69f68dbd..22c7d527 100644 --- a/virtsecrets/templates/secrets.html +++ b/virtsecrets/templates/secrets.html @@ -13,9 +13,7 @@ {% include "computes/host_nav.html" with section="virtsecrets" %} {% if secrets_all is None %}{# not read: the error above says why #}{% elif not secrets_all %} -
- {% bs_icon 'exclamation-triangle' %} {% trans "This host has no secrets." %} -
+

{% trans "This host has no secrets." %}

{% else %}
diff --git a/vmbackups/templates/vmbackups/index.html b/vmbackups/templates/vmbackups/index.html index cc117b10..0baf99e5 100644 --- a/vmbackups/templates/vmbackups/index.html +++ b/vmbackups/templates/vmbackups/index.html @@ -13,7 +13,8 @@ {% bs_icon 'hdd-network' %} {% trans "Backup targets" %}{% endblock page_heading_extra %} {% block content %} -
+ {% if rows or vm or target or state %}{# while there is a backup to filter #} +
@@ -37,10 +38,13 @@
-
- + {% if vm or target or state %} + + {% endif %} + {% endif %} {% if rows %}
@@ -75,10 +79,10 @@ {% bootstrap_pagination page extra=page_query pages_to_show=5 extra_classes="flex-wrap" %} {% endif %} {% elif vm or target or state %} -
{% trans "No backup matches the filter." %}
+

{% trans "No backup matches the filter." %}

{% else %} -
{% trans "No backup yet. Back a VM up from its Backups tab." %}
+

{% trans "No backup yet. Back a VM up from its Backups tab." %}

{% endif %} {% endblock %} -{% block script %}{% endblock %} +{% block script %}{% endblock %} diff --git a/vmbackups/templates/vmbackups/policies.html b/vmbackups/templates/vmbackups/policies.html index e0edfcc4..157cd7a9 100644 --- a/vmbackups/templates/vmbackups/policies.html +++ b/vmbackups/templates/vmbackups/policies.html @@ -33,7 +33,7 @@
{% else %} -
{% trans "No backup schedule yet." %} {% trans "A schedule backs chosen VMs, or every VM of a compute, up every day and keeps the newest." %}
+

{% trans "No backup schedule yet." %} {% trans "A schedule backs chosen VMs, or every VM of a compute, up every day and keeps the newest." %}

{% endif %} {% endblock %} diff --git a/vmbackups/templates/vmbackups/targets.html b/vmbackups/templates/vmbackups/targets.html index 1e173dc2..22e41f04 100644 --- a/vmbackups/templates/vmbackups/targets.html +++ b/vmbackups/templates/vmbackups/targets.html @@ -29,7 +29,7 @@
{% else %} -
{% trans "No backup target yet." %}
+

{% trans "No backup target yet." %}

{% endif %} {% endblock %}