From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 528658DAE5 for ; Wed, 9 Nov 2022 15:26:28 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 37B181D224 for ; Wed, 9 Nov 2022 15:26:28 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 9 Nov 2022 15:26:26 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 960B64308A for ; Wed, 9 Nov 2022 15:26:26 +0100 (CET) From: Daniel Tschlatscher To: pbs-devel@lists.proxmox.com Date: Wed, 9 Nov 2022 15:25:23 +0100 Message-Id: <20221109142524.549045-2-d.tschlatscher@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221109142524.549045-1-d.tschlatscher@proxmox.com> References: <20221109142524.549045-1-d.tschlatscher@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.157 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [datastore.rs] Subject: [pbs-devel] [PATCH backup v5 2/3] 'available' field in rrd data in the API and change usage of 'total' X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Nov 2022 14:26:28 -0000 The API now exposes the field 'available' as well, with which the unprivileged total is calculated in all corresponsing views in the frontend. The rrd charts now also display the total as the unprivileged total if available, otherwise the absolute total is used. Signed-off-by: Daniel Tschlatscher --- Changes from v4: * The API now no longer uses the 'unpriv-total' field but instead exposes the field 'available as well'. Subsequently, the calculation for the unprivileged total is now made in the GUI. * The Usage display in the datastore summary now also displays the total for the unprivileged user * RRD charts now also use the unprivileged total src/api2/admin/datastore.rs | 1 + www/dashboard/DataStoreStatistics.js | 7 ++++++- www/datastore/DataStoreListSummary.js | 5 +++-- www/datastore/Summary.js | 18 ++++++++++++++++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index e66e1c0b..c8e86b07 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -1804,6 +1804,7 @@ pub fn get_rrd_stats( let mut rrd_fields = vec![ "total", + "available", "used", "read_ios", "read_bytes", diff --git a/www/dashboard/DataStoreStatistics.js b/www/dashboard/DataStoreStatistics.js index 38f7a2fe..0510fc7d 100644 --- a/www/dashboard/DataStoreStatistics.js +++ b/www/dashboard/DataStoreStatistics.js @@ -3,7 +3,12 @@ Ext.define('pbs-datastore-statistics', { fields: [ 'store', - 'total', + { + name: 'total', + calculate: function(data) { + return data.avail + data.used; + }, + }, 'used', 'avail', 'estimated-full-date', diff --git a/www/datastore/DataStoreListSummary.js b/www/datastore/DataStoreListSummary.js index c7b67d56..bec0562d 100644 --- a/www/datastore/DataStoreListSummary.js +++ b/www/datastore/DataStoreListSummary.js @@ -52,10 +52,11 @@ Ext.define('PBS.datastore.DataStoreListSummary', { vm.set('maintenance', ''); } - let usage = statusData.used/statusData.total; + 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(statusData.total, true), + Proxmox.Utils.format_size(total, true), ); let usagePanel = me.lookup('usage'); diff --git a/www/datastore/Summary.js b/www/datastore/Summary.js index 94be9559..d67e81cc 100644 --- a/www/datastore/Summary.js +++ b/www/datastore/Summary.js @@ -3,6 +3,20 @@ Ext.define('pve-rrd-datastore', { fields: [ 'used', 'total', + { + name: 'unpriv-total', // Can't resuse 'total' here as that creates a stack overflow + calculate: function(data) { + let used = data.used; + let avail = data.available; + + if (avail && used) { + return avail + used; + } + + return data.total; + }, + }, + 'available', 'read_ios', 'read_bytes', 'write_ios', @@ -66,8 +80,8 @@ Ext.define('PBS.DataStoreInfo', { let vm = me.getViewModel(); let counts = store.getById('counts').data.value; - let total = store.getById('total').data.value; let used = store.getById('used').data.value; + let total = store.getById('avail').data.value + used; let usage = Proxmox.Utils.render_size_usage(used, total, true); vm.set('usagetext', usage); @@ -236,7 +250,7 @@ Ext.define('PBS.DataStoreSummary', { { xtype: 'proxmoxRRDChart', title: gettext('Storage usage (bytes)'), - fields: ['total', 'used'], + fields: ['unpriv-total', 'used'], fieldTitles: [gettext('Total'), gettext('Storage usage')], }, { -- 2.30.2