1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 01:16:10 +00:00

feat(tags): the tag filter as pills, below the state pills

The tag filter was a select beside the search box. It is now a row of
pills as the VM states' are, below them on the VM list and above the table
on the hosts list: All tags, No tag and each tag with how many have it.
The state and tag pills share one helper in table_filter.js; a badge
chooses its tag's pill, the choice is remembered as before.
This commit is contained in:
catborise 2026-11-19 08:40:36 +03:00
parent 6680e14ce4
commit 0e711ec058
13 changed files with 243 additions and 221 deletions

View file

@ -11,7 +11,6 @@
{% include 'create_comp_block.html' %}
{% if computes|length > 1 %}<a href="{% url 'balance' %}" class="btn btn-outline-primary mt-1 ms-1 float-end">{% trans "Balance" %}</a>{% endif %}
{% include 'search_block.html' %}
<div class="float-end m-1">{% include 'common/tag_filter.html' %}</div>
<h3 class="mb-3">{% trans "Computes" %}</h3>
</div>
</div>
@ -52,6 +51,7 @@
</div>
</div>
{% include 'common/tag_filter.html' %}
{# position-relative: the hidden status texts are positioned within it, not the page #}
<div class="table-responsive position-relative">
<table class="table table-hover align-middle" data-sortable>

View file

@ -155,7 +155,9 @@ class HostTagsTests(TestCase):
response = self.client.get(reverse("computes"))
self.assertContains(response, 'data-show-tags title="ssd"') # three, and "…" for the others
self.assertContains(response, "rack-1")
self.assertContains(response, '<option value="rack-1">rack-1 (1)</option>', html=True)
self.assertContains(response, '<button type="button" class="nav-link py-1 px-2" data-pill="rack-1" '
'aria-pressed="false">rack-1 <span class="badge text-bg-light ms-1">1</span></button>',
html=True)
self.assertContains(response, 'data-tag-filter="rack-1"')
# a search and a tag that match no host: the page says so and clears them
self.assertContains(response, 'id="no-match"')

View file

@ -6,7 +6,6 @@
{% block page_heading_extra %}
<div class="d-flex flex-wrap justify-content-end gap-2 mt-1">
{% include 'common/tag_filter.html' %}
{# the list's search and the address search, as one control #}
<div class="input-group w-auto">
<input id="filter" class="form-control" type="text" placeholder="{% trans 'Search' %}" aria-label="{% trans 'Search' %}">
@ -43,18 +42,19 @@
{% if instances %}
{# the state filter: table_filter.js counts each state's VMs the search finds #}
<input type="hidden" id="state-filter" value="">
<nav class="mb-3" aria-label="{% trans "VM states" %}">
<nav class="mb-2" aria-label="{% trans "VM states" %}">
<div class="nav nav-pills flex-wrap gap-1" id="state-pills">
<button type="button" class="nav-link active py-1 px-2" data-pill-state="" aria-pressed="true">
<button type="button" class="nav-link active py-1 px-2" data-pill="" aria-pressed="true">
{% trans "All" %} <span class="badge text-bg-light ms-1" data-count-state=""></span>
</button>
{% for state in states %}
<button type="button" class="nav-link py-1 px-2" data-pill-state="{{ state }}" aria-pressed="false" hidden>
<button type="button" class="nav-link py-1 px-2" data-pill="{{ state }}" aria-pressed="false" hidden>
{{ state }} <span class="badge text-bg-light ms-1" data-count-state="{{ state }}"></span>
</button>
{% endfor %}
</div>
</nav>
{% include 'common/tag_filter.html' %}
<div id="filter-status" class="visually-hidden" role="status" data-text="{% trans "%(shown)s of %(all)s VMs match" %}"></div>
{% endif %}
{% if not instances %}

View file

@ -131,60 +131,67 @@ assert.deepStrictEqual(visible(turkish), ["İSTANBUL-1"]);
filterInstances(page([group(turkish)], "sisli", ""));
assert.deepStrictEqual(visible(turkish), ["Şişli"]);
// the chosen state is remembered as the search is: a list the poll reloads keeps it
{
const vmModule = require("vm");
const fs = require("fs");
const stored = {"VMs_filter_state": "Off", "VMs_filter_tag": "prod"};
const pill = (state) => ({dataset: {pillState: state}, classList: {toggle() {}}, setAttribute() {}});
const pillList = [pill(""), pill("Active"), pill("Off")];
const elements = {
filter: {value: "", hasAttribute: () => false, addEventListener() {}},
"state-filter": {value: "", addEventListener() {}},
"state-pills": {querySelectorAll: () => pillList, querySelector: () => pillList[0], addEventListener() {}},
"tag-filter": {value: "", options: [{value: ""}, {value: "prod"}], addEventListener() {}},
};
// the pills: the chosen state and tag are remembered as the search is, so a list the poll reloads keeps them
const vmModule = require("vm");
const fs = require("fs");
const pill = (value) => ({dataset: {pill: value}, classList: {toggle() {}}, setAttribute() {}});
function pillRow(values) {
const row = {pills: values.map(pill), querySelectorAll: () => row.pills,
addEventListener: (name, fn) => { row.click = fn; }};
return row;
}
// runs table_filter.js on a page of these elements, the stored values given; its document click listener
function run(elements, stored) {
const listeners = {};
const doc = {title: "VMs", getElementById: (id) => elements[id], querySelectorAll: () => [],
addEventListener: (name, fn) => { listeners[name] = fn; }};
const storage = {getItem: (k) => stored[k] || null, setItem: (k, v) => { stored[k] = v; }, removeItem: (k) => { delete stored[k]; }};
vmModule.runInNewContext(fs.readFileSync(process.argv[2], "utf8"), {document: doc, sessionStorage: storage});
return listeners.click;
}
const listPage = () => ({
filter: {value: "", hasAttribute: () => false, addEventListener() {}},
"state-filter": {value: "", addEventListener() {}},
"state-pills": pillRow(["", "Active", "Off"]),
"tag-filter": {value: ""},
"tag-pills": pillRow(["", "-", "prod", "web"]),
});
{
const stored = {"VMs_filter_state": "Off", "VMs_filter_tag": "prod"};
const elements = listPage();
const click = run(elements, stored);
assert.strictEqual(elements["state-filter"].value, "Off");
assert.strictEqual(elements["tag-filter"].value, "prod", "the chosen tag is remembered too");
// a tag's badge chooses it in the list
const badge = {dataset: {tagFilter: "web"}};
elements["tag-filter"].options.push({value: "web"});
listeners.click({target: {closest: (s) => (s === "[data-tag-filter]" ? badge : null)}});
// a tag's pill pressed
const tags = elements["tag-pills"];
tags.click({target: {closest: () => tags.pills[1]}});
assert.deepStrictEqual([elements["tag-filter"].value, stored["VMs_filter_tag"]], ["-", "-"]);
// a tag's badge chooses its pill
click({target: {closest: (s) => (s === "[data-tag-filter]" ? {dataset: {tagFilter: "web"}} : null)}});
assert.strictEqual(elements["tag-filter"].value, "web", "a badge chooses its tag");
assert.strictEqual(stored["VMs_filter_tag"], "web", "and it is remembered");
// "…" shows a VM's other tags, and the first of them takes the focus
let focused = null;
const others = {hidden: true, querySelector: () => ({focus: () => { focused = "d4"; }})};
const ellipsis = {hidden: false, nextElementSibling: others};
listeners.click({target: {closest: (s) => (s === "[data-show-tags]" ? ellipsis : null)}});
click({target: {closest: (s) => (s === "[data-show-tags]" ? ellipsis : null)}});
assert.deepStrictEqual([others.hidden, ellipsis.hidden, focused], [false, true, "d4"]);
// tags that are not buttons (no tag list on the page): the tags shown take it
// tags that are not buttons (no tag pills on the page): the tags shown take it
const plain = {hidden: true, querySelector: () => null, focus: () => { focused = "plain"; }};
listeners.click({target: {closest: (s) => (s === "[data-show-tags]" ? {hidden: false, nextElementSibling: plain} : null)}});
click({target: {closest: (s) => (s === "[data-show-tags]" ? {hidden: false, nextElementSibling: plain} : null)}});
assert.strictEqual(focused, "plain");
}
// a kept tag the list no longer has is forgotten: made again later, it is not chosen by itself
// a kept tag no pill has any longer is forgotten: made again later, it is not chosen by itself
{
const vmModule = require("vm");
const fs = require("fs");
const stored = {"VMs_filter_tag": "prod"};
const elements = {
filter: {value: "", hasAttribute: () => false, addEventListener() {}},
"tag-filter": {value: "", options: [{value: ""}], addEventListener() {}},
};
const doc = {title: "VMs", getElementById: (id) => elements[id], querySelectorAll: () => [], addEventListener() {}};
const storage = {getItem: (k) => stored[k] || null, setItem: (k, v) => { stored[k] = v; }, removeItem: (k) => { delete stored[k]; }};
vmModule.runInNewContext(fs.readFileSync(process.argv[2], "utf8"), {document: doc, sessionStorage: storage});
const stored = {"VMs_filter_tag": "gone"};
const elements = listPage();
run(elements, stored);
assert.deepStrictEqual([elements["tag-filter"].value, stored], ["", {}]);
// nor when the list has no tag left to offer (no tag list on the page)
// nor when the list has no tag left to offer (no tag pills on the page)
stored["VMs_filter_tag"] = "prod";
delete elements["tag-pills"];
delete elements["tag-filter"];
vmModule.runInNewContext(fs.readFileSync(process.argv[2], "utf8"), {document: doc, sessionStorage: storage});
run(elements, stored);
assert.deepStrictEqual(stored, {});
}

View file

@ -121,7 +121,7 @@ class StateTests(TestCase):
AppSettings.objects.filter(key="VIEW_INSTANCES_LIST_STYLE").update(value="grouped")
page = html.fromstring(self.get(self.admin, reverse("instances:index")))
# a pill for all and for each state, every state kept (table_filter.js hides the empty ones)
pills = page.xpath("//div[@id='state-pills']/button/@data-pill-state")
pills = page.xpath("//div[@id='state-pills']/button/@data-pill")
self.assertEqual(pills, ["", *LABELS.values(), "Unknown"])
marks = page.xpath("//tbody[@data-host='st']//tr//@data-state")
self.assertEqual(marks, list(LABELS.values()))

View file

@ -142,21 +142,23 @@ class VmListTagFilterTests(TestCase):
def test_the_tag_list_has_the_tags_of_the_vms_listed_with_how_many(self):
Instance.objects.create(compute=Compute.objects.get(), name="bare", uuid="12345678-0000-0000-0000-00000000cc03")
doc = self.page(self.admin)
self.assertEqual(doc.xpath("//select[@id='tag-filter']/option/@value"), ["", "-", "prod", "secret", "web"])
self.assertEqual([" ".join(o.split()) for o in doc.xpath("//select[@id='tag-filter']/option/text()")],
["All tags", "No tag (1)", "prod (1)", "secret (1)", "web (1)"])
# pills as the states', below them
pills = doc.xpath("//nav[preceding-sibling::nav//div[@id='state-pills']]//div[@id='tag-pills']/button")
self.assertEqual([pill.get("data-pill") for pill in pills], ["", "-", "prod", "secret", "web"])
self.assertEqual([" ".join(pill.text_content().split()) for pill in pills],
["All tags", "No tag 1", "prod 1", "secret 1", "web 1"])
self.assertEqual(doc.xpath("//tr[@data-tags]/@data-tags"), ["", "prod web", "secret"])
# a badge chooses its tag in the list
self.assertEqual(doc.xpath("//tr//button[@data-tag-filter]/@data-tag-filter"), ["prod", "web", "secret"])
def test_an_owner_sees_only_the_tags_of_their_vms(self):
doc = self.page(self.owner)
self.assertEqual(doc.xpath("//select[@id='tag-filter']/option/@value"), ["", "prod", "web"])
self.assertEqual(doc.xpath("//div[@id='tag-pills']/button/@data-pill"), ["", "prod", "web"])
self.assertEqual(doc.xpath("//tr[@data-tags]/@data-tags"), ["prod web"])
def test_no_tags_no_tag_list(self):
Tag.objects.all().delete()
self.assertEqual(self.page(self.admin).xpath("//select[@id='tag-filter']"), [])
self.assertEqual(self.page(self.admin).xpath("//*[@id='tag-pills' or @id='tag-filter']"), [])
class TagsApiTests(TestCase):

Binary file not shown.

View file

@ -11,7 +11,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-11-18 20:30+0000\n"
"POT-Creation-Date: 2026-11-19 05:32+0000\n"
"PO-Revision-Date: 2020-11-04 12:00+0000\n"
"Last-Translator: catborise <muhammetalisag@gmail.com>, 2020\n"
"Language-Team: Turkish (https://www.transifex.com/catborise/teams/110663/tr/)\n"
@ -224,7 +224,7 @@ msgstr "Kullanıcı bölümleri"
#: accounts/templates/account.html:50 accounts/templates/account.html:58
#: admin/forms.py:221 admin/templates/admin/tag_list.html:19
#: computes/templates/computes/list.html:34
#: computes/templates/computes/list.html:33
#: computes/templates/computes/list.html:61 computes/templates/overview.html:90
#: instances/views.py:267 vmbackups/templates/vmbackups/policies.html:17
msgid "VMs"
@ -300,7 +300,7 @@ msgstr "Burada oturumunuz açık kalır; diğer oturumlarınız kapanır."
#: admin/templates/admin/group_form.html:73
#: admin/templates/admin/user_form.html:160
#: admin/templates/admin/user_password_form.html:48
#: computes/templates/computes/form.html:49
#: computes/templates/computes/form.html:52
#: console/templates/console-vnc.html:86
#: instances/templates/add_instance_cdrom.html:38
#: instances/templates/add_instance_network_block.html:55
@ -887,7 +887,7 @@ msgstr "Bu izinleri kimlerin alacağı."
#: admin/templates/admin/logs.html:26
#: admin/templates/admin/tombstone_list.html:20
#: admin/templates/admin/user_list.html:20
#: instances/templates/allinstances.html:12 networks/templates/network.html:130
#: instances/templates/allinstances.html:11 networks/templates/network.html:130
#: nodedevs/templates/nodedevs.html:22 nwfilters/templates/nwfilters.html:23
#: templates/search_block.html:3 virtsecrets/templates/secrets.html:23
msgid "Search"
@ -1030,8 +1030,9 @@ msgid "Failed"
msgstr "Başarısız"
#: admin/templates/admin/tag_list.html:5 admin/templates/admin/tag_list.html:7
#: computes/forms.py:48 instances/templates/instances/settings_tab.html:925
#: instances/views.py:244 templates/navbar.html:39
#: computes/forms.py:53 instances/templates/instances/settings_tab.html:925
#: instances/views.py:244 templates/common/tag_filter.html:5
#: templates/navbar.html:39
msgid "Tags"
msgstr "Etiketler"
@ -1048,12 +1049,12 @@ msgstr ""
msgid "No tags yet"
msgstr "Henüz etiket yok"
#: admin/templates/admin/tag_list.html:18 templates/common/tag_filter.html:3
#: admin/templates/admin/tag_list.html:18
msgid "Tag"
msgstr "Etiket"
#: admin/templates/admin/tag_list.html:20
#: computes/templates/computes/list.html:27
#: computes/templates/computes/list.html:26
msgid "Hosts"
msgstr "Sunucular"
@ -1327,12 +1328,12 @@ msgid "Its owners and tags no longer come back if its UUID shows up again."
msgstr ""
"UUID'si yeniden görünse bile sahipleri ve etiketleri artık geri gelmez."
#: admin/views.py:507
#: admin/views.py:510
#, python-format
msgid "Rename tag %(tag)s"
msgstr "%(tag)s etiketini yeniden adlandır"
#: admin/views.py:512
#: admin/views.py:515
#, python-format
msgid "The backup schedule %(schedules)s backs up its VMs: change it first"
msgid_plural ""
@ -1344,24 +1345,24 @@ msgstr[1] ""
"%(schedules)s yedekleme zamanlamaları bu etiketin sanal makinelerini "
"yedekliyor: önce onları değiştirin"
#: admin/views.py:530
#: admin/views.py:533
#, python-format
msgid "Tag %(tag)s deleted"
msgstr "%(tag)s etiketi silindi"
#: admin/views.py:538
#: admin/views.py:541
#, python-format
msgid "It is taken off %(vms)s and %(hosts)s."
msgstr "%(vms)s ve %(hosts)s üzerinden kaldırılır."
#: admin/views.py:539
#: admin/views.py:542
#, python-format
msgid "%(count)s VM"
msgid_plural "%(count)s VMs"
msgstr[0] "%(count)s sanal makine"
msgstr[1] "%(count)s sanal makine"
#: admin/views.py:540
#: admin/views.py:543
#, python-format
msgid "%(count)s host"
msgid_plural "%(count)s hosts"
@ -2022,20 +2023,20 @@ msgstr "Hiçbir şey değişmedi"
msgid "Other"
msgstr "Diğer"
#: computes/forms.py:21
#: computes/forms.py:23
msgid "Stored, leave empty to keep"
msgstr "Kayıtlı, korumak için boş bırakın"
#: computes/forms.py:35
#: computes/forms.py:37
#, python-format
msgid "Add tag %(tag)s"
msgstr "Etiket ekle: %(tag)s"
#: computes/forms.py:57
#: computes/forms.py:65
msgid "A tag has at most 32 characters"
msgstr "Bir etiket en fazla 32 karakterdir"
#: computes/forms.py:82 computes/templates/computes/instances.html:53
#: computes/forms.py:96 computes/templates/computes/instances.html:53
#: instances/templates/instances/settings_tab.html:872
#: instances/templates/instances/settings_tab.html:904
#: instances/templates/instances/snapshots_tab.html:27
@ -2043,43 +2044,43 @@ msgstr "Bir etiket en fazla 32 karakterdir"
msgid "Description"
msgstr "Tanım"
#: computes/forms.py:83
#: computes/forms.py:97
msgid "Shown on the hosts list"
msgstr "Sunucu listesinde gösterilir"
#: computes/forms.py:84
#: computes/forms.py:98
msgid "SASL login"
msgstr "SASL kullanıcı adı"
#: computes/forms.py:84
#: computes/forms.py:98
msgid "SASL password"
msgstr "SASL parolası"
#: computes/forms.py:90 computes/templates/create_comp_block.html:10
#: computes/forms.py:104 computes/templates/create_comp_block.html:10
msgid "libvirt over TCP, with a SASL login"
msgstr "TCP üzerinden libvirt, SASL girişiyle"
#: computes/forms.py:104 computes/templates/create_comp_block.html:14
#: computes/forms.py:118 computes/templates/create_comp_block.html:14
msgid "libvirt over SSH, with the panel's SSH key"
msgstr "SSH üzerinden libvirt, panelin SSH anahtarıyla"
#: computes/forms.py:105
#: computes/forms.py:119
msgid "FQDN/IP"
msgstr "FQDN/IP"
#: computes/forms.py:110
#: computes/forms.py:124
msgid "SSH user"
msgstr "SSH kullanıcısı"
#: computes/forms.py:118 computes/templates/create_comp_block.html:18
#: computes/forms.py:132 computes/templates/create_comp_block.html:18
msgid "libvirt over TLS, with certificates"
msgstr "TLS üzerinden libvirt, sertifikalarla"
#: computes/forms.py:131 computes/templates/create_comp_block.html:21
#: computes/forms.py:145 computes/templates/create_comp_block.html:21
msgid "Local"
msgstr "Yerel"
#: computes/forms.py:132 computes/templates/create_comp_block.html:22
#: computes/forms.py:146 computes/templates/create_comp_block.html:22
msgid "the libvirt of the host the panel runs on, by its socket"
msgstr "panelin çalıştığı sunucunun libvirt'i, soketi üzerinden"
@ -2183,7 +2184,7 @@ msgstr ""
"Diğer sunucuların taşınan sanal makineleri gönderdiği IP adresi veya ana "
"bilgisayar adı; boş: panelin bu sunucuya ulaştığı adres"
#: computes/models.py:70 computes/templates/computes/form.html:38
#: computes/models.py:70 computes/templates/computes/form.html:41
msgid "gstfsd key"
msgstr "gstfsd anahtarı"
@ -2251,7 +2252,7 @@ msgstr ""
#: computes/templates/computes/balance.html:11
#: computes/templates/computes/list.html:6
#: computes/templates/computes/list.html:15 templates/navbar.html:18
#: computes/templates/computes/list.html:14 templates/navbar.html:18
msgid "Computes"
msgstr "Sunucular"
@ -2295,7 +2296,7 @@ msgstr[1] "%(counter)s vCPU"
#: computes/templates/computes/balance.html:33
#: computes/templates/computes/balance.html:36
#: computes/templates/computes/capacity_vcpus.html:4
#: computes/templates/computes/list.html:43
#: computes/templates/computes/list.html:42
#, python-format
msgid "on %(counter)s CPU"
msgid_plural "on %(counter)s CPUs"
@ -2582,31 +2583,31 @@ msgstr "Sunucuyu düzenle: %(name)s"
msgid "Connection"
msgstr "Bağlantı"
#: computes/templates/computes/form.html:35
#: computes/templates/computes/form.html:38
#: instances/templates/create_instance_w2.html:258
msgid "Advanced"
msgstr "Gelişmiş"
#: computes/templates/computes/form.html:37
#: computes/templates/computes/form.html:40
msgid "Migration address"
msgstr "Taşıma adresi"
#: computes/templates/computes/form.html:37
#: computes/templates/computes/form.html:40
msgid "the host name"
msgstr "sunucu adı"
#: computes/templates/computes/form.html:38
#: computes/templates/computes/form.html:41
msgid "stored"
msgstr "kayıtlı"
#: computes/templates/computes/form.html:38
#: computes/templates/computes/form.html:41
#: instances/templates/instances/edit_instance_volume.html:82
#: instances/templates/instances/settings_tab.html:375
#: networks/templates/networks.html:63
msgid "none"
msgstr "hiçbiri"
#: computes/templates/computes/form.html:50
#: computes/templates/computes/form.html:53
#: instances/templates/instances/edit_instance_volume.html:112
#: instances/templates/instances/nic_qos_form.html:23
#: instances/templates/instances/settings_tab.html:413
@ -2700,7 +2701,7 @@ 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
#: computes/templates/computes/list.html:19
msgid "Warning"
msgstr "Uyarı"
@ -2712,27 +2713,27 @@ msgstr "Hipervizör üzerinde hiç sanal makine yok"
msgid "VCPU"
msgstr "VCPU"
#: computes/templates/computes/list.html:20
#: computes/templates/computes/list.html:19
msgid "You don't have any computes"
msgstr "Hiç sunucunuz yok"
#: computes/templates/computes/list.html:29
#: computes/templates/computes/list.html:28
msgid "connected"
msgstr "bağlı"
#: computes/templates/computes/list.html:36
#: computes/templates/computes/list.html:35
msgid "running"
msgstr "çalışıyor"
#: computes/templates/computes/list.html:41
#: computes/templates/computes/list.html:40
msgid "vCPUs given"
msgstr "Verilen vCPU"
#: computes/templates/computes/list.html:48
#: computes/templates/computes/list.html:47
msgid "Memory given"
msgstr "Atanan bellek"
#: computes/templates/computes/list.html:50
#: computes/templates/computes/list.html:49
#, python-format
msgid "of %(memory)s"
msgstr "/ %(memory)s"
@ -3215,7 +3216,7 @@ msgstr "Bağlan"
#: instances/templates/add_instance_network_block.html:11
#: instances/templates/add_instance_owner_block.html:11
#: instances/templates/add_instance_volume.html:15
#: instances/templates/allinstances.html:33
#: instances/templates/allinstances.html:32
#: instances/templates/allinstances.html:91
#: instances/templates/create_inst_block.html:12
#: instances/templates/create_instance_w2.html:367
@ -4148,26 +4149,26 @@ msgstr "Önce bir havuz seçin"
msgid "Cache mode"
msgstr "Önbellek modu"
#: instances/templates/allinstances.html:14
#: instances/templates/allinstances.html:13
msgid "Find IP / MAC"
msgstr "IP / MAC bul"
#: instances/templates/allinstances.html:27
#: instances/templates/allinstances.html:26
#, python-format
msgid "The panel cannot reach %(counter)s host:"
msgid_plural "The panel cannot reach %(counter)s hosts:"
msgstr[0] "Panel %(counter)s sunucuya ulaşamıyor:"
msgstr[1] "Panel %(counter)s sunucuya ulaşamıyor:"
#: instances/templates/allinstances.html:38
#: instances/templates/allinstances.html:37
msgid "A host of some of your virtual machines cannot be reached right now."
msgstr "Bazı sanal makinelerinizin bir sunucusuna şu anda ulaşılamıyor."
#: instances/templates/allinstances.html:46
#: instances/templates/allinstances.html:45
msgid "VM states"
msgstr "Sanal makine durumları"
#: instances/templates/allinstances.html:49
#: instances/templates/allinstances.html:48
msgid "All"
msgstr "Tümü"
@ -9683,14 +9684,13 @@ msgstr "Yalnız bu etiketi göster"
msgid "more tags"
msgstr "diğer etiketler"
#: templates/common/tag_filter.html:4
#: templates/common/tag_filter.html:7
msgid "All tags"
msgstr "Tüm etiketler"
#: templates/common/tag_filter.html:5
#, python-format
msgid "No tag (%(untagged)s)"
msgstr "Etiketsiz (%(untagged)s)"
#: templates/common/tag_filter.html:10
msgid "No tag"
msgstr "Etiketsiz"
#: templates/error.html:13
msgid "HTTP status"

Binary file not shown.

View file

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-11-18 20:30+0000\n"
"POT-Creation-Date: 2026-11-19 05:32+0000\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
@ -219,7 +219,7 @@ msgstr "用户页面导航"
#: accounts/templates/account.html:50 accounts/templates/account.html:58
#: admin/forms.py:221 admin/templates/admin/tag_list.html:19
#: computes/templates/computes/list.html:34
#: computes/templates/computes/list.html:33
#: computes/templates/computes/list.html:61 computes/templates/overview.html:90
#: instances/views.py:267 vmbackups/templates/vmbackups/policies.html:17
msgid "VMs"
@ -295,7 +295,7 @@ msgstr "您在此处保持登录;您的其他会话将结束。"
#: admin/templates/admin/group_form.html:73
#: admin/templates/admin/user_form.html:160
#: admin/templates/admin/user_password_form.html:48
#: computes/templates/computes/form.html:49
#: computes/templates/computes/form.html:52
#: console/templates/console-vnc.html:86
#: instances/templates/add_instance_cdrom.html:38
#: instances/templates/add_instance_network_block.html:55
@ -861,7 +861,7 @@ msgstr "获得这些权限的用户。"
#: admin/templates/admin/logs.html:26
#: admin/templates/admin/tombstone_list.html:20
#: admin/templates/admin/user_list.html:20
#: instances/templates/allinstances.html:12 networks/templates/network.html:130
#: instances/templates/allinstances.html:11 networks/templates/network.html:130
#: nodedevs/templates/nodedevs.html:22 nwfilters/templates/nwfilters.html:23
#: templates/search_block.html:3 virtsecrets/templates/secrets.html:23
msgid "Search"
@ -1002,8 +1002,9 @@ msgid "Failed"
msgstr "失败"
#: admin/templates/admin/tag_list.html:5 admin/templates/admin/tag_list.html:7
#: computes/forms.py:48 instances/templates/instances/settings_tab.html:925
#: instances/views.py:244 templates/navbar.html:39
#: computes/forms.py:53 instances/templates/instances/settings_tab.html:925
#: instances/views.py:244 templates/common/tag_filter.html:5
#: templates/navbar.html:39
msgid "Tags"
msgstr "标签"
@ -1017,12 +1018,12 @@ msgstr "虚拟机和主机的标签。标签在首次于虚拟机的“选项”
msgid "No tags yet"
msgstr "还没有标签"
#: admin/templates/admin/tag_list.html:18 templates/common/tag_filter.html:3
#: admin/templates/admin/tag_list.html:18
msgid "Tag"
msgstr "标签"
#: admin/templates/admin/tag_list.html:20
#: computes/templates/computes/list.html:27
#: computes/templates/computes/list.html:26
msgid "Hosts"
msgstr "主机"
@ -1285,35 +1286,35 @@ msgstr "已删除已移除的虚拟机 %(name)s"
msgid "Its owners and tags no longer come back if its UUID shows up again."
msgstr "若其 UUID 再次出现,其所有者和标签将不再恢复。"
#: admin/views.py:507
#: admin/views.py:510
#, python-format
msgid "Rename tag %(tag)s"
msgstr "重命名标签 %(tag)s"
#: admin/views.py:512
#: admin/views.py:515
#, python-format
msgid "The backup schedule %(schedules)s backs up its VMs: change it first"
msgid_plural ""
"The backup schedules %(schedules)s back up its VMs: change them first"
msgstr[0] "备份计划 %(schedules)s 正在备份该标签的虚拟机:请先修改计划"
#: admin/views.py:530
#: admin/views.py:533
#, python-format
msgid "Tag %(tag)s deleted"
msgstr "标签 %(tag)s 已删除"
#: admin/views.py:538
#: admin/views.py:541
#, python-format
msgid "It is taken off %(vms)s and %(hosts)s."
msgstr "它将从 %(vms)s 和 %(hosts)s 上移除。"
#: admin/views.py:539
#: admin/views.py:542
#, python-format
msgid "%(count)s VM"
msgid_plural "%(count)s VMs"
msgstr[0] "%(count)s 个虚拟机"
#: admin/views.py:540
#: admin/views.py:543
#, python-format
msgid "%(count)s host"
msgid_plural "%(count)s hosts"
@ -1946,20 +1947,20 @@ msgstr "没有任何更改"
msgid "Other"
msgstr "其他"
#: computes/forms.py:21
#: computes/forms.py:23
msgid "Stored, leave empty to keep"
msgstr "已保存,留空则保持不变"
#: computes/forms.py:35
#: computes/forms.py:37
#, python-format
msgid "Add tag %(tag)s"
msgstr "添加标签:%(tag)s"
#: computes/forms.py:57
#: computes/forms.py:65
msgid "A tag has at most 32 characters"
msgstr "标签最多 32 个字符"
#: computes/forms.py:82 computes/templates/computes/instances.html:53
#: computes/forms.py:96 computes/templates/computes/instances.html:53
#: instances/templates/instances/settings_tab.html:872
#: instances/templates/instances/settings_tab.html:904
#: instances/templates/instances/snapshots_tab.html:27
@ -1967,43 +1968,43 @@ msgstr "标签最多 32 个字符"
msgid "Description"
msgstr "描述"
#: computes/forms.py:83
#: computes/forms.py:97
msgid "Shown on the hosts list"
msgstr "显示在主机列表中"
#: computes/forms.py:84
#: computes/forms.py:98
msgid "SASL login"
msgstr "SASL 登录名"
#: computes/forms.py:84
#: computes/forms.py:98
msgid "SASL password"
msgstr "SASL 密码"
#: computes/forms.py:90 computes/templates/create_comp_block.html:10
#: computes/forms.py:104 computes/templates/create_comp_block.html:10
msgid "libvirt over TCP, with a SASL login"
msgstr "通过 TCP 连接 libvirt,使用 SASL 登录"
#: computes/forms.py:104 computes/templates/create_comp_block.html:14
#: computes/forms.py:118 computes/templates/create_comp_block.html:14
msgid "libvirt over SSH, with the panel's SSH key"
msgstr "通过 SSH 连接 libvirt,使用面板的 SSH 密钥"
#: computes/forms.py:105
#: computes/forms.py:119
msgid "FQDN/IP"
msgstr "FQDN/IP"
#: computes/forms.py:110
#: computes/forms.py:124
msgid "SSH user"
msgstr "SSH 用户"
#: computes/forms.py:118 computes/templates/create_comp_block.html:18
#: computes/forms.py:132 computes/templates/create_comp_block.html:18
msgid "libvirt over TLS, with certificates"
msgstr "通过 TLS 连接 libvirt,使用证书"
#: computes/forms.py:131 computes/templates/create_comp_block.html:21
#: computes/forms.py:145 computes/templates/create_comp_block.html:21
msgid "Local"
msgstr "本地"
#: computes/forms.py:132 computes/templates/create_comp_block.html:22
#: computes/forms.py:146 computes/templates/create_comp_block.html:22
msgid "the libvirt of the host the panel runs on, by its socket"
msgstr "面板所在主机的 libvirt,通过其套接字连接"
@ -2097,7 +2098,7 @@ msgid ""
"address the panel reaches the host at"
msgstr "其他主机向此主机迁移虚拟机时使用的 IP 地址或主机名;留空:使用面板连接该主机的地址"
#: computes/models.py:70 computes/templates/computes/form.html:38
#: computes/models.py:70 computes/templates/computes/form.html:41
msgid "gstfsd key"
msgstr "gstfsd 密钥"
@ -2154,7 +2155,7 @@ msgstr "有磁盘文件不在两台主机共享的存储上:请在该虚拟机
#: computes/templates/computes/balance.html:11
#: computes/templates/computes/list.html:6
#: computes/templates/computes/list.html:15 templates/navbar.html:18
#: computes/templates/computes/list.html:14 templates/navbar.html:18
msgid "Computes"
msgstr "计算节点"
@ -2194,7 +2195,7 @@ msgstr[0] "%(counter)s 个 vCPU"
#: computes/templates/computes/balance.html:33
#: computes/templates/computes/balance.html:36
#: computes/templates/computes/capacity_vcpus.html:4
#: computes/templates/computes/list.html:43
#: computes/templates/computes/list.html:42
#, python-format
msgid "on %(counter)s CPU"
msgid_plural "on %(counter)s CPUs"
@ -2459,31 +2460,31 @@ msgstr "编辑主机:%(name)s"
msgid "Connection"
msgstr "连接"
#: computes/templates/computes/form.html:35
#: computes/templates/computes/form.html:38
#: instances/templates/create_instance_w2.html:258
msgid "Advanced"
msgstr "高级"
#: computes/templates/computes/form.html:37
#: computes/templates/computes/form.html:40
msgid "Migration address"
msgstr "迁移地址"
#: computes/templates/computes/form.html:37
#: computes/templates/computes/form.html:40
msgid "the host name"
msgstr "主机名"
#: computes/templates/computes/form.html:38
#: computes/templates/computes/form.html:41
msgid "stored"
msgstr "已保存"
#: computes/templates/computes/form.html:38
#: computes/templates/computes/form.html:41
#: instances/templates/instances/edit_instance_volume.html:82
#: instances/templates/instances/settings_tab.html:375
#: networks/templates/networks.html:63
msgid "none"
msgstr "无"
#: computes/templates/computes/form.html:50
#: computes/templates/computes/form.html:53
#: instances/templates/instances/edit_instance_volume.html:112
#: instances/templates/instances/nic_qos_form.html:23
#: instances/templates/instances/settings_tab.html:413
@ -2577,7 +2578,7 @@ 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
#: computes/templates/computes/list.html:19
msgid "Warning"
msgstr "警告"
@ -2589,27 +2590,27 @@ msgstr "虚拟机管理程序中没有任何虚拟机"
msgid "VCPU"
msgstr "VCPU"
#: computes/templates/computes/list.html:20
#: computes/templates/computes/list.html:19
msgid "You don't have any computes"
msgstr "您还没有任何计算节点"
#: computes/templates/computes/list.html:29
#: computes/templates/computes/list.html:28
msgid "connected"
msgstr "已连接"
#: computes/templates/computes/list.html:36
#: computes/templates/computes/list.html:35
msgid "running"
msgstr "运行中"
#: computes/templates/computes/list.html:41
#: computes/templates/computes/list.html:40
msgid "vCPUs given"
msgstr "已分配 vCPU"
#: computes/templates/computes/list.html:48
#: computes/templates/computes/list.html:47
msgid "Memory given"
msgstr "已分配内存"
#: computes/templates/computes/list.html:50
#: computes/templates/computes/list.html:49
#, python-format
msgid "of %(memory)s"
msgstr "共 %(memory)s"
@ -3064,7 +3065,7 @@ msgstr "连接"
#: instances/templates/add_instance_network_block.html:11
#: instances/templates/add_instance_owner_block.html:11
#: instances/templates/add_instance_volume.html:15
#: instances/templates/allinstances.html:33
#: instances/templates/allinstances.html:32
#: instances/templates/allinstances.html:91
#: instances/templates/create_inst_block.html:12
#: instances/templates/create_instance_w2.html:367
@ -3934,25 +3935,25 @@ msgstr "请先选择存储池"
msgid "Cache mode"
msgstr "缓存模式"
#: instances/templates/allinstances.html:14
#: instances/templates/allinstances.html:13
msgid "Find IP / MAC"
msgstr "查找 IP / MAC"
#: instances/templates/allinstances.html:27
#: instances/templates/allinstances.html:26
#, python-format
msgid "The panel cannot reach %(counter)s host:"
msgid_plural "The panel cannot reach %(counter)s hosts:"
msgstr[0] "面板无法连接 %(counter)s 台主机:"
#: instances/templates/allinstances.html:38
#: instances/templates/allinstances.html:37
msgid "A host of some of your virtual machines cannot be reached right now."
msgstr "您的部分虚拟机所在的主机当前无法连接。"
#: instances/templates/allinstances.html:46
#: instances/templates/allinstances.html:45
msgid "VM states"
msgstr "虚拟机状态"
#: instances/templates/allinstances.html:49
#: instances/templates/allinstances.html:48
msgid "All"
msgstr "全部"
@ -9116,14 +9117,13 @@ msgstr "只显示此标签"
msgid "more tags"
msgstr "更多标签"
#: templates/common/tag_filter.html:4
#: templates/common/tag_filter.html:7
msgid "All tags"
msgstr "所有标签"
#: templates/common/tag_filter.html:5
#, python-format
msgid "No tag (%(untagged)s)"
msgstr "无标签(%(untagged)s)"
#: templates/common/tag_filter.html:10
msgid "No tag"
msgstr "无标签"
#: templates/error.html:13
msgid "HTTP status"

View file

@ -304,9 +304,15 @@ fieldset:not(:has(input[value="set"]:checked)) > .console-new-password {
.form-section-fields:has(input[name="usable_password"][value="false"]:checked) > .with-password {
display: none;
}
/* a list's tag filter: a long tag name does not widen it beyond a phone's width */
#tag-filter {
max-width: 15rem;
/* a list's tag pills and a row's tag badges: a long tag name breaks within, not beyond a phone's width */
#tag-pills .nav-link,
.tag-badge {
max-width: 100%;
overflow-wrap: anywhere;
text-align: start;
}
.tag-badge {
white-space: normal;
}
/* a VM's or host's tags: smaller than other badges, so a row with several stays narrow */
.tag-badge {

View file

@ -4,9 +4,9 @@
// shows when its text contains the search, in any case: plain text, not a
// pattern. A row with data-search is searched in that text only, not in its
// buttons and menus. With a state list, the row's [data-state] must
// be the chosen state too; with a tag list (#tag-filter), the chosen tag
// be the chosen state too; with tag pills (#tag-pills, #tag-filter), the chosen tag
// one of the row's data-tags (names split by spaces), or "-" none of them.
// A tag's badge ([data-tag-filter]) chooses it in the list; a row's "…"
// A tag's badge ([data-tag-filter]) chooses its pill; a row's "…"
// ([data-show-tags]) shows its other tags. In a grouped list a search for a group's host
// shows all of its rows, and its header row (data-group-header) shows while
// any of its rows does. A page's #no-match shows while no row does. The
@ -114,24 +114,50 @@ if (typeof module !== "undefined") {
filterTable(document);
});
}
var tags = document.getElementById("tag-filter");
if (tags) {
try {
var keptTag = sessionStorage.getItem(key + "_tag") || "";
// a tag no row has any longer is forgotten: made again later, it is not chosen by itself
if (Array.prototype.some.call(tags.options, function (option) { return option.value === keptTag; })) {
tags.value = keptTag;
} else {
keep("", key + "_tag");
}
} catch (e) {
// storage turned off: all tags
}
tags.addEventListener("change", function () {
keep(tags.value, key + "_tag");
// a row of pills (data-pill="value"): the one pressed sets its filter (a hidden
// input) and is remembered under which, as the search is; the value kept is chosen
// again, or forgotten when no pill has it any longer (a tag made again later is
// not chosen by itself). Gives the function that chooses a value's pill.
function pillRow(pills, input, which) {
var all = pills.querySelectorAll("[data-pill]");
function choose(pill) {
input.value = pill.dataset.pill;
keep(input.value, which);
all.forEach(function (other) {
other.classList.toggle("active", other === pill);
other.setAttribute("aria-pressed", other === pill);
});
filterTable(document);
}
function chooseValue(value) {
var pill = Array.prototype.find.call(all, function (one) { return one.dataset.pill === value; });
if (pill) {
choose(pill);
}
return pill;
}
pills.addEventListener("click", function (event) {
var pill = event.target.closest("[data-pill]");
if (pill) {
choose(pill);
}
});
} else {
var kept = "";
try {
kept = sessionStorage.getItem(which) || "";
} catch (e) {
// storage turned off: all
}
if (kept && !chooseValue(kept)) {
keep("", which);
}
return chooseValue;
}
var statePills = document.getElementById("state-pills");
var chooseState = statePills && pillRow(statePills, states, key + "_state");
var tagPills = document.getElementById("tag-pills");
var chooseTag = tagPills && pillRow(tagPills, document.getElementById("tag-filter"), key + "_tag");
if (!tagPills) {
keep("", key + "_tag"); // no row has a tag: none is kept to come back later
}
document.addEventListener("click", function (event) {
@ -145,53 +171,20 @@ if (typeof module !== "undefined") {
return;
}
var badge = event.target.closest("[data-tag-filter]");
if (badge && tags) {
tags.value = badge.dataset.tagFilter;
keep(tags.value, key + "_tag");
filterTable(document);
if (badge && chooseTag) {
chooseTag(badge.dataset.tagFilter);
}
});
var pills = document.getElementById("state-pills");
function chooseState(pill) {
states.value = pill.dataset.pillState;
keep(states.value, key + "_state");
pills.querySelectorAll("[data-pill-state]").forEach(function (other) {
other.classList.toggle("active", other === pill);
other.setAttribute("aria-pressed", other === pill);
});
filterTable(document);
}
if (pills) {
var kept = "";
try {
kept = sessionStorage.getItem(key + "_state") || "";
} catch (e) {
// storage turned off: all states
}
var keptPill = kept && Array.prototype.find.call(pills.querySelectorAll("[data-pill-state]"), function (pill) {
return pill.dataset.pillState === kept;
});
if (keptPill) {
chooseState(keptPill);
}
pills.addEventListener("click", function (event) {
var pill = event.target.closest("[data-pill-state]");
if (pill) {
chooseState(pill);
}
});
}
var clear = document.getElementById("clear-filters");
if (clear) {
clear.addEventListener("click", function () {
search.value = "";
keep("");
if (tags) {
tags.value = "";
keep("", key + "_tag");
if (chooseTag) {
chooseTag("");
}
if (pills) {
chooseState(pills.querySelector('[data-pill-state=""]'));
if (chooseState) {
chooseState("");
} else if (states) {
states.value = "";
}

View file

@ -1,8 +1,20 @@
{% load i18n %}{# tags: Tag.counts of the listed rows; table_filter.js shows the rows with the one chosen #}
{% load i18n %}{% load bootstrap_icons %}
{# tags: Tag.counts of the listed rows; the pills as the VM states' (table_filter.js): the rows with the one pressed show #}
{% with names=tags.0 untagged=tags.1 %}{% if names %}
<select id="tag-filter" class="form-select w-auto" aria-label="{% trans "Tag" %}">
<option value="">{% trans "All tags" %}</option>
{% if untagged %}<option value="-">{% blocktrans %}No tag ({{ untagged }}){% endblocktrans %}</option>{% endif %}
{% for name, count in names %}<option value="{{ name }}">{{ name }} ({{ count }})</option>{% endfor %}
</select>
<input type="hidden" id="tag-filter" value="">
<nav class="mb-3" aria-label="{% trans "Tags" %}">
<div class="nav nav-pills flex-wrap gap-1" id="tag-pills">
<button type="button" class="nav-link active py-1 px-2" data-pill="" aria-pressed="true">{% bs_icon 'tag' %} {% trans "All tags" %}</button>
{% if untagged %}
<button type="button" class="nav-link py-1 px-2" data-pill="-" aria-pressed="false">
{% trans "No tag" %} <span class="badge text-bg-light ms-1">{{ untagged }}</span>
</button>
{% endif %}
{% for name, count in names %}
<button type="button" class="nav-link py-1 px-2" data-pill="{{ name }}" aria-pressed="false">
{{ name }} <span class="badge text-bg-light ms-1">{{ count }}</span>
</button>
{% endfor %}
</div>
</nav>
{% endif %}{% endwith %}