From: Gabriel Goller <g.goller@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 1/2] ui: datastore summary handle non-existent values
Date: Thu, 7 Dec 2023 15:35:26 +0100 [thread overview]
Message-ID: <20231207143527.282373-2-g.goller@proxmox.com> (raw)
In-Reply-To: <20231207143527.282373-1-g.goller@proxmox.com>
Correctly display missing 'avail' and 'used' attributes in the
datatstore summary. This simply sets it to 0, so that we don't get any
errors in the console.
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
www/datastore/DataStoreListSummary.js | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/www/datastore/DataStoreListSummary.js b/www/datastore/DataStoreListSummary.js
index 968239b0..b908034d 100644
--- a/www/datastore/DataStoreListSummary.js
+++ b/www/datastore/DataStoreListSummary.js
@@ -52,12 +52,20 @@ Ext.define('PBS.datastore.DataStoreListSummary', {
vm.set('maintenance', '');
}
- let total = statusData.avail + statusData.used;
- let usage = statusData.used / total;
- let usagetext = Ext.String.format(gettext('{0} of {1}'),
- Proxmox.Utils.format_size(statusData.used, true),
- Proxmox.Utils.format_size(total, true),
- );
+ let usagetext;
+ let usage;
+
+ if (Object.hasOwn(statusData, 'avail') && Object.hasOwn(statusData, 'used')) {
+ let total = statusData.avail + statusData.used;
+ usage = statusData.used / total;
+ usagetext = Ext.String.format(gettext('{0} of {1}'),
+ Proxmox.Utils.format_size(statusData.used, true),
+ Proxmox.Utils.format_size(total, true),
+ );
+ } else {
+ usagetext = Ext.String.format(gettext('{0} of {1}'), 0, 0);
+ usage = 0;
+ }
let usagePanel = me.lookup('usage');
usagePanel.updateValue(usage, usagetext);
--
2.39.2
next prev parent reply other threads:[~2023-12-07 14:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-07 14:35 [pbs-devel] [PATCH proxmox-backup 0/2] Fix DatastoreListSummary on limited permissions Gabriel Goller
2023-12-07 14:35 ` Gabriel Goller [this message]
2023-12-07 14:35 ` [pbs-devel] [PATCH proxmox-backup 2/2] status: use Option on avail/used datastore attrs Gabriel Goller
2023-12-07 17:07 ` Dietmar Maurer
2023-12-07 17:10 ` Dietmar Maurer
2023-12-07 17:33 ` Dietmar Maurer
2023-12-11 8:46 ` Gabriel Goller
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=20231207143527.282373-2-g.goller@proxmox.com \
--to=g.goller@proxmox.com \
--cc=pbs-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