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 0A85D9D0F5 for ; Thu, 23 Nov 2023 10:15:07 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E0F3A34B0D for ; Thu, 23 Nov 2023 10:14:36 +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 ; Thu, 23 Nov 2023 10:14:36 +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 14DC942F6A for ; Thu, 23 Nov 2023 10:14:36 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Thu, 23 Nov 2023 10:14:34 +0100 Message-Id: <20231123091435.1548813-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.017 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com] Subject: [pve-devel] [PATCH manager v2 1/2] ui: resource tree: optimize change detection 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: , X-List-Received-Date: Thu, 23 Nov 2023 09:15:07 -0000 the 'text' property comes from the ResourceStore, but we often replace it here before rendering, so this will trigger every time for tree elements where we make use of 'setText'. Instead, check for the 'name' property. To ensure the tags get updated with the correct colors, listen to the 'loadedUiOptions' event and mark every node changed for the next update cycle. This way the calls to setText, etc. should be drastically reduced. Signed-off-by: Dominik Csapak --- this is a partial replacement for: https://lists.proxmox.com/pipermail/pve-devel/2023-November/060774.html changes from v1: * split out the optimization * to show the current tag override colors, redraw the elements when there was a 'loadedUiOptions' event www/manager6/tree/ResourceTree.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/www/manager6/tree/ResourceTree.js b/www/manager6/tree/ResourceTree.js index d3c15aec..e07e4ba0 100644 --- a/www/manager6/tree/ResourceTree.js +++ b/www/manager6/tree/ResourceTree.js @@ -264,7 +264,7 @@ Ext.define('PVE.tree.ResourceTree', { let stateid = 'rid'; const changedFields = [ - 'text', 'running', 'template', 'status', 'qmpstatus', 'hastate', 'lock', 'tags', + 'name', 'running', 'template', 'status', 'qmpstatus', 'hastate', 'lock', 'tags', ]; let updateTree = function() { @@ -294,6 +294,9 @@ Ext.define('PVE.tree.ResourceTree', { let item = rstore.data.get(olditem.data.id); let changed = sorting_changed, moved = sorting_changed; + if (me.needsUpdate) { + changed = true; + } if (item) { // test if any grouping attributes changed, catches migrated tree-nodes in server view too for (const attr of moveCheckAttrs) { @@ -376,6 +379,7 @@ Ext.define('PVE.tree.ResourceTree', { } pdata.updateCount++; + me.needsUpdate = false; }; sp.on('statechange', (_sp, key, value) => { @@ -498,6 +502,10 @@ Ext.define('PVE.tree.ResourceTree', { rstore.on("load", updateTree); rstore.startUpdate(); + + me.mon(Ext.GlobalEvents, 'loadedUiOptions', () => { + me.needsUpdate = true; + }); }, }); -- 2.30.2