mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 08:56:07 +00:00
fix(ui): a VM page on a phone opens on its tab, not under it
On a phone the VM card's facts, three rows of section buttons and up to three rows of settings tabs pushed every tab's content below the first screen. Both tab rows are now a single row that scrolls sideways, the chosen tab is kept in sight, and the card's facts run inline below the lg breakpoint. The Migrate tab of a VM that cannot be migrated shows only the reason, as Bulk Migrate does, not an empty destination list and a disabled button. The card's Refresh and OS details buttons are outlined, like the panel's other secondary buttons; filled gray read as disabled in the united theme.
This commit is contained in:
parent
4881c3cd3e
commit
701d9b1f0a
4 changed files with 38 additions and 30 deletions
|
|
@ -38,9 +38,9 @@
|
|||
<button type="button" class="btn btn-sm btn-primary" id="clone-button">{% bs_icon 'copy' %} {% trans "Clone" %}</button>
|
||||
{% endif %}
|
||||
{% if instance.guest_agent_ready %}
|
||||
<button type="button" class="btn btn-sm btn-secondary" id="os-details-button">{% bs_icon 'info-circle' %} {% trans "OS details" %}</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" id="os-details-button">{% bs_icon 'info-circle' %} {% trans "OS details" %}</button>
|
||||
{% endif %}
|
||||
<a class="btn btn-sm btn-secondary" href="{% url 'instances:instance' instance.id %}">{% bs_icon 'arrow-clockwise' %} {% trans "Refresh" %}</a>
|
||||
<a class="btn btn-sm btn-outline-secondary" href="{% url 'instances:instance' instance.id %}">{% bs_icon 'arrow-clockwise' %} {% trans "Refresh" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
{# shown by instance_status.js while the VM's state cannot be read #}
|
||||
|
|
@ -58,28 +58,29 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
<dl class="row g-2 small mb-0 mt-1">
|
||||
<div class="col-6 col-lg-2">
|
||||
<dt class="fw-normal text-body-secondary">{% trans "CPU" %}</dt>
|
||||
<dd class="mb-0">{% firstof instance.cur_vcpu instance.vcpu %} {% trans "of" %} {{ instance.vcpu }} {% trans "vCPU" %}</dd>
|
||||
<div class="col-auto col-lg-2">
|
||||
<dt class="fw-normal text-body-secondary d-inline d-lg-block">{% trans "CPU" %}</dt>
|
||||
<dd class="mb-0 d-inline d-lg-block">{% firstof instance.cur_vcpu instance.vcpu %} {% trans "of" %} {{ instance.vcpu }} {% trans "vCPU" %}</dd>
|
||||
</div>
|
||||
<div class="col-6 col-lg-2">
|
||||
<dt class="fw-normal text-body-secondary">{% trans "Memory" %}</dt>
|
||||
<dd class="mb-0">{{ instance.cur_memory }} MiB</dd>
|
||||
<div class="col-auto col-lg-2">
|
||||
<dt class="fw-normal text-body-secondary d-inline d-lg-block">{% trans "Memory" %}</dt>
|
||||
<dd class="mb-0 d-inline d-lg-block">{{ instance.cur_memory }} MiB</dd>
|
||||
</div>
|
||||
<div class="col-6 col-lg-5">
|
||||
<dt class="fw-normal text-body-secondary">{% trans "Disks" %}</dt>
|
||||
<dd class="mb-0">{% for disk in instance.disks %}{{ disk.dev }} {{ disk.size|filesizeformat }}{% if not forloop.last %} · {% endif %}{% empty %}{% trans "None" %}{% endfor %}</dd>
|
||||
<div class="col-auto col-lg-5">
|
||||
<dt class="fw-normal text-body-secondary d-inline d-lg-block">{% trans "Disks" %}</dt>
|
||||
<dd class="mb-0 d-inline d-lg-block">{% for disk in instance.disks %}{{ disk.dev }} {{ disk.size|filesizeformat }}{% if not forloop.last %} · {% endif %}{% empty %}{% trans "None" %}{% endfor %}</dd>
|
||||
</div>
|
||||
{% if not instance.is_template %}
|
||||
<div class="col-6 col-lg-3">
|
||||
<dt class="fw-normal text-body-secondary">{% trans "IPv4" %}</dt>
|
||||
<dd class="mb-0 font-monospace" data-address-mac="{% for nic in instance.networks %}{{ nic.mac }} {% endfor %}" data-address-family="ipv4" data-empty="—">{% trans "Reading…" %}</dd>
|
||||
<div class="col-auto col-lg-3">
|
||||
<dt class="fw-normal text-body-secondary d-inline d-lg-block">{% trans "IPv4" %}</dt>
|
||||
<dd class="mb-0 d-inline d-lg-block font-monospace" data-address-mac="{% for nic in instance.networks %}{{ nic.mac }} {% endfor %}" data-address-family="ipv4" data-empty="—">{% trans "Reading…" %}</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
</dl>
|
||||
</div>
|
||||
<div class="card-footer p-2">
|
||||
<ul class="nav nav-pills nav-fill flex-wrap gap-1 small" id="navbtn" role="tablist" aria-label="{% trans "Instance actions" %}">
|
||||
<div class="card-footer p-1">
|
||||
{# p-1 inside the scroller keeps the focus ring from being clipped #}
|
||||
<ul class="nav nav-pills nav-fill flex-nowrap overflow-x-auto gap-1 p-1 small" id="navbtn" role="tablist" aria-label="{% trans "Instance actions" %}">
|
||||
{# a template is cloned, not run: no power, access, snapshots or stats #}
|
||||
{% if not instance.is_template %}
|
||||
<li class="nav-item" role="presentation">
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<!-- Nav tabs -->
|
||||
<div class="card">
|
||||
<div class="card-header bg-transparent pb-0">
|
||||
<ul class="nav nav-underline nav-fill small" role="tablist" aria-label="Instance settings">
|
||||
<ul class="nav nav-underline nav-fill flex-nowrap overflow-x-auto text-nowrap p-1 small" role="tablist" aria-label="Instance settings">
|
||||
{% if instance.guest_agent_ready %}
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="px-1 nav-link" data-bs-toggle="tab" id="osinfo-tab" data-bs-target="#osinfo" type="button" role="tab" aria-controls="osinfo" aria-selected="false">
|
||||
|
|
@ -543,6 +543,10 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
<div role="tabpanel" class="tab-pane" id="migrate">
|
||||
{# a VM that cannot go anywhere gets the reason, not the form #}
|
||||
{% if migrate_refusal %}
|
||||
<p class="text-body-secondary mb-0">{{ migrate_refusal }}</p>
|
||||
{% else %}
|
||||
<form action="{% url 'instances:migrate' instance.id %}" method="post" aria-labelledby="migrate-route">{% csrf_token %}{% submission_key %}
|
||||
<header class="border-bottom pb-3 mb-4">
|
||||
<h2 class="h6" id="migrate-route">{% trans "Migration route" %}</h2>
|
||||
|
|
@ -568,8 +572,6 @@
|
|||
{% trans "Both hosts need the same emulator; the VM's definition leaves the source host." %}
|
||||
</p>
|
||||
</header>
|
||||
{# a VM that cannot go anywhere gets the reason, not the disks and settings #}
|
||||
{% if not migrate_refusal %}
|
||||
<section class="card mb-3" aria-labelledby="migrate-storage">
|
||||
<div class="card-body">
|
||||
<h2 class="h6 mb-3" id="migrate-storage">{% bs_icon 'device-hdd' %} {% trans "Storage" %}</h2>
|
||||
|
|
@ -632,21 +634,15 @@
|
|||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
<footer class="border-top pt-3">
|
||||
{% if migrate_refusal %}<p class="small text-body-secondary mb-2">{{ migrate_refusal }}</p>{% endif %}
|
||||
<div class="d-flex flex-wrap align-items-center justify-content-between gap-3">
|
||||
<p class="small text-body-secondary mb-0">{% trans "Migration runs as a background job." %}</p>
|
||||
{% if migrate_refusal %}
|
||||
<button type="button" class="btn btn-primary ms-auto" disabled>{% trans "Migrate" %}</button>
|
||||
{% else %}
|
||||
{# enabled once the disks of the chosen destination are shown #}
|
||||
<button type="submit" class="btn btn-primary ms-auto" name="migrate" disabled>{% trans "Migrate" %}</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</footer>
|
||||
</form>
|
||||
<div class="clearfix"></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="xmledit">
|
||||
{% if instance.status != 5 %}
|
||||
|
|
|
|||
|
|
@ -62,11 +62,14 @@ class MigrateFormTests(TestCase):
|
|||
self.domain.suspend()
|
||||
self.assertEqual(self.migrate_form().xpath(".//input[@type='checkbox']/@name"), switches)
|
||||
|
||||
def test_a_vm_with_no_other_host_gets_the_reason(self):
|
||||
def test_a_vm_with_no_other_host_gets_only_the_reason(self):
|
||||
self.other.delete()
|
||||
form = self.migrate_form()
|
||||
self.assertIn("There is no other host to migrate to.", form.text_content())
|
||||
self.assertEqual(form.xpath(".//button[@name='migrate']"), [])
|
||||
self.client.force_login(self.admin)
|
||||
with patch("vrtManager.connection.connection_manager.get_connection", return_value=self.conn):
|
||||
page = self.client.get(reverse("instances:instance", args=[self.vm.id])).content
|
||||
(tab,) = html.fromstring(page).xpath("//div[@id='migrate']")
|
||||
self.assertEqual(tab.text_content().strip(), "There is no other host to migrate to.")
|
||||
self.assertEqual(tab.xpath(".//form"), [])
|
||||
|
||||
def test_the_api_uses_auto_converge_unless_told_otherwise(self):
|
||||
api = APIClient()
|
||||
|
|
|
|||
|
|
@ -298,6 +298,14 @@
|
|||
migrateCompute.addEventListener("change", loadMigratePlan);
|
||||
}
|
||||
|
||||
// the tab rows scroll sideways on a phone: the chosen tab is centred in its row, the page stays put
|
||||
document.addEventListener("shown.bs.tab", function (event) {
|
||||
var row = event.target.closest(".overflow-x-auto");
|
||||
if (!row) return;
|
||||
var tab = event.target.getBoundingClientRect(), box = row.getBoundingClientRect();
|
||||
row.scrollLeft += tab.left - box.left - (box.width - tab.width) / 2;
|
||||
});
|
||||
|
||||
// the tab a redirect points to; a template opens on its clone form
|
||||
restoreInstanceTab(document, location.hash || summary.dataset.opensOn, show_tab, load_osinfo);
|
||||
// none open (a template has no Power tab): the first section the page has
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue