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 2446F70254 for ; Tue, 21 Jun 2022 11:20:44 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B49F12C95 for ; Tue, 21 Jun 2022 11:20:24 +0200 (CEST) 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 id C670329D5 for ; Tue, 21 Jun 2022 11:20:15 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9FB9F43C23 for ; Tue, 21 Jun 2022 11:20:15 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Tue, 21 Jun 2022 11:20:09 +0200 Message-Id: <20220621092012.1776825-22-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220621092012.1776825-1-d.csapak@proxmox.com> References: <20220621092012.1776825-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.101 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 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. [item.data] Subject: [pve-devel] [PATCH manager v7 11/14] ui: form/GlobalSearchField: display tags and allow to search for them 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: Tue, 21 Jun 2022 09:20:44 -0000 each tag is treated like a seperate field, so it weighs more if the user searches for the exact string of a single tag Signed-off-by: Dominik Csapak --- www/manager6/form/GlobalSearchField.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/www/manager6/form/GlobalSearchField.js b/www/manager6/form/GlobalSearchField.js index 267a480d..8e815d4f 100644 --- a/www/manager6/form/GlobalSearchField.js +++ b/www/manager6/form/GlobalSearchField.js @@ -15,6 +15,7 @@ Ext.define('PVE.form.GlobalSearchField', { grid: { xtype: 'gridpanel', + userCls: 'proxmox-tags-full', focusOnToFront: false, floating: true, emptyText: Proxmox.Utils.noneText, @@ -23,7 +24,7 @@ Ext.define('PVE.form.GlobalSearchField', { scrollable: { xtype: 'scroller', y: true, - x: false, + x: true, }, store: { model: 'PVEResources', @@ -78,6 +79,11 @@ Ext.define('PVE.form.GlobalSearchField', { text: gettext('Description'), flex: 1, dataIndex: 'text', + renderer: function(value, mD, rec) { + let overrides = PVE.Utils.tagOverrides; + let tags = PVE.Utils.renderTags(rec.data.tags, overrides); + return `${value}${tags}`; + }, }, { text: gettext('Node'), @@ -104,16 +110,20 @@ Ext.define('PVE.form.GlobalSearchField', { 'storage': ['type', 'pool', 'node', 'storage'], 'default': ['name', 'type', 'node', 'pool', 'vmid'], }; - let fieldArr = fieldMap[item.data.type] || fieldMap.default; + let fields = fieldMap[item.data.type] || fieldMap.default; + let fieldArr = fields.map(field => item.data[field]?.toString().toLowerCase()); + if (item.data.tags) { + let tags = item.data.tags.split(/[;, ]/); + fieldArr.push(...tags); + } let filterWords = me.filterVal.split(/\s+/); // all text is case insensitive and each split-out word is searched for separately. // a row gets 1 point for every partial match, and and additional point for every exact match let match = 0; - for (let field of fieldArr) { - let fieldValue = item.data[field]?.toString().toLowerCase(); - if (fieldValue === undefined) { + for (let fieldValue of fieldArr) { + if (fieldValue === undefined || fieldValue === "") { continue; } for (let filterWord of filterWords) { -- 2.30.2