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 88F091FF17F for <inbox@lore.proxmox.com>; Mon, 19 May 2025 13:48:06 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1EE538D9F; Mon, 19 May 2025 13:48:05 +0200 (CEST) From: Christian Ebner <c.ebner@proxmox.com> To: pbs-devel@lists.proxmox.com Date: Mon, 19 May 2025 13:46:28 +0200 Message-Id: <20250519114640.303640-28-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250519114640.303640-1-c.ebner@proxmox.com> References: <20250519114640.303640-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.969 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 KAM_MAILER 2 Automated Mailer Tag Left in Email 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] [RFC proxmox-backup 27/39] ui: add S3 client edit window for configuration create/edit 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> Adds an edit window for creating or editing S3 client configurations. Loosely based on the same edit window for the remote configuration. Signed-off-by: Christian Ebner <c.ebner@proxmox.com> --- pbs-datastore/src/datastore.rs | 5 +- www/window/S3BucketEdit.js | 125 +++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 www/window/S3BucketEdit.js diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs index 68d3ac6e2..a15f82b5b 100644 --- a/pbs-datastore/src/datastore.rs +++ b/pbs-datastore/src/datastore.rs @@ -1461,8 +1461,9 @@ impl DataStore { let mut chunk_count = 0; let prefix = Some(".chunks/"); // Operates in batches of 1000 objects max per request - let mut list_bucket_result = - proxmox_async::runtime::block_on(s3_client.list_objects_v2(prefix, None, None))?; + let mut list_bucket_result = proxmox_async::runtime::block_on( + s3_client.list_objects_v2(prefix, None, None), + )?; let mut delete_list = Vec::with_capacity(1000); loop { diff --git a/www/window/S3BucketEdit.js b/www/window/S3BucketEdit.js new file mode 100644 index 000000000..1491ddbe5 --- /dev/null +++ b/www/window/S3BucketEdit.js @@ -0,0 +1,125 @@ +Ext.define('PBS.window.S3BucketEdit', { + extend: 'Proxmox.window.Edit', + alias: 'widget.pbsS3BucketEdit', + mixins: ['Proxmox.Mixin.CBind'], + + onlineHelp: 'backup_s3bucket', + + isAdd: true, + + subject: gettext('S3 Bucket'), + + fieldDefaults: { labelWidth: 120 }, + + cbindData: function(initialConfig) { + let me = this; + + let baseurl = '/api2/extjs/config/s3'; + let id = initialConfig.id; + + me.isCreate = !id; + me.url = id ? `${baseurl}/${id}` : baseurl; + me.method = id ? 'PUT' : 'POST'; + me.autoLoad = !!id; + return { + passwordEmptyText: me.isCreate ? '' : gettext('Unchanged'), + }; + }, + + items: { + xtype: 'inputpanel', + column1: [ + { + xtype: 'pmxDisplayEditField', + name: 'id', + fieldLabel: gettext('Unique Identifier'), + renderer: Ext.htmlEncode, + allowBlank: false, + minLength: 4, + cbind: { + editable: '{isCreate}', + }, + }, + { + xtype: 'proxmoxtextfield', + name: 'host', + fieldLabel: gettext('Host'), + allowBlank: false, + emptyText: gettext('FQDN or IP-address'), + }, + { + xtype: 'proxmoxtextfield', + name: 'port', + fieldLabel: gettext('Port'), + emptyText: gettext("default"), + cbind: { + deleteEmpty: '{!isCreate}', + }, + }, + ], + + column2: [ + { + xtype: 'proxmoxtextfield', + name: 'bucket', + fieldLabel: gettext('Bucket'), + allowBlank: false, + }, + { + xtype: 'proxmoxtextfield', + name: 'region', + fieldLabel: gettext('Region'), + emptyText: gettext("default"), + }, + { + xtype: 'proxmoxtextfield', + name: 'access-key', + fieldLabel: gettext('Access Key'), + cbind: { + emptyText: '{passwordEmptyText}', + allowBlank: '{!isCreate}', + }, + }, + { + xtype: 'textfield', + name: 'secret-key', + inputType: 'password', + fieldLabel: gettext('Secret Key'), + cbind: { + emptyText: '{passwordEmptyText}', + allowBlank: '{!isCreate}', + }, + }, + ], + + columnB: [ + { + xtype: 'proxmoxtextfield', + name: 'fingerprint', + fieldLabel: gettext('Fingerprint'), + emptyText: gettext("Server certificate's SHA-256 fingerprint, required for self-signed certificates"), + cbind: { + deleteEmpty: '{!isCreate}', + }, + }, + ], + }, + + getValues: function() { + let me = this; + let values = me.callParent(arguments); + + if (me.isCreate) { + /// Secrets are stored into separate config, but set the same id for both configs + values['secrets-id'] = values.id; + } + if (values['access-key'] === '') { + delete values['access-key'] + } + if (values['secret-key'] === '') { + delete values['secret-key'] + } + + return values; + }, +}); -- 2.39.5 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel