all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Philipp Hufnagl <p.hufnagl@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 2/3] ui: Show if Filter includes or excludes
Date: Mon, 23 Oct 2023 17:43:01 +0200	[thread overview]
Message-ID: <20231023154302.2558918-3-p.hufnagl@proxmox.com> (raw)
In-Reply-To: <20231023154302.2558918-1-p.hufnagl@proxmox.com>

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 <p.hufnagl@proxmox.com>
---
 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: `<span class="pmx-hint">${gettext('Note')}</span>: `
-			+ 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





  parent reply	other threads:[~2023-10-23 15:43 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-23 15:42 [pbs-devel] [PATCH proxmox-backup 0/3] fix #4315: datastore: Exclude entries from sync Philipp Hufnagl
2023-10-23 15:43 ` [pbs-devel] [PATCH proxmox-backup 1/3] fix #4315: jobs: modify GroupFilter so include/exclude is tracked Philipp Hufnagl
2023-10-24  9:18   ` Lukas Wagner
2023-10-24  9:54     ` Philipp Hufnagl
2023-10-24 10:43       ` Lukas Wagner
2023-10-24 14:32         ` Philipp Hufnagl
2023-10-25 13:33           ` Thomas Lamprecht
2023-10-25 15:07             ` Philipp Hufnagl
2023-10-25 15:45               ` Thomas Lamprecht
2023-11-07  7:43                 ` Wolfgang Bumiller
2023-11-07  7:55                   ` Thomas Lamprecht
2023-11-07  8:26                     ` Wolfgang Bumiller
2023-11-07  9:01                       ` Dominik Csapak
2023-11-07 11:10                         ` Thomas Lamprecht
2023-11-07 11:07                       ` Thomas Lamprecht
2023-10-23 15:43 ` Philipp Hufnagl [this message]
2023-10-24 12:20   ` [pbs-devel] [PATCH proxmox-backup 2/3] ui: Show if Filter includes or excludes Lukas Wagner
2023-10-24 12:27   ` Lukas Wagner
2023-10-24 12:36     ` Philipp Hufnagl
2023-10-24 14:09       ` Philipp Hufnagl
2023-10-24 14:12         ` Lukas Wagner
2023-10-27  9:29           ` Thomas Lamprecht
2023-10-23 15:43 ` [pbs-devel] [PATCH proxmox-backup 3/3] docs: document new include/exclude paramenter Philipp Hufnagl

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=20231023154302.2558918-3-p.hufnagl@proxmox.com \
    --to=p.hufnagl@proxmox.com \
    --cc=pbs-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal