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 1882B8527 for ; Tue, 15 Nov 2022 14:11:49 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E9F7436AE for ; Tue, 15 Nov 2022 14:11:18 +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 ; Tue, 15 Nov 2022 14:11:15 +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 3B27C44C10 for ; Tue, 15 Nov 2022 14:02:52 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Tue, 15 Nov 2022 14:02:47 +0100 Message-Id: <20221115130248.1007325-23-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221115130248.1007325-1-d.csapak@proxmox.com> References: <20221115130248.1007325-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: =?UTF-8?Q?0=0A=09?=AWL -1.536 Adjusted score from AWL reputation of From: =?UTF-8?Q?address=0A=09?=BAYES_00 -1.9 Bayes spam probability is 0 to 1% ENA_SUBJ_ODD_CASE 3.2 Subject has odd =?UTF-8?Q?case=0A=09?=KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict =?UTF-8?Q?Alignment=0A=09?=SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF =?UTF-8?Q?Record=0A=09?=SPF_PASS -0.001 SPF: sender matches SPF =?UTF-8?Q?record=0A=09?=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 v10 12/13] ui: add tags to ResourceGrid and GlobalSearchField 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, 15 Nov 2022 13:11:49 -0000 also allows to search for tags in the GlobalSearchField where 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 ui: ResourceGrid: render tags with the 'full' styling Signed-off-by: Dominik Csapak --- www/manager6/data/ResourceStore.js | 1 + www/manager6/form/GlobalSearchField.js | 20 +++++++++++++++----- www/manager6/grid/ResourceGrid.js | 1 + 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/www/manager6/data/ResourceStore.js b/www/manager6/data/ResourceStore.js index b18f7dd8d..ed1f4699e 100644 --- a/www/manager6/data/ResourceStore.js +++ b/www/manager6/data/ResourceStore.js @@ -295,6 +295,7 @@ Ext.define('PVE.data.ResourceStore', { }, tags: { header: gettext('Tags'), + renderer: (value) => PVE.Utils.renderTags(value, PVE.Utils.tagOverrides), type: 'string', hidden: true, sortable: true, diff --git a/www/manager6/form/GlobalSearchField.js b/www/manager6/form/GlobalSearchField.js index 267a480d7..8e815d4f5 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) { diff --git a/www/manager6/grid/ResourceGrid.js b/www/manager6/grid/ResourceGrid.js index 29906a376..9376bcc26 100644 --- a/www/manager6/grid/ResourceGrid.js +++ b/www/manager6/grid/ResourceGrid.js @@ -7,6 +7,7 @@ Ext.define('PVE.grid.ResourceGrid', { property: 'type', direction: 'ASC', }, + userCls: 'proxmox-tags-full', initComponent: function() { let me = this; -- 2.30.2