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 78AAD9C2DA for ; Mon, 23 Oct 2023 17:43:39 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5AF091652C for ; Mon, 23 Oct 2023 17:43:09 +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 for ; Mon, 23 Oct 2023 17:43:08 +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 5F6E3445C8 for ; Mon, 23 Oct 2023 17:43:08 +0200 (CEST) From: Philipp Hufnagl To: pbs-devel@lists.proxmox.com Date: Mon, 23 Oct 2023 17:43:01 +0200 Message-Id: <20231023154302.2558918-3-p.hufnagl@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231023154302.2558918-1-p.hufnagl@proxmox.com> References: <20231023154302.2558918-1-p.hufnagl@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.073 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 Subject: [pbs-devel] [PATCH proxmox-backup 2/3] ui: Show if Filter includes or excludes X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Oct 2023 15:43:39 -0000 To make the UI compatible, the Group Filter dialogue has been extended by a "behaviour" column which will show if the filter includes or excludes the matches. While it would be a nice feature to also re-sort the filter in the GUI, it is not strictly needed for it to work and should (in my option) be done in an other patch. Signed-off-by: Philipp Hufnagl --- www/form/GroupFilter.js | 57 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/www/form/GroupFilter.js b/www/form/GroupFilter.js index dee37b0b..10ac02c4 100644 --- a/www/form/GroupFilter.js +++ b/www/form/GroupFilter.js @@ -45,6 +45,22 @@ Ext.define('PBS.form.GroupFilter', { me.updateRealField(); }, + + onBehaviourChange: function(field, value) { + let me = this; + let record = field.getWidgetRecord(); + if (record === undefined) { + return; + } + + record.set('behaviour', value); + record.commit(); + if (record.widgets) { + me.setInputValue(record.widgets, record); + } + me.updateRealField(); + }, + onTypeChange: function(field, value) { let me = this; let record = field.getWidgetRecord(); @@ -77,8 +93,12 @@ Ext.define('PBS.form.GroupFilter', { }, parseGroupFilter: function(filter) { - let [, type, input] = filter.match(/^(type|group|regex):(.*)$/); + let [, behaviour, type, input] = filter.match(/^(?:(exclude|include):)?(type|group|regex):(.*)$/); + if (behaviour === undefined) { + behaviour = "include"; + } return { + behaviour, type, input, }; @@ -163,8 +183,12 @@ Ext.define('PBS.form.GroupFilter', { let filter = []; me.lookup('grid').getStore().each((rec) => { - if (rec.data.type && rec.data.input) { - filter.push(`${rec.data.type}:${rec.data.input}`); + if (rec.data.type && rec.data.input && rec.data.behaviour) { + let behaviour_string = ''; + if (rec.data.behaviour === 'exclude') { + behaviour_string = 'exclude:'; + } + filter.push(`${behaviour_string}${rec.data.type}:${rec.data.input}`); } }); @@ -175,6 +199,9 @@ Ext.define('PBS.form.GroupFilter', { }, control: { + 'grid pbsGroupBehaviourSelector': { + change: 'onBehaviourChange', + }, 'grid pbsGroupFilterTypeSelector': { change: 'onTypeChange', }, @@ -277,6 +304,16 @@ Ext.define('PBS.form.GroupFilter', { deferEmptyText: false, }, columns: [ + { + text: gettext('Behaviour'), + xtype: 'widgetcolumn', + dataIndex: 'behaviour', + flex: 1, + widget: { + xtype: 'pbsGroupBehaviourSelector', + isFormField: false, + }, + }, { text: gettext('Filter Type'), xtype: 'widgetcolumn', @@ -368,7 +405,7 @@ Ext.define('PBS.form.GroupFilter', { xtype: 'box', style: 'margin: 3px 0px;', html: `${gettext('Note')}: ` - + gettext('Filters are additive (OR-like)'), + + gettext('Filters are additive or subtractive'), }, ], }, @@ -384,6 +421,18 @@ Ext.define('PBS.form.GroupFilter', { }, }); +Ext.define('PBS.form.pbsGroupBehaviourSelector', { + extend: 'Proxmox.form.KVComboBox', + alias: 'widget.pbsGroupBehaviourSelector', + + allowBlank: false, + + comboItems: [ + ['include', gettext('Include')], + ['exclude', gettext('Exclude')], + ], +}); + Ext.define('PBS.form.GroupFilterTypeSelector', { extend: 'Proxmox.form.KVComboBox', alias: 'widget.pbsGroupFilterTypeSelector', -- 2.39.2