mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(ui): sizes in the units the forms ask in, percentages as the language writes them
- binary_size filter (common_tags): every size on the pages is B/KiB/MiB/GiB/TiB with the language's decimal mark; Django's filesizeformat said GB for GiB, so a page showed "512,0 MB / 3,8 GB" beside "0,4 / 3,8 GiB" and a disk "20,0 GB" next to a GiB field - percent filter and Intl percent in charts.js, the job panel and the new-VM dialog: 13% in English, %13 in Turkish (pages had "13 %", "%11" and "13%") - the Jobs page and panel say in whole sentences that the job worker is not running and that jobs wait for it, instead of a sentence glued to a date - job state badges start with a capital, as the VM state badges (CSS, so the label stays lowercase inside sentences) - profile card shows the username under the name only when there is a full name - Turkish: hostname, revert snapshot, snapshot count, API token and worker texts
This commit is contained in:
parent
50fa42181b
commit
7408a575d6
52 changed files with 241 additions and 127 deletions
|
|
@ -279,6 +279,13 @@ button.vcpu-cell:disabled { opacity: .65; }
|
|||
.nic-wire::after { right: -3px; }
|
||||
.nic-wire.nic-up { color: var(--bs-success); border-top-style: solid; }
|
||||
|
||||
/* a job state badge starts with a capital, as the VM state badges; the label stays
|
||||
lowercase for sentences ("… is running on this resource"), and the page's lang
|
||||
gives Turkish its dotted İ */
|
||||
.job-state::first-letter {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* a log message keeps a readable width when its table scrolls on a phone */
|
||||
.log-message {
|
||||
min-width: 16rem;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@ var TICK_ROOM = 60;
|
|||
// 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;
|
||||
// a percentage as the language writes it: 13% in English, %13 in Turkish
|
||||
function formatPercent(value) {
|
||||
return new Intl.NumberFormat(PAGE_LANGUAGE, {style: "percent", maximumFractionDigits: 1}).format(value / 100);
|
||||
}
|
||||
|
||||
(function () {
|
||||
var style = getComputedStyle(document.body);
|
||||
|
|
@ -26,6 +30,10 @@ function lineChart(canvas, unit, labels, options) {
|
|||
return style.getPropertyValue(name).trim();
|
||||
});
|
||||
options = options || {};
|
||||
// a reading with its unit: a percentage as the language writes it
|
||||
function withUnit(value, text) {
|
||||
return unit === "%" ? formatPercent(value) : text + " " + unit;
|
||||
}
|
||||
return new Chart(canvas, {
|
||||
type: "line",
|
||||
data: {
|
||||
|
|
@ -64,7 +72,9 @@ function lineChart(canvas, unit, labels, options) {
|
|||
},
|
||||
},
|
||||
// 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; }}},
|
||||
y: {min: 0, max: options.max, ticks: {callback: function (value) {
|
||||
return withUnit(value, Chart.Ticks.formatters.numeric.apply(this, arguments));
|
||||
}}},
|
||||
},
|
||||
plugins: {
|
||||
legend: {display: labels.length > 1},
|
||||
|
|
@ -74,7 +84,7 @@ function lineChart(canvas, unit, labels, options) {
|
|||
return items.length ? labelAt(items[0].chart, items[0].parsed.x) : "";
|
||||
},
|
||||
label: function (context) {
|
||||
var text = context.dataset.label + ": " + context.formattedValue + " " + unit;
|
||||
var text = context.dataset.label + ": " + withUnit(context.parsed.y, context.formattedValue);
|
||||
return options.tooltip ? options.tooltip(context, text) : text;
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@
|
|||
});
|
||||
table.classList.toggle("d-none", matches.length === 0);
|
||||
if (answer.coverage) {
|
||||
var readAt = fill(text.readAt, "%(time)s", new Date(answer.read_at).toLocaleTimeString());
|
||||
var readAt = fill(text.readAt, "%(time)s", new Date(answer.read_at).toLocaleTimeString(document.documentElement.lang || undefined));
|
||||
var none = MAC.test(form.elements.q.value.trim()) ? text.noneMac : text.none;
|
||||
coverage.textContent = (matches.length ? "" : none + " ") + coverageText(answer.coverage) + " " + readAt;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ pollWhileVisible(5000, function () {
|
|||
stale();
|
||||
return;
|
||||
}
|
||||
cpuNow.textContent = formatNumber(data.cpudata) + " %";
|
||||
cpuNow.textContent = formatPercent(data.cpudata);
|
||||
lastUpdate = data.timeline;
|
||||
state.textContent = state.dataset.updated.replace("%(time)s", data.timeline);
|
||||
state.classList.remove("text-danger");
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
cpuWindows.shift();
|
||||
}
|
||||
addPoint(cpuChart, data.timeline, [data.cpudata]);
|
||||
document.getElementById("cpuNow").textContent = reading(data.cpudata) + " %";
|
||||
document.getElementById("cpuNow").textContent = data.cpudata == null ? "–" : formatPercent(data.cpudata);
|
||||
// a VM whose memory could not be read gives total 0: a gap, same axis;
|
||||
// the RSS may pass the balloon size: then the axis grows to it
|
||||
if (data.memdata.total) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
const addInstance = document.getElementById("AddInstance");
|
||||
let opening = 0, queue = [], reading = 0;
|
||||
|
||||
// a percentage as the page's language writes it: 13% in English, %13 in Turkish
|
||||
const percentFormat = new Intl.NumberFormat(document.documentElement.lang || undefined, {style: "percent"});
|
||||
|
||||
function setCpuUsage(cell, percent, text) {
|
||||
const meter = cell.querySelector(".progress");
|
||||
cell.querySelector(".progress-bar").style.width = (percent || 0) + "%";
|
||||
|
|
@ -23,7 +26,7 @@ function show(element, data) {
|
|||
return;
|
||||
}
|
||||
const usage = data !== null && typeof data.cpudata === "number" ? Math.round(data.cpudata) : null;
|
||||
setCpuUsage(element, usage, usage === null ? "—" : usage + "%");
|
||||
setCpuUsage(element, usage, usage === null ? "—" : percentFormat.format(usage / 100));
|
||||
}
|
||||
|
||||
function readNext() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue