]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
utils: code cleanup/refactoring
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 4 May 2021 08:27:17 +0000 (10:27 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 4 May 2021 08:27:19 +0000 (10:27 +0200)
no semantic change intended

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/Utils.js

index 1dd2098dddc8729c32c23b209b06220ff4d6ae87..52f1314cf6ce91d3e506c2fbdefaff550040aae2 100644 (file)
@@ -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) {