From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@proxmox.com>
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 7D81D6035B
 for <pve-devel@lists.proxmox.com>; Wed,  2 Dec 2020 10:21:20 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id AE71E191AC
 for <pve-devel@lists.proxmox.com>; Wed,  2 Dec 2020 10:21:19 +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 B5C3C19072
 for <pve-devel@lists.proxmox.com>; Wed,  2 Dec 2020 10:21:15 +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 7A85A447D0
 for <pve-devel@lists.proxmox.com>; Wed,  2 Dec 2020 10:21:15 +0100 (CET)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Wed,  2 Dec 2020 10:21:11 +0100
Message-Id: <20201202092113.15911-9-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201202092113.15911-1-d.csapak@proxmox.com>
References: <20201202092113.15911-1-d.csapak@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.298 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: [pve-devel] [PATCH manager 6/7] ui: add necessary fields for
 influxdb http api
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Wed, 02 Dec 2020 09:21:20 -0000

and en/disable them accordingly to the selected mode

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/manager6/dc/MetricServerView.js | 101 ++++++++++++++++++++++++++--
 1 file changed, 96 insertions(+), 5 deletions(-)

diff --git a/www/manager6/dc/MetricServerView.js b/www/manager6/dc/MetricServerView.js
index e30ea14e..dfec8c03 100644
--- a/www/manager6/dc/MetricServerView.js
+++ b/www/manager6/dc/MetricServerView.js
@@ -174,6 +174,13 @@ Ext.define('PVE.dc.InfluxDBEdit', {
 
     subject: 'InfluxDB',
 
+    cbindData: function() {
+	let me = this;
+	me.callParent();
+	me.tokenEmptyText = me.isCreate ? '' : gettext('unchanged');
+	return {};
+    },
+
     items: [
 	{
 	    xtype: 'inputpanel',
@@ -209,6 +216,41 @@ Ext.define('PVE.dc.InfluxDBEdit', {
 		    fieldLabel: gettext('Server'),
 		    allowBlank: false,
 		},
+		{
+		    xtype: 'proxmoxintegerfield',
+		    name: 'port',
+		    fieldLabel: gettext('Port'),
+		    value: 8089,
+		    minValue: 1,
+		    maximum: 65536,
+		    allowBlank: false,
+		},
+		{
+		    xtype: 'proxmoxKVComboBox',
+		    name: 'influxdbproto',
+		    fieldLabel: gettext('Protocol'),
+		    value: '__default__',
+		    cbind: {
+			deleteEmpty: '{!isCreate}',
+		    },
+		    comboItems: [
+			['__default__', 'UDP'],
+			['http', 'HTTP'],
+			['https', 'HTTPS'],
+		    ],
+		    listeners: {
+			change: function(field, value) {
+			    let me = this;
+			    let isUdp = value !== 'http' && value !== 'https';
+			    me.up('inputpanel').down('field[name=organization]').setDisabled(isUdp);
+			    me.up('inputpanel').down('field[name=bucket]').setDisabled(isUdp);
+			    me.up('inputpanel').down('field[name=token]').setDisabled(isUdp);
+			    me.up('inputpanel').down('field[name=mtu]').setDisabled(!isUdp);
+			    me.up('inputpanel').down('field[name=timeout]').setDisabled(isUdp);
+			    me.up('inputpanel').down('field[name=max-body-size]').setDisabled(isUdp);
+			},
+		    },
+		},
 	    ],
 
 	    column2: [
@@ -220,18 +262,67 @@ Ext.define('PVE.dc.InfluxDBEdit', {
 		    uncheckedValue: 0,
 		    checked: true,
 		},
+		{
+		    xtype: 'proxmoxtextfield',
+		    name: 'organization',
+		    fieldLabel: gettext('Organization'),
+		    emptyText: 'proxmox',
+		    disabled: true,
+		    cbind: {
+			deleteEmpty: '{!isCreate}',
+		    },
+		},
+		{
+		    xtype: 'proxmoxtextfield',
+		    name: 'bucket',
+		    fieldLabel: gettext('Bucket'),
+		    emptyText: 'proxmox',
+		    disabled: true,
+		    cbind: {
+			deleteEmpty: '{!isCreate}',
+		    },
+		},
+		{
+		    xtype: 'proxmoxtextfield',
+		    name: 'token',
+		    fieldLabel: gettext('Token'),
+		    disabled: true,
+		    allowBlank: true,
+		    deleteEmpty: false,
+		    submitEmpty: false,
+		    cbind: {
+			disabled: '{!isCreate}',
+			emptyText: '{tokenEmptyText}',
+		    },
+		},
+	    ],
+
+	    advancedColumn1: [
 		{
 		    xtype: 'proxmoxintegerfield',
-		    name: 'port',
-		    fieldLabel: gettext('Port'),
-		    value: 8089,
+		    name: 'timeout',
+		    fieldLabel: gettext('Timeout (s)'),
+		    disabled: true,
+		    cbind: {
+			deleteEmpty: '{!isCreate}',
+		    },
 		    minValue: 1,
-		    maximum: 65536,
-		    allowBlank: false,
+		    emptyText: 1,
 		},
 	    ],
 
 	    advancedColumn2: [
+		{
+		    xtype: 'proxmoxintegerfield',
+		    name: 'max-body-size',
+		    fieldLabel: gettext('Batch Size (b)'),
+		    minValue: 1,
+		    emptyText: '25000000',
+		    submitEmpty: false,
+		    cbind: {
+			deleteEmpty: '{!isCreate}',
+		    },
+		},
 		{
 		    xtype: 'proxmoxintegerfield',
 		    name: 'mtu',
-- 
2.20.1