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 0B25E66254 for ; Thu, 5 Nov 2020 12:13:10 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0174517369 for ; Thu, 5 Nov 2020 12:12:40 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 id 7F6A51735F for ; Thu, 5 Nov 2020 12:12:39 +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 48ABB45EB2 for ; Thu, 5 Nov 2020 12:12:39 +0100 (CET) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Thu, 5 Nov 2020 12:12:24 +0100 Message-Id: <20201105111226.4105475-4-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201105111226.4105475-1-f.gruenbichler@proxmox.com> References: <20201105111226.4105475-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.024 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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 v2 proxmox-backup 3/5] www: add remote store selector 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: Thu, 05 Nov 2020 11:13:10 -0000 (hopefully) improved upon NFS export selection in PVE Signed-off-by: Fabian Grünbichler --- Notes: v2: - rename actualChange to firstLoad and add comment - drop monStoreErrors (Dominik sent a patch to do this directly and properly in ComboGrid) www/window/SyncJobEdit.js | 97 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/www/window/SyncJobEdit.js b/www/window/SyncJobEdit.js index e4e47fa4..c3c0e228 100644 --- a/www/window/SyncJobEdit.js +++ b/www/window/SyncJobEdit.js @@ -1,3 +1,90 @@ +Ext.define('PBS.form.RemoteStoreSelector', { + extend: 'Proxmox.form.ComboGrid', + alias: 'widget.pbsRemoteStoreSelector', + + queryMode: 'local', + + valueField: 'store', + displayField: 'store', + notFoundIsValid: true, + + matchFieldWidth: false, + listConfig: { + loadingText: gettext('Scanning...'), + width: 350, + columns: [ + { + header: gettext('Datastore'), + sortable: true, + dataIndex: 'store', + renderer: Ext.String.htmlEncode, + flex: 1, + }, + { + header: gettext('Comment'), + dataIndex: 'comment', + renderer: Ext.String.htmlEncode, + flex: 1, + }, + ], + }, + + doRawQuery: function() { + // do nothing. + }, + + setRemote: function(remote) { + let me = this; + + if (me.remote === remote) { + return; + } + + me.remote = remote; + + let store = me.store; + store.removeAll(); + + if (me.remote) { + me.setDisabled(false); + if (!me.firstLoad) { + me.clearValue(); + } + + store.proxy.url = '/api2/json/config/remote/' + encodeURIComponent(me.remote) + '/scan'; + store.load(); + + me.firstLoad = false; + } else { + me.setDisabled(true); + me.clearValue(); + } + }, + + initComponent: function() { + let me = this; + + me.firstLoad = true; + + let store = Ext.create('Ext.data.Store', { + fields: ['store', 'comment'], + proxy: { + type: 'proxmox', + url: '/api2/json/config/remote/' + encodeURIComponent(me.remote) + '/scan', + }, + }); + + store.sort('store', 'ASC'); + + Ext.apply(me, { + store: store, + }); + + me.callParent(); + }, +}); + + Ext.define('PBS.window.SyncJobEdit', { extend: 'Proxmox.window.Edit', alias: 'widget.pbsSyncJobEdit', @@ -80,12 +167,20 @@ Ext.define('PBS.window.SyncJobEdit', { xtype: 'pbsRemoteSelector', allowBlank: false, name: 'remote', + listeners: { + change: function(f, value) { + let me = this; + let remoteStoreField = me.up('pbsSyncJobEdit').down('field[name=remote-store]'); + remoteStoreField.setRemote(value); + }, + }, }, { fieldLabel: gettext('Source Datastore'), - xtype: 'proxmoxtextfield', + xtype: 'pbsRemoteStoreSelector', allowBlank: false, name: 'remote-store', + disabled: true, }, { fieldLabel: gettext('Sync Schedule'), -- 2.20.1