[pbs-devel] [PATCH v4 backup 2/2] ui: add textarea in remote and menu for pasting json blob

Oguz Bektas o.bektas at proxmox.com
Wed Mar 31 12:35:40 CEST 2021


automatically fill hostname and fingerprint when pasted

Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
 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





More information about the pbs-devel mailing list