when we get a max value of 0
(for example when a storage is not active)

the render function would show:
'NaN% (0B of 0B)'

because of a division by 0

this patch simply returns 'N/A' because
a max value of 0 should never be valid

Signed-off-by: Dominik Csapak <d.csa...@proxmox.com>
---
 www/manager6/Utils.js | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 4ec7d5b..f9f780b 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1037,6 +1037,9 @@ Ext.define('PVE.Utils', { statics: {
     },
 
     render_size_usage: function(val, max) {
+       if (max === 0) {
+           return gettext('N/A');
+       }
        return (val*100/max).toFixed(2) + '% '+ '(' +
            Ext.String.format(gettext('{0} of {1}'),
            PVE.Utils.render_size(val), PVE.Utils.render_size(max)) + ')';
-- 
2.1.4


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to