public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: Matthias Heiserer <m.heiserer@proxmox.com>,
	Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH widget-toolkit] StatusView: fix usage calculation for fields without valid values
Date: Fri, 11 Mar 2022 10:52:46 +0100	[thread overview]
Message-ID: <ef2eba08-870b-7aa4-4a8b-61a7b130a41f@proxmox.com> (raw)
In-Reply-To: <b23eb9cf-c6e2-0ff6-8669-22ff22987c6e@proxmox.com>

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'




  reply	other threads:[~2022-03-11  9:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10 14:31 Dominik Csapak
2022-03-11  9:13 ` Matthias Heiserer
2022-03-11  9:52   ` Dominik Csapak [this message]
2022-04-26  6:29 ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ef2eba08-870b-7aa4-4a8b-61a7b130a41f@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=m.heiserer@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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