mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-07 17:17:41 +03:00
parent
45a8543ab8
commit
556e3513da
@ -121,7 +121,7 @@ const VirtualMachineCard = memo(
|
|||||||
|
|
||||||
const error = useMemo(() => getErrorMessage(vm), [vm])
|
const error = useMemo(() => getErrorMessage(vm), [vm])
|
||||||
const ips = useMemo(() => getIps(vm), [vm])
|
const ips = useMemo(() => getIps(vm), [vm])
|
||||||
const memValue = useMemo(() => prettyBytes(+MEMORY, 'MB'), [MEMORY])
|
const memValue = useMemo(() => prettyBytes(+MEMORY, 'MB', 2), [MEMORY])
|
||||||
|
|
||||||
const labels = useMemo(
|
const labels = useMemo(
|
||||||
() =>
|
() =>
|
||||||
|
@ -80,7 +80,7 @@ const CapacityPanel = ({ vm = {}, actions, oneConfig, adminGroup }) => {
|
|||||||
{
|
{
|
||||||
icon: <MemoryIcon />,
|
icon: <MemoryIcon />,
|
||||||
name: T.Memory,
|
name: T.Memory,
|
||||||
value: prettyBytes(+MEMORY, 'MB'),
|
value: prettyBytes(+MEMORY, 'MB', 2),
|
||||||
dataCy: 'memory',
|
dataCy: 'memory',
|
||||||
},
|
},
|
||||||
![CORES, SOCKETS].includes(undefined) && {
|
![CORES, SOCKETS].includes(undefined) && {
|
||||||
|
@ -133,12 +133,14 @@ export const prettyBytes = (value, unit = UNITS.KB, fractionDigits = 0) => {
|
|||||||
|
|
||||||
let idxUnit = units.indexOf(unit)
|
let idxUnit = units.indexOf(unit)
|
||||||
|
|
||||||
while (ensuredValue > 1024) {
|
while (ensuredValue >= 1024) {
|
||||||
ensuredValue /= 1024
|
ensuredValue /= 1024
|
||||||
idxUnit += 1
|
idxUnit += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${ensuredValue.toFixed(fractionDigits)} ${units[idxUnit]}`
|
const decimals = fractionDigits && ensuredValue % 1 !== 0 ? fractionDigits : 0
|
||||||
|
|
||||||
|
return `${ensuredValue.toFixed(decimals)} ${units[idxUnit]}`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -737,6 +737,9 @@ define(function(require) {
|
|||||||
|
|
||||||
$("div.mb_input", context).on("change", "input.visor, select", function(e){
|
$("div.mb_input", context).on("change", "input.visor, select", function(e){
|
||||||
var element = $(this);
|
var element = $(this);
|
||||||
|
var step = '1'
|
||||||
|
var baseCal = 1;
|
||||||
|
var unit = "MB";
|
||||||
var min = parseInt(element.attr("data-min"),10);
|
var min = parseInt(element.attr("data-min"),10);
|
||||||
var max = parseInt(element.attr("data-max"),10);
|
var max = parseInt(element.attr("data-max"),10);
|
||||||
var value = element.val();
|
var value = element.val();
|
||||||
@ -745,26 +748,24 @@ define(function(require) {
|
|||||||
switch (mb_input_unit_val) {
|
switch (mb_input_unit_val) {
|
||||||
case "TB":
|
case "TB":
|
||||||
baseCal = base*base;
|
baseCal = base*base;
|
||||||
|
step = '0.001'
|
||||||
unit = "TB";
|
unit = "TB";
|
||||||
break;
|
break;
|
||||||
case "GB":
|
case "GB":
|
||||||
baseCal = base;
|
baseCal = base;
|
||||||
|
step = '0.01'
|
||||||
unit = "GB";
|
unit = "GB";
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
baseCal = 1;
|
|
||||||
unit = "MB";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (value >= 0) {
|
if (value >= 0) {
|
||||||
valueInMB = value * baseCal;
|
valueInMB = value * baseCal;
|
||||||
if(!isNaN(min) && parseInt(min, 10) > valueInMB ){
|
if(!isNaN(min) && parseInt(min, 10) > valueInMB ){
|
||||||
valueInMB = min;
|
valueInMB = min;
|
||||||
}
|
}
|
||||||
$("input, select", contextElement).val(valueInMB);
|
$("input, select", contextElement).val(Math.ceil(valueInMB));
|
||||||
valueInUnit = valueInMB / baseCal;
|
valueInUnit = valueInMB / baseCal;
|
||||||
}
|
}
|
||||||
$("input.visor", contextElement).val(valueInUnit);
|
$("input.visor", contextElement).attr('step', step).val(valueInUnit);
|
||||||
var contextUnit = contextElement.siblings(".input-group-button");
|
var contextUnit = contextElement.siblings(".input-group-button");
|
||||||
$(".mb_input_unit", contextUnit).val(unit);
|
$(".mb_input_unit", contextUnit).val(unit);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user