diff --git a/computes/templates/computes/bulk_migrate.html b/computes/templates/computes/bulk_migrate.html index cb5cd326..3782e2da 100644 --- a/computes/templates/computes/bulk_migrate.html +++ b/computes/templates/computes/bulk_migrate.html @@ -2,6 +2,7 @@ {% load i18n %} {% load static %} {% load operations %} +{% load bootstrap_icons %} {% block title %}{% trans "Bulk Migrate" %} - {{ compute.name }}{% endblock %} {% block page_heading %}{{ compute.name }} - {% trans "Bulk Migrate" %}{% endblock page_heading %} @@ -15,65 +16,69 @@
{% trans "There is no other host to migrate to." %}
{% else %}

{% trans "Each chosen VM migrates in a job of its own: a running VM live, a shut-off one offline. A VM that fails stays on this host." %}

-{% if targets|length > 1 %} {# another destination reloads the list: which VMs can go depends on it #} -
- - -
-{% else %} -

{% trans "Destination" %}: {{ target.name }}

-{% endif %} +
{% 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." %}
{% else %} -
{% csrf_token %}{% submission_key %} +{% csrf_token %}{% submission_key %} -
- - +
+ {{ compute.name }} {% bs_icon 'arrow-right' %} + {% if targets|length > 1 %} + + {% else %} + {{ target.name }} + {% endif %} +
+ + +
- +
- + - - + + {% for instance in instances %} - - - - + + + {% endfor %}
{% trans "Name" %} {% trans "Status" %}{% trans "VCPU" %} {% trans "Memory" %}vCPU{% trans "Why" %}
+ {% include 'instance_state.html' %}{{ instance.info.3 }}{% if instance.info %}{% widthratio instance.info.2 1024 1 %} MiB{% endif %}{{ instance.refusal|default:"" }}{% if instance.info %}{% widthratio instance.info.2 1 1024 as bytes %}{{ bytes|filesizeformat }}{% endif %}{{ instance.info.3 }}{{ instance.refusal|default:"" }}
-
- - {% for n in parallel %}{% endfor %} + {% blocktrans with source=compute.name dest=target.name asvar question %}Migrate the chosen VMs from {{ source }} to {{ dest }}?{% endblocktrans %} +
- {% blocktrans with source=compute.name dest=target.name asvar question %}Migrate the chosen VMs from {{ source }} to {{ dest }}?{% endblocktrans %} - {% endif %} {% endif %} diff --git a/computes/tests/test_bulk_migrate.py b/computes/tests/test_bulk_migrate.py index aae1a1a0..62a02daa 100644 --- a/computes/tests/test_bulk_migrate.py +++ b/computes/tests/test_bulk_migrate.py @@ -89,7 +89,7 @@ class BulkMigratePageTests(TestCase): def test_one_destination_is_named_and_several_are_a_choice(self): self.assertEqual(self.page().xpath("//select[@name='target']"), []) - self.assertIn("ev-other", self.page().xpath("//strong/text()")) + self.assertIn("ev-other", self.page().xpath("//div[contains(@class, 'card-header')]/span/text()")) Compute.objects.create(name="ev-third", hostname="198.51.100.32", login="", password="", type=4) self.assertEqual(self.page().xpath("//select[@name='target']/option/text()"), ["ev-other", "ev-third"]) diff --git a/computes/tests/test_bulk_migrate_js.py b/computes/tests/test_bulk_migrate_js.py index 99ddd54d..cecbd3d7 100644 --- a/computes/tests/test_bulk_migrate_js.py +++ b/computes/tests/test_bulk_migrate_js.py @@ -20,23 +20,29 @@ const boxes = [ ]; const handlers = {}; const box = (id) => ({addEventListener: (name, fn) => { handlers[id] = fn; }}); -const ids = {"bulk-migrate-all": box("all"), "bulk-migrate-shut-off": box("shut-off"), "bulk-migrate-target": box("target")}; +const button = {disabled: false}, counter = {textContent: ""}; +const ids = {"bulk-migrate-all": box("all"), "bulk-migrate-shut-off": box("shut-off"), "bulk-migrate-target": box("target"), + "bulk-migrate-submit": button, "bulk-migrate-count": counter}; let submitted = 0; const selectors = { "input[name=instance]:not(:disabled)": (b) => !b.disabled, "input[data-shut-off]:not(:disabled)": (b) => b.shutOff && !b.disabled, + "input[name=instance]:checked": (b) => b.checked, }; vm.runInNewContext(SCRIPT, vm.createContext({document: { getElementById: (id) => ids[id], querySelectorAll: (selector) => boxes.filter(selectors[selector]), + addEventListener: (name, fn) => { handlers.document = fn; }, }})); const ticked = () => boxes.filter((b) => b.checked).map((b) => b.name); -const seen = []; +const seen = [], counts = [[counter.textContent, button.disabled]]; for (const [id, checked] of STEPS) { handlers[id]({target: {checked, form: {submit: () => { submitted += 1; }}}}); + handlers.document(); // the change bubbles to the page seen.push(ticked()); + counts.push([counter.textContent, button.disabled]); } -console.log(JSON.stringify({seen, submitted})); +console.log(JSON.stringify({seen, submitted, counts})); """ @@ -54,5 +60,9 @@ class BulkMigrateScriptTests(unittest.TestCase): def test_the_shut_off_box_ticks_only_the_shut_off_vms(self): self.assertEqual(self.run_script([["shut-off", True], ["shut-off", False]])["seen"], [["run", "off"], ["run"]]) + def test_the_button_counts_the_ticked_vms_and_is_off_without_one(self): + self.assertEqual(self.run_script([["all", False], ["all", True]])["counts"], + [[1, False], [0, True], [2, False]]) + def test_another_destination_reloads_the_list(self): self.assertEqual(self.run_script([["target", False]])["submitted"], 1) diff --git a/locale/tr/LC_MESSAGES/django.mo b/locale/tr/LC_MESSAGES/django.mo index 597329e4..49895c25 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 591244ad..100ba9d5 100644 --- a/locale/tr/LC_MESSAGES/django.po +++ b/locale/tr/LC_MESSAGES/django.po @@ -11,7 +11,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-16 05:10+0000\n" +"POT-Creation-Date: 2026-11-16 06:19+0000\n" "PO-Revision-Date: 2020-11-04 12:00+0000\n" "Last-Translator: catborise , 2020\n" "Language-Team: Turkish (https://www.transifex.com/catborise/teams/110663/tr/)\n" @@ -66,7 +66,7 @@ msgstr "Geçersiz anahtar" #: accounts/forms.py:95 computes/templates/computes/balance.html:57 #: computes/templates/computes/balance.html:104 -#: computes/templates/computes/bulk_migrate.html:45 +#: computes/templates/computes/bulk_migrate.html:47 #: computes/templates/computes/instances.html:46 #: instances/templates/add_instance_volume.html:39 #: instances/templates/allinstances_index_grouped.html:11 @@ -772,7 +772,7 @@ msgid "vCPUs" msgstr "vCPU" #: admin/forms.py:209 computes/templates/computes/balance.html:58 -#: computes/templates/computes/bulk_migrate.html:48 +#: computes/templates/computes/bulk_migrate.html:49 #: computes/templates/computes/instances.html:50 #: computes/templates/computes/list.html:62 computes/templates/overview.html:66 #: computes/templates/overview.html:150 @@ -2120,7 +2120,7 @@ msgstr[0] "Önerilen taşımalar (%(counter)s)" msgstr[1] "Önerilen taşımalar (%(counter)s)" #: computes/templates/computes/balance.html:56 -#: computes/templates/computes/bulk_migrate.html:44 +#: computes/templates/computes/bulk_migrate.html:46 msgid "Select all" msgstr "Tümünü seç" @@ -2129,7 +2129,7 @@ msgid "Migration" msgstr "Taşıma" #: computes/templates/computes/balance.html:81 -#: computes/templates/computes/bulk_migrate.html:70 +#: computes/templates/computes/bulk_migrate.html:73 msgid "Migrations at once" msgstr "Aynı anda taşıma" @@ -2145,7 +2145,7 @@ msgid "Migrate the VMs listed?" msgstr "Listelenen sanal makineler taşınsın mı?" #: computes/templates/computes/balance.html:88 -#: computes/templates/computes/bulk_migrate.html:30 +#: computes/templates/computes/bulk_migrate.html:22 msgid "" "The worker runs one job at a time: set Worker Concurrency to 2 or more on the" " Settings page." @@ -2167,6 +2167,7 @@ msgid "Let it move" msgstr "Taşınabilsin" #: computes/templates/computes/balance.html:106 +#: computes/templates/computes/bulk_migrate.html:51 msgid "Why" msgstr "Neden" @@ -2174,17 +2175,17 @@ msgstr "Neden" msgid "You kept it here: tick it to let it move" msgstr "Yerinde tuttunuz: taşınabilmesi için işaretleyin" -#: computes/templates/computes/bulk_migrate.html:5 #: computes/templates/computes/bulk_migrate.html:6 +#: computes/templates/computes/bulk_migrate.html:7 #: computes/templates/computes/instances.html:15 msgid "Bulk Migrate" msgstr "Toplu Taşı" -#: computes/templates/computes/bulk_migrate.html:15 instances/views.py:379 +#: computes/templates/computes/bulk_migrate.html:16 instances/views.py:379 msgid "There is no other host to migrate to." msgstr "Taşınacak başka bir sunucu yok." -#: computes/templates/computes/bulk_migrate.html:17 +#: computes/templates/computes/bulk_migrate.html:18 msgid "" "Each chosen VM migrates in a job of its own: a running VM live, a shut-off " "one offline. A VM that fails stays on this host." @@ -2192,44 +2193,35 @@ msgstr "" "Seçilen her sanal makine kendi işinde taşınır: çalışan sanal makine canlı, " "kapalı olan çevrimdışı. Taşınamayan sanal makine bu sunucuda kalır." -#: computes/templates/computes/bulk_migrate.html:21 -#: computes/templates/computes/bulk_migrate.html:27 -msgid "Destination" -msgstr "Hedef" - -#: computes/templates/computes/bulk_migrate.html:32 +#: computes/templates/computes/bulk_migrate.html:24 msgid "The host has no VMs." msgstr "Bu sunucuda sanal makine yok." -#: computes/templates/computes/bulk_migrate.html:38 +#: computes/templates/computes/bulk_migrate.html:31 +msgid "Destination" +msgstr "Hedef" + +#: computes/templates/computes/bulk_migrate.html:39 msgid "Also migrate the shut-off VMs" msgstr "Kapalı sanal makineleri de taşı" -#: computes/templates/computes/bulk_migrate.html:46 +#: computes/templates/computes/bulk_migrate.html:48 #: computes/templates/computes/instances.html:48 #: instances/templates/allinstances_index_grouped.html:12 #: instances/templates/allinstances_index_nongrouped.html:10 msgid "Status" msgstr "Durum" -#: computes/templates/computes/bulk_migrate.html:47 -#: computes/templates/computes/instances.html:49 -msgid "VCPU" -msgstr "VCPU" - -#: computes/templates/computes/bulk_migrate.html:75 +#: computes/templates/computes/bulk_migrate.html:77 #, python-format msgid "Migrate the chosen VMs from %(source)s to %(dest)s?" msgstr "" "Seçilen sanal makineler %(source)s sunucusundan %(dest)s sunucusuna taşınsın " "mı?" -#: computes/templates/computes/bulk_migrate.html:76 -#: instances/templates/instances/settings_tab.html:60 -#: instances/templates/instances/settings_tab.html:617 -#: instances/templates/instances/settings_tab.html:620 -msgid "Migrate" -msgstr "Taşı" +#: computes/templates/computes/bulk_migrate.html:79 +msgid "Migrate the chosen VMs" +msgstr "Seçilen sanal makineleri taşı" #: computes/templates/computes/capacity_line.txt:2 #, python-format @@ -2473,6 +2465,10 @@ msgstr "Uyarı" msgid "Hypervisor doesn't have any Instances" msgstr "Hipervizör üzerinde hiç sanal makine yok" +#: computes/templates/computes/instances.html:49 +msgid "VCPU" +msgstr "VCPU" + #: computes/templates/computes/instances.html:51 #: computes/templates/computes/list.html:63 #: instances/templates/allinstances_index_grouped.html:18 @@ -5231,6 +5227,12 @@ msgstr "Ağ" msgid "Host devices" msgstr "Sunucu aygıtları" +#: instances/templates/instances/settings_tab.html:60 +#: instances/templates/instances/settings_tab.html:617 +#: instances/templates/instances/settings_tab.html:620 +msgid "Migrate" +msgstr "Taşı" + #: instances/templates/instances/settings_tab.html:65 msgid "XML" msgstr "XML" diff --git a/locale/zh/LC_MESSAGES/django.mo b/locale/zh/LC_MESSAGES/django.mo index 189afc2c..16d4408a 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 ab4d7a45..689c7526 100644 --- a/locale/zh/LC_MESSAGES/django.po +++ b/locale/zh/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-16 05:10+0000\n" +"POT-Creation-Date: 2026-11-16 06:19+0000\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -63,7 +63,7 @@ msgstr "无效的密钥" #: accounts/forms.py:95 computes/templates/computes/balance.html:57 #: computes/templates/computes/balance.html:104 -#: computes/templates/computes/bulk_migrate.html:45 +#: computes/templates/computes/bulk_migrate.html:47 #: computes/templates/computes/instances.html:46 #: instances/templates/add_instance_volume.html:39 #: instances/templates/allinstances_index_grouped.html:11 @@ -749,7 +749,7 @@ msgid "vCPUs" msgstr "vCPU" #: admin/forms.py:209 computes/templates/computes/balance.html:58 -#: computes/templates/computes/bulk_migrate.html:48 +#: computes/templates/computes/bulk_migrate.html:49 #: computes/templates/computes/instances.html:50 #: computes/templates/computes/list.html:62 computes/templates/overview.html:66 #: computes/templates/overview.html:150 @@ -2038,7 +2038,7 @@ msgid_plural "Proposed migrations (%(counter)s)" msgstr[0] "建议的迁移(%(counter)s)" #: computes/templates/computes/balance.html:56 -#: computes/templates/computes/bulk_migrate.html:44 +#: computes/templates/computes/bulk_migrate.html:46 msgid "Select all" msgstr "全选" @@ -2047,7 +2047,7 @@ msgid "Migration" msgstr "迁移" #: computes/templates/computes/balance.html:81 -#: computes/templates/computes/bulk_migrate.html:70 +#: computes/templates/computes/bulk_migrate.html:73 msgid "Migrations at once" msgstr "同时迁移数" @@ -2062,7 +2062,7 @@ msgid "Migrate the VMs listed?" msgstr "迁移列出的虚拟机?" #: computes/templates/computes/balance.html:88 -#: computes/templates/computes/bulk_migrate.html:30 +#: computes/templates/computes/bulk_migrate.html:22 msgid "" "The worker runs one job at a time: set Worker Concurrency to 2 or more on the" " Settings page." @@ -2082,6 +2082,7 @@ msgid "Let it move" msgstr "允许迁移" #: computes/templates/computes/balance.html:106 +#: computes/templates/computes/bulk_migrate.html:51 msgid "Why" msgstr "原因" @@ -2089,58 +2090,49 @@ msgstr "原因" msgid "You kept it here: tick it to let it move" msgstr "您将其保留在原处:勾选后即可迁移" -#: computes/templates/computes/bulk_migrate.html:5 #: computes/templates/computes/bulk_migrate.html:6 +#: computes/templates/computes/bulk_migrate.html:7 #: computes/templates/computes/instances.html:15 msgid "Bulk Migrate" msgstr "批量迁移" -#: computes/templates/computes/bulk_migrate.html:15 instances/views.py:379 +#: computes/templates/computes/bulk_migrate.html:16 instances/views.py:379 msgid "There is no other host to migrate to." msgstr "没有其他可迁移到的主机。" -#: computes/templates/computes/bulk_migrate.html:17 +#: computes/templates/computes/bulk_migrate.html:18 msgid "" "Each chosen VM migrates in a job of its own: a running VM live, a shut-off " "one offline. A VM that fails stays on this host." msgstr "每台选中的虚拟机在各自的任务中迁移:运行中的虚拟机在线迁移,已关机的离线迁移。迁移失败的虚拟机留在此主机上。" -#: computes/templates/computes/bulk_migrate.html:21 -#: computes/templates/computes/bulk_migrate.html:27 -msgid "Destination" -msgstr "目标主机" - -#: computes/templates/computes/bulk_migrate.html:32 +#: computes/templates/computes/bulk_migrate.html:24 msgid "The host has no VMs." msgstr "此主机没有虚拟机。" -#: computes/templates/computes/bulk_migrate.html:38 +#: computes/templates/computes/bulk_migrate.html:31 +msgid "Destination" +msgstr "目标主机" + +#: computes/templates/computes/bulk_migrate.html:39 msgid "Also migrate the shut-off VMs" msgstr "同时迁移已关机的虚拟机" -#: computes/templates/computes/bulk_migrate.html:46 +#: computes/templates/computes/bulk_migrate.html:48 #: computes/templates/computes/instances.html:48 #: instances/templates/allinstances_index_grouped.html:12 #: instances/templates/allinstances_index_nongrouped.html:10 msgid "Status" msgstr "状态" -#: computes/templates/computes/bulk_migrate.html:47 -#: computes/templates/computes/instances.html:49 -msgid "VCPU" -msgstr "VCPU" - -#: computes/templates/computes/bulk_migrate.html:75 +#: computes/templates/computes/bulk_migrate.html:77 #, python-format msgid "Migrate the chosen VMs from %(source)s to %(dest)s?" msgstr "将选中的虚拟机从 %(source)s 迁移到 %(dest)s?" -#: computes/templates/computes/bulk_migrate.html:76 -#: instances/templates/instances/settings_tab.html:60 -#: instances/templates/instances/settings_tab.html:617 -#: instances/templates/instances/settings_tab.html:620 -msgid "Migrate" -msgstr "迁移" +#: computes/templates/computes/bulk_migrate.html:79 +msgid "Migrate the chosen VMs" +msgstr "迁移所选虚拟机" #: computes/templates/computes/capacity_line.txt:2 #, python-format @@ -2373,6 +2365,10 @@ msgstr "警告" msgid "Hypervisor doesn't have any Instances" msgstr "虚拟机管理程序中没有任何虚拟机" +#: computes/templates/computes/instances.html:49 +msgid "VCPU" +msgstr "VCPU" + #: computes/templates/computes/instances.html:51 #: computes/templates/computes/list.html:63 #: instances/templates/allinstances_index_grouped.html:18 @@ -4970,6 +4966,12 @@ msgstr "网络" msgid "Host devices" msgstr "主机设备" +#: instances/templates/instances/settings_tab.html:60 +#: instances/templates/instances/settings_tab.html:617 +#: instances/templates/instances/settings_tab.html:620 +msgid "Migrate" +msgstr "迁移" + #: instances/templates/instances/settings_tab.html:65 msgid "XML" msgstr "XML" diff --git a/static/js/bulk_migrate.js b/static/js/bulk_migrate.js index 3067c8c5..41df8a9c 100644 --- a/static/js/bulk_migrate.js +++ b/static/js/bulk_migrate.js @@ -1,11 +1,20 @@ // The Bulk Migrate page: another destination reloads the list; the header // box ticks or unticks every VM that can migrate, "Also migrate the -// shut-off VMs" the shut-off ones. +// shut-off VMs" the shut-off ones. The Migrate button counts the ticked +// VMs and is off while none is. function tick(selector, checked) { document.querySelectorAll(selector).forEach(function (box) { box.checked = checked; }); } +function count() { + const ticked = document.querySelectorAll("input[name=instance]:checked").length; + const button = document.getElementById("bulk-migrate-submit"); + if (button) { + button.disabled = ticked === 0; + document.getElementById("bulk-migrate-count").textContent = ticked; + } +} document.getElementById("bulk-migrate-target")?.addEventListener("change", function (event) { event.target.form.submit(); }); @@ -15,3 +24,5 @@ document.getElementById("bulk-migrate-all")?.addEventListener("change", function document.getElementById("bulk-migrate-shut-off")?.addEventListener("change", function (event) { tick("input[data-shut-off]:not(:disabled)", event.target.checked); }); +document.addEventListener("change", count); +count();