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 71267810DE for ; Mon, 22 Nov 2021 15:20:56 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 67D631FD94 for ; Mon, 22 Nov 2021 15:20:26 +0100 (CET) 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 id E64531FD6B for ; Mon, 22 Nov 2021 15:20:24 +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 BAFEA44FF4 for ; Mon, 22 Nov 2021 15:20:24 +0100 (CET) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Mon, 22 Nov 2021 15:20:21 +0100 Message-Id: <20211122142024.913238-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211122142024.913238-1-d.csapak@proxmox.com> References: <20211122142024.913238-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.207 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 1/4] ui: add GroupSelector 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, 22 Nov 2021 14:20:56 -0000 to select either a local or remote group from a datastore Signed-off-by: Dominik Csapak --- www/Makefile | 1 + www/form/GroupSelector.js | 83 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 www/form/GroupSelector.js diff --git a/www/Makefile b/www/Makefile index 616c3e12..c975387c 100644 --- a/www/Makefile +++ b/www/Makefile @@ -42,6 +42,7 @@ JSSRC= \ form/DataStoreSelector.js \ form/CalendarEvent.js \ form/PermissionPathSelector.js \ + form/GroupSelector.js \ data/RunningTasksStore.js \ button/TaskButton.js \ config/UserView.js \ diff --git a/www/form/GroupSelector.js b/www/form/GroupSelector.js new file mode 100644 index 00000000..1e6c1bd4 --- /dev/null +++ b/www/form/GroupSelector.js @@ -0,0 +1,83 @@ +Ext.define('pbs-groups', { + extend: 'Ext.data.Model', + fields: [ + 'backup-type', + 'backup-id', + { + name: 'group', + type: 'string', + convert: function(value, record) { + if (record.data['backup-type'] && record.data['backup-id']) { + return `${record.data['backup-type']}/${record.data['backup-id']}`; + } + return value; + }, + }, + ], + proxy: { + type: 'proxmox', + }, +}); + +Ext.define('PBS.form.GroupSelector', { + extend: 'Proxmox.form.ComboGrid', + alias: 'widget.pbsGroupSelector', + + allowBlank: false, + autoSelect: false, + notFoundIsValid: true, + editable: true, + valueField: 'group', + displayField: 'group', + + reload: function() { + let me = this; + if (!me.isDisabled()) { + let value = me.getValue(); + me.getStore().load({ + callback: function() { + me.setValue(value); + }, + }); + } + }, + + setLocalDatastore: function(datastore) { + let me = this; + me.getStore().getProxy().setUrl(`/api2/json/admin/datastore/${datastore}/groups`); + me.reload(); + }, + + setRemoteDatastore: function(remote, datastore) { + let me = this; + me.getStore().getProxy().setUrl(`/api2/json/config/remote/${remote}/scan/${datastore}/groups`); + me.reload(); + }, + + store: { + sorters: 'group', + model: 'pbs-groups', + }, + + listConfig: { + columns: [ + { + header: gettext('Group'), + sortable: true, + dataIndex: 'group', + renderer: Ext.String.htmlEncode, + flex: 1, + }, + ], + }, + + initComponent: function() { + let me = this; + me.callParent(); + if (me.remote && me.datastore) { + me.setRemoteDatastore(me.remote, me.datastore); + } else if (me.datastore) { + me.setLocalDatastore(me.datastore); + } + }, +}); -- 2.30.2