[pve-devel] applied: [PATCH manager] fix 'NaN%' when max value is 0

Dietmar Maurer dietmar at proxmox.com
Wed Oct 19 12:05:52 CEST 2016



> On October 12, 2016 at 12:04 PM Dominik Csapak <d.csapak at proxmox.com> wrote:
> 
> 
> 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.csapak at 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 at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list