From: Matthias Heiserer <m.heiserer@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
Dominik Csapak <d.csapak@proxmox.com>
Subject: Re: [pve-devel] [PATCH widget-toolkit] StatusView: fix usage calculation for fields without valid values
Date: Fri, 11 Mar 2022 10:13:09 +0100 [thread overview]
Message-ID: <b23eb9cf-c6e2-0ff6-8669-22ff22987c6e@proxmox.com> (raw)
In-Reply-To: <20220310143137.1384472-1-d.csapak@proxmox.com>
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?
next prev parent reply other threads:[~2022-03-11 9:13 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 [this message]
2022-03-11 9:52 ` Dominik Csapak
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=b23eb9cf-c6e2-0ff6-8669-22ff22987c6e@proxmox.com \
--to=m.heiserer@proxmox.com \
--cc=d.csapak@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