[pbs-devel] [PATCH proxmox-backup 1/2] ui: datastore summary handle non-existent values
Gabriel Goller
g.goller at proxmox.com
Thu Dec 7 15:35:26 CET 2023
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 at 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
More information about the pbs-devel
mailing list