From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pbs-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 1BAE51FF173
	for <inbox@lore.proxmox.com>; Mon, 25 Nov 2024 12:16:12 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id C366210CB0;
	Mon, 25 Nov 2024 12:16:11 +0100 (CET)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Mon, 25 Nov 2024 12:15:37 +0100
Message-Id: <20241125111537.1504618-7-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20241125111537.1504618-1-d.csapak@proxmox.com>
References: <20241125111537.1504618-1-d.csapak@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.016 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 6/6] ui: sync jobs: add search box
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox Backup Server development discussion
 <pbs-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pbs-devel-bounces@lists.proxmox.com
Sender: "pbs-devel" <pbs-devel-bounces@lists.proxmox.com>

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@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



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel