From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager v3 1/2] ui: resource tree: use 'diskuse' instead of calculating everytime
Date: Fri, 23 Jan 2026 09:12:12 +0100 [thread overview]
Message-ID: <20260123081322.644536-1-d.csapak@proxmox.com> (raw)
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% .
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 <d.csapak@proxmox.com>
---
chnages from v2:
* use better names for variables
* check explicitely if both old and new or just one is defined
and mark it as changed accordingly
www/manager6/tree/ResourceTree.js | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/www/manager6/tree/ResourceTree.js b/www/manager6/tree/ResourceTree.js
index 6ea28919..bdb0d6f8 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);
@@ -190,7 +190,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)));
}
@@ -331,8 +331,6 @@ Ext.define('PVE.tree.ResourceTree', {
let stateid = 'rid';
const changedFields = [
- 'disk',
- 'maxdisk',
'vmid',
'name',
'type',
@@ -430,14 +428,29 @@ 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.01) {
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
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next reply other threads:[~2026-01-23 8:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 8:12 Dominik Csapak [this message]
2026-01-23 8:12 ` [pve-devel] [PATCH manager v3 2/2] ui: resource tree: only fire 'refresh' event when something changed Dominik Csapak
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=20260123081322.644536-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-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