From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <oguz@gaia.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 E072067C73
 for <pbs-devel@lists.proxmox.com>; Tue, 10 Nov 2020 14:29:06 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id D6FBD21F82
 for <pbs-devel@lists.proxmox.com>; Tue, 10 Nov 2020 14:29:06 +0100 (CET)
Received: from gaia.proxmox.com (212-186-127-178.static.upcbusiness.at
 [212.186.127.178])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 326F721F72
 for <pbs-devel@lists.proxmox.com>; Tue, 10 Nov 2020 14:29:06 +0100 (CET)
Received: from gaia.proxmox.com (localhost.localdomain [127.0.0.1])
 by gaia.proxmox.com (8.15.2/8.15.2/Debian-14~deb10u1) with ESMTP id
 0AADSvan1269416; Tue, 10 Nov 2020 14:28:57 +0100
Received: (from oguz@localhost)
 by gaia.proxmox.com (8.15.2/8.15.2/Submit) id 0AADSvA81269415;
 Tue, 10 Nov 2020 14:28:57 +0100
From: Oguz Bektas <o.bektas@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Tue, 10 Nov 2020 14:28:53 +0100
Message-Id: <20201110132853.1269082-2-o.bektas@proxmox.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201110132853.1269082-1-o.bektas@proxmox.com>
References: <20201110132853.1269082-1-o.bektas@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  1
 AWL -0.579 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery
 methods
 KHOP_HELO_FCRDNS          0.4 Relay HELO differs from its IP's reverse DNS
 NO_DNS_FOR_FROM         0.379 Envelope sender has no MX or A DNS records
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_NONE                0.001 SPF: sender does not publish an SPF Record
Subject: [pbs-devel] [PATCH v3 proxmox-backup 2/2] ui: add textarea in
 remote and menu for pasting json blob
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>
X-List-Received-Date: Tue, 10 Nov 2020 13:29:06 -0000

fills ip and fingerprint automatically on paste.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
---
v2->v3:
* remove console.log calls

 www/window/RemoteEdit.js | 55 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 51 insertions(+), 4 deletions(-)

diff --git a/www/window/RemoteEdit.js b/www/window/RemoteEdit.js
index 4a4d8114..92b3d929 100644
--- a/www/window/RemoteEdit.js
+++ b/www/window/RemoteEdit.js
@@ -11,6 +11,39 @@ Ext.define('PBS.window.RemoteEdit', {
 
     fieldDefaults: { labelWidth: 120 },
 
+    viewModel: {
+	parent: null,
+	data: {
+	    info: {
+		ipAddress: '',
+		fingerprint: '',
+		datastore: '',
+	    },
+	},
+    },
+
+    controller: {
+	xclass: 'Ext.app.ViewController',
+	control: {
+	    'textarea[name=serializedinfo]': {
+		change: 'deserializeInfo',
+	    },
+	},
+        deserializeInfo: function(field, value) {
+	    let vm = this.getViewModel();
+	    let jsons = Ext.util.Base64.decode(value);
+	    let joinInfo = Ext.JSON.decode(jsons, true);
+
+	    let info = {
+	        ipAddress: joinInfo.ipAddress,
+	        fingerprint: joinInfo.fingerprint,
+	        datastore: joinInfo.datastore,
+	    };
+
+	    vm.set('info', info);
+	},
+    },
+
     cbindData: function(initialConfig) {
 	let me = this;
 
@@ -26,7 +59,7 @@ Ext.define('PBS.window.RemoteEdit', {
 	};
     },
 
-    items: {
+    items: [{
 	xtype: 'inputpanel',
 	column1: [
 	    {
@@ -47,6 +80,9 @@ Ext.define('PBS.window.RemoteEdit', {
 		submitValue: false,
 		vtype: 'HostPort',
 		fieldLabel: gettext('Host'),
+		bind: {
+		    value: '{info.ipAddress}',
+		},
 		listeners: {
 		    change: function(field, newvalue) {
 			let host = newvalue;
@@ -86,7 +122,6 @@ Ext.define('PBS.window.RemoteEdit', {
 		name: 'port',
 	    },
 	],
-
 	column2: [
 	    {
 		xtype: 'proxmoxtextfield',
@@ -105,7 +140,6 @@ Ext.define('PBS.window.RemoteEdit', {
 		},
 	    },
 	],
-
 	columnB: [
 	    {
 		xtype: 'proxmoxtextfield',
@@ -114,6 +148,10 @@ Ext.define('PBS.window.RemoteEdit', {
 		    deleteEmpty: '{!isCreate}',
 		},
 		fieldLabel: gettext('Fingerprint'),
+		bind: {
+		    value: '{info.fingerprint}',
+		},
+
 	    },
 	    {
 		xtype: 'proxmoxtextfield',
@@ -124,7 +162,16 @@ Ext.define('PBS.window.RemoteEdit', {
 		fieldLabel: gettext('Comment'),
 	    },
 	],
-    },
+	},
+	{
+	    xtype: 'textarea',
+	    name: 'serializedinfo',
+	    fieldLabel: gettext('Remote Info Blob'),
+	    submitValue: false,
+	    emptyText: gettext('Paste encoded Remote Information here'),
+	    value: '',
+	},
+    ],
 
     setValues: function(values) {
 	let me = this;
-- 
2.20.1