From: Thomas Lamprecht Date: Tue, 4 May 2021 08:27:17 +0000 (+0200) Subject: utils: code cleanup/refactoring X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=ce8289fc58d85dde8df69b1702108a329be52398;p=proxmox-widget-toolkit.git utils: code cleanup/refactoring no semantic change intended Signed-off-by: Thomas Lamprecht --- diff --git a/src/Utils.js b/src/Utils.js index 1dd2098..52f1314 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -855,7 +855,7 @@ utilities: { return value; }, - render_usage: val => (val*100).toFixed(2) + '%', + render_usage: val => (val * 100).toFixed(2) + '%', render_cpu_usage: function(val, max) { return Ext.String.format( @@ -869,9 +869,9 @@ utilities: { if (max === 0) { return gettext('N/A'); } - return (val*100/max).toFixed(2) + '% (' + - Ext.String.format(gettext('{0} of {1}'), - Proxmox.Utils.render_size(val), Proxmox.Utils.render_size(max)) + ')'; + let fmt = v => Proxmox.Utils.format_size(v); + let ratio = (val * 100 / max).toFixed(2); + return ratio + '% (' + Ext.String.format(gettext('{0} of {1}'), fmt(val), fmt(max)) + ')'; }, render_cpu: function(value, metaData, record, rowIndex, colIndex, store) {