public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH widget-toolkit] StatusView: fix usage calculation for fields without valid values
@ 2022-03-10 14:31 Dominik Csapak
  2022-03-11  9:13 ` Matthias Heiserer
  2022-04-26  6:29 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 2 replies; 4+ messages in thread
From: Dominik Csapak @ 2022-03-10 14:31 UTC (permalink / raw)
  To: pve-devel

Sometimes, total can be zero (e.g. for swap when it's not used), which
leads to the usage being NaN. This led to the progressbar not being
updated for InfoWidgets, leaving a spurious '0%' as text.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/panel/StatusView.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/panel/StatusView.js b/src/panel/StatusView.js
index 4a60dae..e2e81e2 100644
--- a/src/panel/StatusView.js
+++ b/src/panel/StatusView.js
@@ -47,7 +47,7 @@ Ext.define('Proxmox.panel.StatusView', {
 	     */
 	    if (used.used !== undefined &&
 		used.total !== undefined) {
-		return used.used/used.total;
+		return used.total > 0 ? used.used/used.total : 0;
 	    }
 	}
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] [PATCH widget-toolkit] StatusView: fix usage calculation for fields without valid values
  2022-03-10 14:31 [pve-devel] [PATCH widget-toolkit] StatusView: fix usage calculation for fields without valid values Dominik Csapak
@ 2022-03-11  9:13 ` Matthias Heiserer
  2022-03-11  9:52   ` Dominik Csapak
  2022-04-26  6:29 ` [pve-devel] applied: " Thomas Lamprecht
  1 sibling, 1 reply; 4+ messages in thread
From: Matthias Heiserer @ 2022-03-11  9:13 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dominik Csapak

On 10.03.2022 15:31, Dominik Csapak wrote:
> Sometimes, total can be zero (e.g. for swap when it's not used), which
> leads to the usage being NaN. This led to the progressbar not being
> updated for InfoWidgets, leaving a spurious '0%' as text.
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>   src/panel/StatusView.js | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/panel/StatusView.js b/src/panel/StatusView.js
> index 4a60dae..e2e81e2 100644
> --- a/src/panel/StatusView.js
> +++ b/src/panel/StatusView.js
> @@ -47,7 +47,7 @@ Ext.define('Proxmox.panel.StatusView', {
>   	     */
>   	    if (used.used !== undefined &&
>   		used.total !== undefined) {
> -		return used.used/used.total;
> +		return used.total > 0 ? used.used/used.total : 0;
>   	    }
>   	}
>   

When used.used or used.total is undefined, the function still returns 
NaN. Have you considered using the or operator?




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] [PATCH widget-toolkit] StatusView: fix usage calculation for fields without valid values
  2022-03-11  9:13 ` Matthias Heiserer
@ 2022-03-11  9:52   ` Dominik Csapak
  0 siblings, 0 replies; 4+ messages in thread
From: Dominik Csapak @ 2022-03-11  9:52 UTC (permalink / raw)
  To: Matthias Heiserer, Proxmox VE development discussion

On 3/11/22 10:13, Matthias Heiserer wrote:
> On 10.03.2022 15:31, Dominik Csapak wrote:
>> Sometimes, total can be zero (e.g. for swap when it's not used), which
>> leads to the usage being NaN. This led to the progressbar not being
>> updated for InfoWidgets, leaving a spurious '0%' as text.
>>
>> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
>> ---
>>   src/panel/StatusView.js | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/panel/StatusView.js b/src/panel/StatusView.js
>> index 4a60dae..e2e81e2 100644
>> --- a/src/panel/StatusView.js
>> +++ b/src/panel/StatusView.js
>> @@ -47,7 +47,7 @@ Ext.define('Proxmox.panel.StatusView', {
>>            */
>>           if (used.used !== undefined &&
>>           used.total !== undefined) {
>> -        return used.used/used.total;
>> +        return used.total > 0 ? used.used/used.total : 0;
>>           }
>>       }
> 
> When used.used or used.total is undefined, the function still returns NaN. Have you considered using 
> the or operator?

that can't happen because of the 'if' check:

'used.used !== undefined && used.total !== undefined'




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] applied: [PATCH widget-toolkit] StatusView: fix usage calculation for fields without valid values
  2022-03-10 14:31 [pve-devel] [PATCH widget-toolkit] StatusView: fix usage calculation for fields without valid values Dominik Csapak
  2022-03-11  9:13 ` Matthias Heiserer
@ 2022-04-26  6:29 ` Thomas Lamprecht
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2022-04-26  6:29 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dominik Csapak

On 10.03.22 15:31, Dominik Csapak wrote:
> Sometimes, total can be zero (e.g. for swap when it's not used), which
> leads to the usage being NaN. This led to the progressbar not being
> updated for InfoWidgets, leaving a spurious '0%' as text.
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  src/panel/StatusView.js | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-26  6:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-10 14:31 [pve-devel] [PATCH widget-toolkit] StatusView: fix usage calculation for fields without valid values Dominik Csapak
2022-03-11  9:13 ` Matthias Heiserer
2022-03-11  9:52   ` Dominik Csapak
2022-04-26  6:29 ` [pve-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal