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 A09DFC184D for ; Tue, 16 Jan 2024 15:33:57 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8A36D3845D for ; Tue, 16 Jan 2024 15:33:57 +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 for ; Tue, 16 Jan 2024 15:33:56 +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 AAE4C49176 for ; Tue, 16 Jan 2024 15:33:56 +0100 (CET) From: Folke Gleumes To: pve-devel@lists.proxmox.com Date: Tue, 16 Jan 2024 15:33:37 +0100 Message-Id: <20240116143338.294260-2-f.gleumes@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240116143338.294260-1-f.gleumes@proxmox.com> References: <20240116143338.294260-1-f.gleumes@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH manager 1/2] fix #5093: webui: acme: custom directory option X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jan 2024 14:33:57 -0000 This patch allows the user to set a custom ACME directory by providing a 'Custom' option in the directory dropdown. This in turn reveals an input for the url. When using a custom directory the directory has to be manually queried via button press to prevent from spamming the directory on every input. Signed-off-by: Folke Gleumes --- www/manager6/node/ACME.js | 140 +++++++++++++++++++++++++++++--------- 1 file changed, 107 insertions(+), 33 deletions(-) diff --git a/www/manager6/node/ACME.js b/www/manager6/node/ACME.js index 21137b1a..5b71778a 100644 --- a/www/manager6/node/ACME.js +++ b/www/manager6/node/ACME.js @@ -10,6 +10,14 @@ Ext.define('PVE.node.ACMEAccountCreate', { url: '/cluster/acme/account', showTaskViewer: true, defaultExists: false, + referenceHolder: true, + onlineHelp: "sysadmin_certs_acme_account", + + viewModel: { + data: { + customDirectory: false, + }, + }, items: [ { @@ -30,12 +38,17 @@ Ext.define('PVE.node.ACMEAccountCreate', { }, { xtype: 'proxmoxComboGrid', - name: 'directory', - allowBlank: false, + notFoundIsValid: true, + isFormField: false, valueField: 'url', displayField: 'name', fieldLabel: gettext('ACME Directory'), store: { + listeners: { + 'load': function() { + this.add({ name: gettext("Custom"), url: '' }); + }, + }, autoLoad: true, fields: ['name', 'url'], idProperty: ['name'], @@ -43,10 +56,6 @@ Ext.define('PVE.node.ACMEAccountCreate', { type: 'proxmox', url: '/api2/json/cluster/acme/directories', }, - sorters: { - property: 'name', - direction: 'ASC', - }, }, listConfig: { columns: [ @@ -64,41 +73,93 @@ Ext.define('PVE.node.ACMEAccountCreate', { }, listeners: { change: function(combogrid, value) { - var me = this; - if (!value) { - return; - } + let me = this; - var disp = me.up('window').down('#tos_url_display'); - var field = me.up('window').down('#tos_url'); - var checkbox = me.up('window').down('#tos_checkbox'); + let vm = me.up('window').getViewModel(); + let dirField = me.up('window').lookupReference('directoryInput'); + let tosButton = me.up('window').lookupReference('queryTos'); - disp.setValue(gettext('Loading')); - field.setValue(undefined); - checkbox.setValue(undefined); - checkbox.setHidden(true); + let isCustom = combogrid.getSelection().get('name') === gettext("Custom"); + vm.set('customDirectory', isCustom); - Proxmox.Utils.API2Request({ - url: '/cluster/acme/meta', - method: 'GET', - params: { - directory: value, + dirField.setValue(value); + + if (!isCustom) { + tosButton.click(); + } else { + me.up('window').clearToSFields(); + } + }, + }, + }, + { + xtype: 'fieldcontainer', + layout: 'hbox', + fieldLabel: gettext('URL'), + bind: { + hidden: '{!customDirectory}', + }, + items: [ + { + xtype: 'proxmoxtextfield', + name: 'directory', + reference: 'directoryInput', + flex: 1, + allowBlank: false, + listeners: { + change: function(textbox, value) { + let me = this; + me.up('window').clearToSFields(); }, - success: function(response, opt) { - if (response.result.data.termsOfService) { - field.setValue(response.result.data.termsOfService); - disp.setValue(response.result.data.termsOfService); - checkbox.setHidden(false); + }, + }, + { + xtype: 'proxmoxButton', + margin: '0 0 0 5', + reference: 'queryTos', + text: gettext('Query URL'), + listeners: { + click: function(button) { + let me = this; + + let w = me.up('window'); + let disp = w.down('#tos_url_display'); + let field = w.down('#tos_url'); + let checkbox = w.down('#tos_checkbox'); + let value = w.lookupReference('directoryInput').getValue(); + w.clearToSFields(); + + if (!value) { + return; } else { - disp.setValue(undefined); + disp.setValue(gettext("Loading")); } + + Proxmox.Utils.API2Request({ + url: '/cluster/acme/meta', + method: 'GET', + params: { + directory: value, + }, + success: function(response, opt) { + if (response.result.data.termsOfService) { + field.setValue(response.result.data.termsOfService); + disp.setValue(response.result.data.termsOfService); + checkbox.setHidden(false); + } else { + checkbox.setValue(false); + disp.setValue("No terms of service agreement required"); + } + }, + failure: function(response, opt) { + disp.setValue(undefined); + Ext.Msg.alert(gettext('Error'), response.htmlStatus); + }, + }); }, - failure: function(response, opt) { - Ext.Msg.alert(gettext('Error'), response.htmlStatus); - }, - }); + }, }, - }, + ], }, { xtype: 'displayfield', @@ -125,6 +186,19 @@ Ext.define('PVE.node.ACMEAccountCreate', { }, ], + clearToSFields: function() { + let me = this; + + let disp = me.down('#tos_url_display'); + let field = me.down('#tos_url'); + let checkbox = me.down('#tos_checkbox'); + + disp.setValue("Terms of service not fetched yet"); + field.setValue(undefined); + checkbox.setValue(undefined); + checkbox.setHidden(true); + }, + }); Ext.define('PVE.node.ACMEAccountView', { -- 2.39.2