utils: code cleanup/refactoring

no semantic change intended

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-05-04 10:27:17 +02:00
parent ff7ee78453
commit ce8289fc58

View File

@ -855,7 +855,7 @@ utilities: {
return value; return value;
}, },
render_usage: val => (val*100).toFixed(2) + '%', render_usage: val => (val * 100).toFixed(2) + '%',
render_cpu_usage: function(val, max) { render_cpu_usage: function(val, max) {
return Ext.String.format( return Ext.String.format(
@ -869,9 +869,9 @@ utilities: {
if (max === 0) { if (max === 0) {
return gettext('N/A'); return gettext('N/A');
} }
return (val*100/max).toFixed(2) + '% (' + let fmt = v => Proxmox.Utils.format_size(v);
Ext.String.format(gettext('{0} of {1}'), let ratio = (val * 100 / max).toFixed(2);
Proxmox.Utils.render_size(val), Proxmox.Utils.render_size(max)) + ')'; return ratio + '% (' + Ext.String.format(gettext('{0} of {1}'), fmt(val), fmt(max)) + ')';
}, },
render_cpu: function(value, metaData, record, rowIndex, colIndex, store) { render_cpu: function(value, metaData, record, rowIndex, colIndex, store) {