[pve-devel] [PATCH manager v3 5/5] add xtermjs to consolebutton

Dominik Csapak d.csapak at proxmox.com
Mon Dec 11 14:55:30 CET 2017


also rework the button.
move most things in the static configuration

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/button/ConsoleButton.js | 74 +++++++++++++++++++++---------------
 www/manager6/lxc/Config.js           | 30 ++++++++++-----
 www/manager6/node/Config.js          |  9 +++++
 3 files changed, 73 insertions(+), 40 deletions(-)

diff --git a/www/manager6/button/ConsoleButton.js b/www/manager6/button/ConsoleButton.js
index 98ebea0e..a3bf7464 100644
--- a/www/manager6/button/ConsoleButton.js
+++ b/www/manager6/button/ConsoleButton.js
@@ -12,50 +12,62 @@ Ext.define('PVE.button.ConsoleButton', {
 
     vmid: 0,
 
+    text: gettext('Console'),
+
     setEnableSpice: function(enable){
 	var me = this;
 
 	me.enableSpice = enable;
-	me.spiceMenu.setDisabled(!enable);
+	me.down('#spicemenu').setDisabled(!enable);
     },
 
-    initComponent: function() {
-        var me = this;
-
-	if (!me.nodename) {
-	    throw "no node name specified";
-	}
+    handler: function() {
+	var me = this;
+	PVE.Utils.openDefaultConsoleWindow(me.enableSpice, me.consoleType, me.vmid,
+					   me.nodename, me.consoleName);
+    },
 
-	me.spiceMenu = Ext.create('Ext.menu.Item', {
+    menu: [
+	{
+	    xtype:'menuitem',
+	    text: 'noVNC',
+	    iconCls: 'pve-itype-icon-novnc',
+	    type: 'html5',
+	    handler: function(button) {
+		var me = this.up('button');
+		PVE.Utils.openConsoleWindow(button.type, me.consoleType, me.vmid, me.nodename, me.consoleName);
+	    },
+	},
+	{
+	    xterm: 'menuitem',
+	    itemId: 'spicemenu',
 	    text: 'SPICE',
+	    type: 'vv',
 	    iconCls: 'pve-itype-icon-virt-viewer',
-	    handler: function() {
-		PVE.Utils.openConsoleWindow('vv', me.consoleType, me.vmid, me.nodename, me.consoleName);
-	    }
-	});
+	    handler: function(button) {
+		var me = this.up('button');
+		PVE.Utils.openConsoleWindow(button.type, me.consoleType, me.vmid, me.nodename, me.consoleName);
+	    },
+	},
+	{
+	    text: 'xterm.js',
+	    itemId: 'xtermjs',
+	    iconCls: 'fa fa-terminal',
+	    type: 'xtermjs',
+	    handler: function(button) {
+		var me = this.up('button');
+		PVE.Utils.openConsoleWindow(button.type, me.consoleType, me.vmid, me.nodename, me.consoleName);
+	    },
+	}
+    ],
 
-	var noVncMenu = Ext.create('Ext.menu.Item', {
-	    text: 'noVNC',
-	    iconCls: 'pve-itype-icon-novnc',
-	    handler: function() {
-		PVE.Utils.openConsoleWindow('html5', me.consoleType, me.vmid, me.nodename, me.consoleName);
-	    }
-	});
+    initComponent: function() {
+        var me = this;
 
-	if (me.text === null) {
-	    me.text = gettext('Console');
+	if (!me.nodename) {
+	    throw "no node name specified";
 	}
 
-	Ext.apply(me, {
-	    handler: function() {
-		PVE.Utils.openDefaultConsoleWindow(me.enableSpice, me.consoleType, me.vmid,
-						   me.nodename, me.consoleName);
-	    },
-	    menu: new Ext.menu.Menu({
-		items: [ noVncMenu, me.spiceMenu ]
-	    })
-	});
-
 	me.callParent();
     }
 });
diff --git a/www/manager6/lxc/Config.js b/www/manager6/lxc/Config.js
index 0ffc4841..bcff47ba 100644
--- a/www/manager6/lxc/Config.js
+++ b/www/manager6/lxc/Config.js
@@ -148,15 +148,27 @@ Ext.define('PVE.lxc.Config', {
 	});
 
 	if (caps.vms['VM.Console']) {
-	    me.items.push({
-		title: gettext('Console'),
-		itemId: 'console',
-		iconCls: 'fa fa-terminal',
-		xtype: 'pveNoVncConsole',
-		vmid: vmid,
-		consoleType: 'lxc',
-		nodename: nodename
-	    });
+	    me.items.push(
+		{
+		    title: gettext('Console'),
+		    itemId: 'console',
+		    iconCls: 'fa fa-terminal',
+		    xtype: 'pveNoVncConsole',
+		    vmid: vmid,
+		    consoleType: 'lxc',
+		    nodename: nodename
+		},
+		{
+		    title: gettext('Console (JS)'),
+		    itemId: 'consolejs',
+		    iconCls: 'fa fa-terminal',
+		    xtype: 'pveNoVncConsole',
+		    vmid: vmid,
+		    consoleType: 'lxc',
+		    xtermjs: true,
+		    nodename: nodename
+		}
+	    );
 	}
 
 	me.items.push(
diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js
index 49f1186f..4d6b51ef 100644
--- a/www/manager6/node/Config.js
+++ b/www/manager6/node/Config.js
@@ -139,6 +139,15 @@ Ext.define('PVE.node.Config', {
 		    xtype: 'pveNoVncConsole',
 		    consoleType: 'shell',
 		    nodename: nodename
+		},
+		{
+		    title: gettext('Shell (JS)'),
+		    iconCls: 'fa fa-terminal',
+		    itemId: 'jsconsole',
+		    xtype: 'pveNoVncConsole',
+		    consoleType: 'shell',
+		    xtermjs: true,
+		    nodename: nodename
 		}
 	    );
 	}
-- 
2.11.0





More information about the pve-devel mailing list