From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 5A8891FF0E1 for ; Mon, 16 Nov 2026 09:52:41 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id A917A216EC; Mon, 16 Nov 2026 09:52:29 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Subject: [PATCH pve-manager v4 1/2] ui: resource tree: use 'diskuse' instead of calculating every time Date: Mon, 16 Nov 2026 09:51:00 +0100 Message-ID: <20261116085222.993923-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.306 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: H2WYNJGI6IDMI2QXYTZIQCUV3SY2LYHE X-Message-ID-Hash: H2WYNJGI6IDMI2QXYTZIQCUV3SY2LYHE X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: the resource store has a field 'diskuse' which it calculates on update. Use that instead of calculating the value ourselves every time. For change detection, we only need a resolution of 0.001 (since we want to use the percentage with one decimal place) so check that the difference of old and new is at least 0.001 (0.1%). This works because we only overwrite the values in the treestore if anything changed, so multiple small changes to the diskuse will not be lost. Signed-off-by: Dominik Csapak --- changes from v3: * rebase on current master * lower the change detection threshold from 0.01 (1%) to 0.001 (0.1%) * show the usage in the tooltip with one decimal place instead of two, so it matches the change detection resolution (thanks Jonas & Thomas) * adapt the commit message to the new threshold and state it as fraction and percentage * wrap an overly long comment * did not carry over Jonas' Tested-by, since the threshold and the tooltip rendering changed www/manager6/tree/ResourceTree.js | 34 ++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/www/manager6/tree/ResourceTree.js b/www/manager6/tree/ResourceTree.js index e2acc431..3efb1cd3 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); @@ -192,9 +192,9 @@ 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))); + qtips.push(Ext.String.format(gettext('Usage: {0}%'), (usage * 100).toFixed(1))); } } @@ -333,8 +333,6 @@ Ext.define('PVE.tree.ResourceTree', { let stateid = 'rid'; const changedFields = [ - 'disk', - 'maxdisk', 'vmid', 'name', 'type', @@ -432,14 +430,30 @@ Ext.define('PVE.tree.ResourceTree', { } } - // tree item has been updated - for (const field of changedFields) { - if (item.data[field] !== olditem.data[field]) { + let diskUsage = item.data.diskuse; + let oldDiskUsage = olditem.data.diskuse; + + if (diskUsage !== undefined && oldDiskUsage !== undefined) { + // we have an old and new value, so check if it changed enough + if (Math.abs(diskUsage - oldDiskUsage) >= 0.001) { changed = true; - break; } + } else if (diskUsage !== undefined || oldDiskUsage !== undefined) { + // we have either a new or an old value, but not both, + // always treat that as a change + changed = true; + } + + 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()? } - // FIXME: also test filterfn()? } if (changed) { -- 2.47.3