[pbs-devel] [PATCH proxmox-backup 6/6] ui: sync jobs: add search box

Dominik Csapak d.csapak at proxmox.com
Mon Nov 25 12:15:37 CET 2024


filter by (remote) store, remote, id, owner, direction.
Local store is only included on the globabl view not the datastore
specific one.

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/config/SyncView.js | 62 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/www/config/SyncView.js b/www/config/SyncView.js
index 3471100b6..ca1f7ecd6 100644
--- a/www/config/SyncView.js
+++ b/www/config/SyncView.js
@@ -31,6 +31,40 @@ Ext.define('PBS.config.SyncJobView', {
     controller: {
 	xclass: 'Ext.app.ViewController',
 
+	search: function(tf, value) {
+	    let me = this;
+	    let view = me.getView();
+	    let store = view.getStore();
+	    if (!value && value !== 0) {
+		store.clearFilter();
+		tf.triggers.clear.setVisible(false);
+		return;
+	    }
+	    tf.triggers.clear.setVisible(true);
+	    if (value.length < 2) return;
+
+	    store.clearFilter();
+
+	    let fieldsToSearch = ['direction', 'id', 'remote', 'remote-store', 'owner'];
+	    if (!view.datastore) {
+		fieldsToSearch.push('store');
+	    }
+	    value = value.toLowerCase();
+
+
+	    store.addFilter(function(rec) {
+		let found = false;
+		for (const field of fieldsToSearch) {
+		    let recValue = rec.data[field] ?? '';
+		    if (recValue.toString().toLowerCase().indexOf(value) !== -1) {
+			found = true;
+			break;
+		    }
+		}
+		return found;
+	    });
+	},
+
 	addPullSyncJob: function() {
 	    this.addSyncJob('pull');
 	},
@@ -197,6 +231,34 @@ Ext.define('PBS.config.SyncJobView', {
 	    handler: 'runSyncJob',
 	    disabled: true,
 	},
+	'->',
+	{
+	    xtype: 'tbtext',
+	    html: gettext('Search'),
+	},
+	{
+	    xtype: 'textfield',
+	    reference: 'searchbox',
+	    emptyText: gettext('(remote) store, remote, id, owner, direction'),
+	    minWidth: 300,
+	    triggers: {
+		clear: {
+		    cls: 'pmx-clear-trigger',
+		    weight: -1,
+		    hidden: true,
+		    handler: function() {
+			this.triggers.clear.setVisible(false);
+			this.setValue('');
+		    },
+		},
+	    },
+	    listeners: {
+		change: {
+		    fn: 'search',
+		    buffer: 500,
+		},
+	    },
+	},
     ],
 
     viewConfig: {
-- 
2.39.5





More information about the pbs-devel mailing list