From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 9439E1FF187 for ; Tue, 18 Nov 2025 15:49:04 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D896017B7F; Tue, 18 Nov 2025 15:49:06 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Tue, 18 Nov 2025 15:48:02 +0100 Message-ID: <20251118144902.3001963-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.030 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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. [olditem.data, item.data] Subject: [pve-devel] [PATCH manager 1/2] ui: resource tree: use 'diskuse' instead of calculating everytime X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" the resource store has a field 'diskuse' which it calculates on update. Use that instead of calculating the value ourselves everytime. For change detection, we only need a resolution of 0.01 (since we want to use the percentage as integer) so check that the difference of old and new is bigger than 0.9% . Signed-off-by: Dominik Csapak --- www/manager6/tree/ResourceTree.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/www/manager6/tree/ResourceTree.js b/www/manager6/tree/ResourceTree.js index bb016f8c..4c4e2908 100644 --- a/www/manager6/tree/ResourceTree.js +++ b/www/manager6/tree/ResourceTree.js @@ -57,7 +57,7 @@ Ext.define('PVE.tree.ResourceTree', { let text = info.text; let status = ''; if (info.type === 'storage') { - let usage = info.disk / info.maxdisk; + let usage = info.diskuse; if (usage >= 0.0 && usage <= 1.0) { let barHeight = (usage * 100).toFixed(0); let remainingHeight = (100 - barHeight).toFixed(0); @@ -186,7 +186,7 @@ Ext.define('PVE.tree.ResourceTree', { qtips.push(Ext.String.format(gettext('HA State: {0}'), info.hastate)); } if (info.type === 'storage') { - let usage = info.disk / info.maxdisk; + let usage = info.diskuse; if (usage >= 0.0 && usage <= 1.0) { qtips.push(Ext.String.format(gettext('Usage: {0}%'), (usage * 100).toFixed(2))); } @@ -310,8 +310,6 @@ Ext.define('PVE.tree.ResourceTree', { let stateid = 'rid'; const changedFields = [ - 'disk', - 'maxdisk', 'vmid', 'name', 'type', @@ -409,14 +407,25 @@ Ext.define('PVE.tree.ResourceTree', { } } - // tree item has been updated - for (const field of changedFields) { - if (item.data[field] !== olditem.data[field]) { + let diskuse = item.data.diskuse; + let oldDiskuse = olditem.data.diskuse; + + if (diskuse !== undefined || oldDiskuse !== undefined) { + if (Math.abs(diskuse - oldDiskuse) > 0.009) { changed = true; - break; } } - // FIXME: also test filterfn()? + + if (!changed) { + // tree item has been updated + for (const field of changedFields) { + if (item.data[field] !== olditem.data[field]) { + changed = true; + break; + } + } + // FIXME: also test filterfn()? + } } if (changed) { -- 2.47.3 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel