mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 08:56:07 +00:00
fix(ui): a host's pages on a phone: one row of sections, tables that fit
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.
This commit is contained in:
parent
701d9b1f0a
commit
a2da2ab394
24 changed files with 84 additions and 55 deletions
|
|
@ -15,4 +15,4 @@
|
|||
<div class="progress-bar {% if given.bar.over %}bg-danger{% else %}bg-primary{% endif %} bg-opacity-50"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="small text-body-secondary mt-1">{% blocktrans with running=given.assigned.running|filesizeformat %}{{ running }} running{% endblocktrans %}</div>
|
||||
<div class="small text-body-secondary mt-1">{% blocktrans with running=given.assigned.running|filesizeformat %}{{ running }} in running VMs{% endblocktrans %}</div>
|
||||
|
|
|
|||
|
|
@ -15,4 +15,4 @@
|
|||
<div class="progress-bar {% if given.ratio > 4 %}bg-danger{% elif given.ratio > 2 %}bg-warning{% else %}bg-primary{% endif %} bg-opacity-50"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="small text-body-secondary mt-1">{% blocktrans with running=given.vcpus.running %}{{ running }} running{% endblocktrans %}</div>
|
||||
<div class="small text-body-secondary mt-1">{% blocktrans with running=given.vcpus.running %}{{ running }} in running VMs{% endblocktrans %}</div>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
{% load bootstrap_icons %}
|
||||
{# The host's sections. section: the one this page belongs to; detail: the page is an item of it (a pool, a network), not the section's own page #}
|
||||
<nav class="host-nav" aria-label="{% trans "Host sections" %}">
|
||||
<ol class="breadcrumb shadow-sm">
|
||||
<ol class="breadcrumb flex-nowrap overflow-x-auto text-nowrap shadow-sm">
|
||||
<li class="breadcrumb-item">
|
||||
{% if section == "overview" and not detail %}<span class="fw-bold" aria-current="page">{% bs_icon 'laptop' %} {% trans "Overview" %}</span>
|
||||
{% else %}<a href="{% url 'overview' compute.id %}"{% if section == "overview" %} class="fw-bold" aria-current="true"{% endif %}>{% bs_icon 'laptop' %} {% trans "Overview" %}</a>{% endif %}
|
||||
|
|
|
|||
|
|
@ -63,9 +63,9 @@ class ComputesPageTests(TestCase):
|
|||
self.assertEqual(cells[1], "6 3 running")
|
||||
self.assertIn("2.5:1", cells[2])
|
||||
self.assertIn("40 vCPUs on 16 CPUs", cells[2])
|
||||
self.assertIn("24 running", cells[2])
|
||||
self.assertIn("24 in running VMs", cells[2])
|
||||
self.assertIn("75 % 48.0 GB / 64.0 GB", cells[3])
|
||||
self.assertIn("32.0 GB running", cells[3])
|
||||
self.assertIn("32.0 GB in running VMs", cells[3])
|
||||
# the totals of the hosts read: host-two's capacity could not be
|
||||
totals = [" ".join(card.text_content().split()) for card in page.xpath("//div[@class='card-body']")]
|
||||
self.assertEqual(totals, ["Hosts 2 / 2 connected", "VMs 3 / 6 running", "vCPUs given 40 on 16 CPUs",
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ class GraphScriptTestCase(TestCase):
|
|||
cpu_now: element({}), mem_now: element({})};
|
||||
let poll;
|
||||
const page = {
|
||||
document: {body: {}, getElementById: (id) => elements[id] || {}},
|
||||
document: {body: {}, documentElement: {lang: "en"}, getElementById: (id) => elements[id] || {}},
|
||||
// Chart.js adds the lists a config leaves out
|
||||
getComputedStyle: () => ({getPropertyValue: () => ""}),
|
||||
Chart: Object.assign(function (canvas, config) {
|
||||
|
|
@ -174,7 +174,7 @@ class ChartAxisTestCase(unittest.TestCase):
|
|||
const vm = require("vm");
|
||||
let chart;
|
||||
const page = {
|
||||
document: {body: {}},
|
||||
document: {body: {}, documentElement: {lang: "en"}},
|
||||
getComputedStyle: () => ({getPropertyValue: () => ""}),
|
||||
Chart: Object.assign(function (canvas, config) {
|
||||
this.data = config.data; this.options = config.options; this.update = () => {}; chart = this;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class OverviewTestCase(TestCase):
|
|||
self.assertIn("rack 4", text(page, "//div[@id='host_status']"))
|
||||
cards = [" ".join(" ".join(card.itertext()).split()) for card in page.xpath("//div[@class='card h-100']")]
|
||||
self.assertIn("VMs 6 3 running, 2 shut off, 1 paused Instances →", cards)
|
||||
self.assertTrue(any(card.startswith("vCPUs 1.5:1 12 vCPUs on 8 CPUs 6 running") for card in cards), cards)
|
||||
self.assertTrue(any(card.startswith("vCPUs 1.5:1 12 vCPUs on 8 CPUs 6 in running VMs") for card in cards), cards)
|
||||
self.assertTrue(any(card.startswith("Memory 75 % 24.0 GB / 32.0 GB") for card in cards), cards)
|
||||
self.assertTrue(any("120.0 GB free of 500.0 GB" in card for card in cards), cards)
|
||||
hardware = text(page, "//div[@class='card-header'][normalize-space()='Hardware']/..")
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ class StatsScriptTestCase(TestDriverVM, TestCase):
|
|||
}
|
||||
const page = {
|
||||
$,
|
||||
document: {body: {}, getElementById,
|
||||
document: {body: {}, documentElement: {lang: "en"}, getElementById,
|
||||
querySelector: () => ({addEventListener: (name, handler) => { handlers[name] = handler; }})},
|
||||
// Chart.js adds the lists a config leaves out
|
||||
getComputedStyle: () => ({getPropertyValue: () => ""}),
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -2703,6 +2703,10 @@ msgstr "Sunucunun %(memory)s belleğinden %(stopped)s"
|
|||
|
||||
#: computes/templates/computes/capacity_memory.html:18
|
||||
#: computes/templates/computes/capacity_vcpus.html:18
|
||||
#, python-format
|
||||
msgid "%(running)s in running VMs"
|
||||
msgstr "Çalışan sanal makinelerde %(running)s"
|
||||
|
||||
#: computes/templates/computes/list.html:94
|
||||
#, python-format
|
||||
msgid "%(running)s running"
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -2564,6 +2564,10 @@ msgstr "占主机 %(memory)s 中的 %(stopped)s"
|
|||
|
||||
#: computes/templates/computes/capacity_memory.html:18
|
||||
#: computes/templates/computes/capacity_vcpus.html:18
|
||||
#, python-format
|
||||
msgid "%(running)s in running VMs"
|
||||
msgstr "运行中的虚拟机占 %(running)s"
|
||||
|
||||
#: computes/templates/computes/list.html:94
|
||||
#, python-format
|
||||
msgid "%(running)s running"
|
||||
|
|
|
|||
|
|
@ -18,10 +18,9 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="d-flex justify-content-end mb-3">
|
||||
<input id="filter" class="form-control form-control-sm w-auto" type="search" placeholder="{% trans "Search" %}" aria-label="{% trans "Search devices" %}">
|
||||
</div>
|
||||
<input id="filter" class="form-control w-auto mb-3" type="search" placeholder="{% trans "Search devices" %}" aria-label="{% trans "Search devices" %}">
|
||||
|
||||
{# on a phone each table keeps the device, what the host has on it and who uses it #}
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">{% trans "PCI devices" %} <span class="badge text-bg-light border">{{ pci_count }}</span></div>
|
||||
{% if pci_count %}
|
||||
|
|
@ -31,9 +30,9 @@
|
|||
<tr>
|
||||
<th scope="col">{% trans "Address" %}</th>
|
||||
<th scope="col">{% trans "Device" %}</th>
|
||||
<th scope="col">{% trans "Type" %}</th>
|
||||
<th scope="col">{% trans "Driver" %}</th>
|
||||
<th scope="col">{% trans "Host resources" %}</th>
|
||||
<th scope="col" class="d-none d-md-table-cell">{% trans "Type" %}</th>
|
||||
<th scope="col" class="d-none d-md-table-cell">{% trans "Driver" %}</th>
|
||||
<th scope="col" class="d-none d-md-table-cell">{% trans "Host resources" %}</th>
|
||||
<th scope="col">{% trans "Used by" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
@ -52,10 +51,11 @@
|
|||
<div class="small text-body-secondary">{{ device.vendor }} <span class="font-monospace">{{ device.ids }}</span></div>
|
||||
{% if device.physfn %}<div class="small text-body-secondary">{% blocktrans with address=device.physfn %}Virtual function of {{ address }}{% endblocktrans %}</div>{% endif %}
|
||||
{% if device.vfs %}<div class="small text-body-secondary">{% blocktrans count counter=device.vfs %}{{ counter }} virtual function{% plural %}{{ counter }} virtual functions{% endblocktrans %}</div>{% endif %}
|
||||
{% if device.resources %}<div class="d-md-none mt-1">{% include "nodedev_resources.html" %}</div>{% endif %}
|
||||
</td>
|
||||
<td class="text-nowrap">{{ device.kind }}</td>
|
||||
<td class="font-monospace">{{ device.driver|default:"–" }}</td>
|
||||
<td>{% include "nodedev_resources.html" %}</td>
|
||||
<td class="text-nowrap d-none d-md-table-cell">{{ device.kind }}</td>
|
||||
<td class="font-monospace d-none d-md-table-cell">{{ device.driver|default:"–" }}</td>
|
||||
<td class="d-none d-md-table-cell">{% include "nodedev_resources.html" %}</td>
|
||||
<td class="text-nowrap">{% include "nodedev_users.html" %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
@ -77,8 +77,8 @@
|
|||
<tr>
|
||||
<th scope="col">{% trans "Bus / device" %}</th>
|
||||
<th scope="col">{% trans "Device" %}</th>
|
||||
<th scope="col">{% trans "Type" %}</th>
|
||||
<th scope="col">{% trans "Host resources" %}</th>
|
||||
<th scope="col" class="d-none d-md-table-cell">{% trans "Type" %}</th>
|
||||
<th scope="col" class="d-none d-md-table-cell">{% trans "Host resources" %}</th>
|
||||
<th scope="col">{% trans "Used by" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
@ -91,8 +91,8 @@
|
|||
<div class="small text-body-secondary">{{ device.vendor }} <span class="font-monospace">{{ device.ids }}</span></div>
|
||||
{% if device.same_model %}<div class="small text-body-secondary">{% trans "One of several of this model: a VM that names the model alone may take any of them." %}</div>{% endif %}
|
||||
</td>
|
||||
<td>{{ device.kinds|join:", "|default:"–" }}</td>
|
||||
<td>{% include "nodedev_resources.html" %}</td>
|
||||
<td class="d-none d-md-table-cell">{{ device.kinds|join:", "|default:"–" }}</td>
|
||||
<td class="d-none d-md-table-cell">{% include "nodedev_resources.html" %}</td>
|
||||
<td>
|
||||
{% if device.vms or not device.by_model %}{% include "nodedev_users.html" %}{% endif %}
|
||||
{% if device.by_model %}<div class="small">{% blocktrans with vms=device.by_model|join:", " %}By model: {{ vms }}{% endblocktrans %}</div>{% endif %}
|
||||
|
|
|
|||
|
|
@ -89,13 +89,14 @@
|
|||
</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">#</th>
|
||||
<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">{% trans "Priority" %}</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>
|
||||
|
|
@ -103,7 +104,7 @@
|
|||
<tbody>
|
||||
{% for rule in rules %}
|
||||
<tr>
|
||||
<th scope="row">{{ forloop.counter }}</th>
|
||||
<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>
|
||||
|
|
@ -111,9 +112,10 @@
|
|||
{% 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 class="text-nowrap">{% 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>{% if rule.priority is not None %}{{ rule.priority }}{% else %}500{% endif %}</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>
|
||||
|
|
|
|||
|
|
@ -21,15 +21,16 @@
|
|||
<input id="filter" class="form-control form-control-sm w-auto" type="search" placeholder="{% trans "Search" %}" aria-label="{% trans "Search filters" %}">
|
||||
</div>
|
||||
<div class="table-responsive position-relative">
|
||||
{# on a phone: the name, the chain and the actions; the filter's page has the rest #}
|
||||
<table class="table table-hover align-middle mb-0" data-sortable>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{% trans "Name" %}</th>
|
||||
<th scope="col">{% trans "Chain" %}</th>
|
||||
<th scope="col" data-sort-method="number">{% trans "Priority" %}</th>
|
||||
<th scope="col" data-sort-method="number">{% trans "Rules" %}</th>
|
||||
<th scope="col">{% trans "References" %}</th>
|
||||
<th scope="col">{% trans "Directly used by" %}</th>
|
||||
<th scope="col" class="d-none d-md-table-cell" data-sort-method="number">{% trans "Priority" %}</th>
|
||||
<th scope="col" class="d-none d-md-table-cell" data-sort-method="number">{% trans "Rules" %}</th>
|
||||
<th scope="col" class="d-none d-md-table-cell">{% trans "References" %}</th>
|
||||
<th scope="col" class="d-none d-md-table-cell">{% trans "Directly used by" %}</th>
|
||||
<th scope="col" data-sort-method="none"><span class="visually-hidden">{% trans "Actions" %}</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
@ -38,10 +39,10 @@
|
|||
<tr data-search="{{ nwf.name }} {{ nwf.chain|default:"" }}{% for ref in nwf.refs %} {{ ref }}{% endfor %}{% for vm in nwf.vms %} {{ vm }}{% endfor %}">
|
||||
<td class="text-nowrap"><a href="{% url 'nwfilter' compute.id nwf.name %}">{{ nwf.name }}</a></td>
|
||||
<td class="font-monospace text-nowrap">{{ nwf.chain|default:"–" }}</td>
|
||||
<td>{% if nwf.priority is not None %}{{ nwf.priority }}{% else %}–{% endif %}</td>
|
||||
<td>{{ nwf.rules }}</td>
|
||||
<td class="small">{{ nwf.refs|join:", "|default:"–" }}</td>
|
||||
<td class="small text-nowrap">
|
||||
<td class="d-none d-md-table-cell">{% if nwf.priority is not None %}{{ nwf.priority }}{% else %}–{% endif %}</td>
|
||||
<td class="d-none d-md-table-cell">{{ nwf.rules }}</td>
|
||||
<td class="small d-none d-md-table-cell">{{ nwf.refs|join:", "|default:"–" }}</td>
|
||||
<td class="small text-nowrap d-none d-md-table-cell">
|
||||
{% if nwf.vms or nwf.referenced_by %}
|
||||
{% if nwf.vms %}{% blocktrans count counter=nwf.vms|length %}{{ counter }} VM{% plural %}{{ counter }} VMs{% endblocktrans %}{% endif %}{% if nwf.vms and nwf.referenced_by %}, {% endif %}
|
||||
{% if nwf.referenced_by %}{% blocktrans count counter=nwf.referenced_by|length %}{{ counter }} filter{% plural %}{{ counter }} filters{% endblocktrans %}{% endif %}
|
||||
|
|
|
|||
|
|
@ -129,14 +129,21 @@ th[aria-sort="ascending"]:not([data-sort-method="none"])::after {
|
|||
height: 160px;
|
||||
}
|
||||
|
||||
/* the host's sections (computes/host_nav.html) on one line in every theme:
|
||||
/* the host's sections (computes/host_nav.html) on one line in every theme,
|
||||
scrolled sideways on a phone:
|
||||
one font size, and the divider spaced alike on its two sides (Zephyr
|
||||
doubles the space after it) */
|
||||
.host-nav .breadcrumb {
|
||||
--bs-breadcrumb-item-padding-x: .5rem;
|
||||
/* room for a link's focus outline inside the scrolling row, in a theme without padding */
|
||||
padding: max(.25rem, var(--bs-breadcrumb-padding-y, 0px)) max(.25rem, var(--bs-breadcrumb-padding-x, 0px));
|
||||
font-size: .875rem;
|
||||
}
|
||||
|
||||
.host-nav .breadcrumb-item {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.host-nav .breadcrumb-item + .breadcrumb-item::before {
|
||||
padding-right: var(--bs-breadcrumb-item-padding-x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,16 @@
|
|||
var CHART_POINTS = 10;
|
||||
// the pixels a tick's label needs from the next one
|
||||
var TICK_ROOM = 60;
|
||||
// a reading as the page's language writes it (a decimal comma in Turkish), one decimal at most;
|
||||
// no thousands separator, as the panel's own pages
|
||||
var PAGE_LANGUAGE = document.documentElement.lang || undefined;
|
||||
var formatNumber = new Intl.NumberFormat(PAGE_LANGUAGE, {maximumFractionDigits: 1, useGrouping: false}).format;
|
||||
|
||||
(function () {
|
||||
var style = getComputedStyle(document.body);
|
||||
Chart.defaults.color = style.getPropertyValue("--bs-body-color").trim();
|
||||
Chart.defaults.borderColor = style.getPropertyValue("--bs-border-color").trim();
|
||||
Chart.defaults.locale = PAGE_LANGUAGE; // the tooltips' numbers
|
||||
})();
|
||||
|
||||
// labels: one per line. options: max (the y axis top), tooltip(context, text)
|
||||
|
|
@ -58,7 +63,8 @@ function lineChart(canvas, unit, labels, options) {
|
|||
},
|
||||
},
|
||||
},
|
||||
y: {min: 0, max: options.max, ticks: {callback: function (value) { return value + " " + unit; }}},
|
||||
// the axis as Chart.js writes it (its precision, the page language), with the unit
|
||||
y: {min: 0, max: options.max, ticks: {callback: function () { return Chart.Ticks.formatters.numeric.apply(this, arguments) + " " + unit; }}},
|
||||
},
|
||||
plugins: {
|
||||
legend: {display: labels.length > 1},
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ var cpuChart = lineChart(document.getElementById("cpuChart"), "%", [state.datase
|
|||
max: 100,
|
||||
tooltip: function (context, text) {
|
||||
var span = cpuWindows[context.dataIndex];
|
||||
return span ? text + ' (' + state.dataset.averageOver + ' ' + span + ' s)' : text;
|
||||
return span ? text + ' (' + state.dataset.averageOver + ' ' + formatNumber(span) + ' s)' : text;
|
||||
},
|
||||
});
|
||||
var memChart = lineChart(document.getElementById("memChart"), "GiB", [state.dataset.usage]);
|
||||
|
|
@ -42,7 +42,7 @@ pollWhileVisible(5000, function () {
|
|||
if (data.memdata.total) {
|
||||
memChart.options.scales.y.max = gb(data.memdata.total);
|
||||
addPoint(memChart, data.timeline, [gb(data.memdata.usage)]);
|
||||
memNow.textContent = gb(data.memdata.usage) + " / " + gb(data.memdata.total) + " GiB";
|
||||
memNow.textContent = formatNumber(gb(data.memdata.usage)) + " / " + formatNumber(gb(data.memdata.total)) + " GiB";
|
||||
} else {
|
||||
addPoint(memChart, data.timeline, [null]);
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ pollWhileVisible(5000, function () {
|
|||
stale();
|
||||
return;
|
||||
}
|
||||
cpuNow.textContent = data.cpudata + " %";
|
||||
cpuNow.textContent = formatNumber(data.cpudata) + " %";
|
||||
lastUpdate = data.timeline;
|
||||
state.textContent = state.dataset.updated.replace("%(time)s", data.timeline);
|
||||
state.classList.remove("text-danger");
|
||||
|
|
|
|||
|
|
@ -298,14 +298,6 @@
|
|||
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
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
var statsSample = null;
|
||||
// a reading for the line above a chart: one decimal, a dash where it is missing
|
||||
function reading(value) {
|
||||
return value == null ? "–" : String(Math.round(value * 10) / 10);
|
||||
return value == null ? "–" : formatNumber(value);
|
||||
}
|
||||
stats_tab.addEventListener('hidden.bs.tab', function () {
|
||||
stats_poll.stop();
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
max: 100,
|
||||
tooltip: function (context, text) {
|
||||
var span = cpuWindows[context.dataIndex];
|
||||
return span ? text + ' (' + pane.dataset.averageOver + ' ' + span + ' s)' : text;
|
||||
return span ? text + ' (' + pane.dataset.averageOver + ' ' + formatNumber(span) + ' s)' : text;
|
||||
},
|
||||
});
|
||||
var memChart = lineChart(document.getElementById("memChart"), "MiB", [pane.dataset.usageRss]);
|
||||
|
|
|
|||
12
static/js/scroll_rows.js
Normal file
12
static/js/scroll_rows.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// A row of tabs or sections that scrolls sideways on a phone (overflow-x-auto)
|
||||
// keeps its current item in sight: centred in the row, the page stays put.
|
||||
(function () {
|
||||
function centre(item) {
|
||||
var row = item.closest(".overflow-x-auto");
|
||||
if (!row) return;
|
||||
var box = row.getBoundingClientRect(), own = item.getBoundingClientRect();
|
||||
row.scrollLeft += own.left - box.left - (box.width - own.width) / 2;
|
||||
}
|
||||
document.addEventListener("shown.bs.tab", function (event) { centre(event.target); });
|
||||
document.querySelectorAll(".overflow-x-auto [aria-current]").forEach(centre);
|
||||
})();
|
||||
|
|
@ -96,7 +96,7 @@
|
|||
</span>
|
||||
</li>
|
||||
<li class="list-group-item py-1 d-flex justify-content-between gap-3">
|
||||
<span class="text-body-secondary">{% trans "Type" %}</span><span>{{ type|default:"—" }}</span>
|
||||
<span class="text-body-secondary">{% trans "Type" %}</span>{% if type %}<span class="badge text-bg-light border">{{ type }}</span>{% else %}<span>—</span>{% endif %}
|
||||
</li>
|
||||
<li class="list-group-item py-1 d-flex justify-content-between gap-3">
|
||||
<span class="text-body-secondary">{% trans "Path" %}</span>
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
<ul class="list-group list-group-flush flex-grow-1">
|
||||
<li class="list-group-item py-1 d-flex justify-content-between align-items-baseline gap-3">
|
||||
<span class="text-body-secondary">{% trans "Type" %}</span>
|
||||
<span class="badge text-bg-light border">{{ pool.type|upper }}</span>
|
||||
<span class="badge text-bg-light border">{{ pool.type }}</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 "Path" %}</span>
|
||||
|
|
|
|||
|
|
@ -234,9 +234,9 @@ class PoolListTests(TestCase):
|
|||
page = html.fromstring(self.client.get(reverse("storages", args=[compute.pk])).content)
|
||||
cards = [" ".join(" ".join(card.itertext()).split()) for card in page.xpath("//div[@class='card h-100']")]
|
||||
self.assertEqual(cards, [
|
||||
"default Active Autostart Type DIR Path /var/lib/libvirt/images Volumes 3 60 bytes free of 100 bytes",
|
||||
"ceph-vms Active Type RBD Path vms Volumes 9 5 bytes free of 100 bytes",
|
||||
"backup Stopped Type DIR Path /srv/backup Volumes – Space unavailable while stopped",
|
||||
"default Active Autostart Type dir Path /var/lib/libvirt/images Volumes 3 60 bytes free of 100 bytes",
|
||||
"ceph-vms Active Type rbd Path vms Volumes 9 5 bytes free of 100 bytes",
|
||||
"backup Stopped Type dir Path /srv/backup Volumes – Space unavailable while stopped",
|
||||
])
|
||||
self.assertEqual(page.xpath("//div[contains(@class,'progress-bar')]/@class"),
|
||||
["progress-bar ", "progress-bar bg-danger"])
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@
|
|||
<script src="{% static 'js/sort_tables.js' %}"></script>
|
||||
<script src="{% static 'js/error_focus.js' %}"></script>
|
||||
<script src="{% static 'js/back_links.js' %}"></script>
|
||||
<script src="{% static 'js/scroll_rows.js' %}"></script>
|
||||
<script src="{% static 'js/console_window.js' %}"></script>
|
||||
{% block script %}{% endblock %}
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue