[pve-devel] [PATCH manager 4/5] add right-click menu for nodes

Dominik Csapak d.csapak at proxmox.com
Fri Apr 14 10:09:23 CEST 2017


to easier reach the bulk actions, create wizards, and shell

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/Makefile        |   1 +
 www/manager6/Utils.js        |   6 +++
 www/manager6/node/CmdMenu.js | 117 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 124 insertions(+)
 create mode 100644 www/manager6/node/CmdMenu.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 66d7259e..0c266ef7 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -13,6 +13,7 @@ JSSRC= 				                 	\
 	qemu/CmdMenu.js					\
 	qemu/TemplateMenu.js				\
 	lxc/CmdMenu.js					\
+	node/CmdMenu.js					\
 	VNCConsole.js					\
 	data/TimezoneStore.js				\
 	data/reader/JsonObject.js			\
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index dc2c9c83..d1ada771 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1336,6 +1336,12 @@ Ext.define('PVE.Utils', { utilities: {
 	    });
 	    */
 	    return;
+
+	} else if (record.data.type === 'node' ){
+	    menu = Ext.create('PVE.node.CmdMenu', {
+		nodename: record.data.node
+	    });
+
 	} else {
 	    return;
 	}
diff --git a/www/manager6/node/CmdMenu.js b/www/manager6/node/CmdMenu.js
new file mode 100644
index 00000000..05a92f62
--- /dev/null
+++ b/www/manager6/node/CmdMenu.js
@@ -0,0 +1,117 @@
+Ext.define('PVE.node.CmdMenu', {
+    extend: 'Ext.menu.Menu',
+    xtype: 'nodeCmdMenu',
+
+    showSeparator: false,
+
+    items: [
+	{
+	    text: gettext('Create VM'),
+	    itemId: 'createvm',
+	    iconCls: 'fa fa-desktop',
+	    handler: function() {
+		var me = this.up('menu');
+		var wiz = Ext.create('PVE.qemu.CreateWizard', {
+		    nodename: me.nodename
+		});
+		wiz.show();
+	    }
+	},
+	{
+	    text: gettext('Create CT'),
+	    itemId: 'createct',
+	    iconCls: 'fa fa-cube',
+	    handler: function() {
+		var me = this.up('menu');
+		var wiz = Ext.create('PVE.lxc.CreateWizard', {
+		    nodename: me.nodename
+		});
+		wiz.show();
+	    }
+	},
+	{ xtype: 'menuseparator' },
+	{
+	    text: gettext('Bulk Start'),
+	    itemId: 'bulkstart',
+	    iconCls: 'fa fa-fw fa-play',
+	    handler: function() {
+		var me = this.up('menu');
+		var win = Ext.create('PVE.window.BulkAction', {
+		    nodename: me.nodename,
+		    title: gettext('Bulk Start'),
+		    btnText: gettext('Start'),
+		    action: 'startall'
+		});
+		win.show();
+	    }
+	},
+	{
+	    text: gettext('Bulk Stop'),
+	    itemId: 'bulkstop',
+	    iconCls: 'fa fa-fw fa-stop',
+	    handler: function() {
+		var me = this.up('menu');
+		var win = Ext.create('PVE.window.BulkAction', {
+		    nodename: me.nodename,
+		    title: gettext('Bulk Stop'),
+		    btnText: gettext('Stop'),
+		    action: 'stopall'
+		});
+		win.show();
+	    }
+	},
+	{
+	    text: gettext('Bulk Migrate'),
+	    itemId: 'bulkmigrate',
+	    iconCls: 'fa fa-fw fa-send-o',
+	    handler: function() {
+		var me = this.up('menu');
+		var win = Ext.create('PVE.window.BulkAction', {
+		    nodename: me.nodename,
+		    title: gettext('Bulk Migrate'),
+		    btnText: gettext('Migrate'),
+		    action: 'migrateall'
+		});
+		win.show();
+	    }
+	},
+	{ xtype: 'menuseparator' },
+	{
+	    text: gettext('Shell'),
+	    itemId: 'shell',
+	    iconCls: 'fa fa-fw fa-terminal',
+	    handler: function() {
+		var me = this.up('menu');
+		PVE.Utils.openDefaultConsoleWindow(true, 'shell', undefined, me.nodename, undefined);
+	    }
+	}
+    ],
+
+    initComponent: function() {
+	var me = this;
+
+	if (!me.nodename) {
+	    throw 'no nodename specified';
+	}
+
+	me.title = gettext('Node') + " '" + me.nodename + "'";
+	me.callParent();
+
+	var caps = Ext.state.Manager.get('GuiCap');
+	// disable not allowed options
+	if (!caps.vms['VM.Allocate']) {
+	    me.getComponent('createct').setDisabled(true);
+	    me.getComponent('createvm').setDisabled(true);
+	}
+
+	if (!caps.nodes['Sys.PowerMgmt']) {
+	    me.getComponent('bulkstart').setDisabled(true);
+	    me.getComponent('bulkstop').setDisabled(true);
+	    me.getComponent('bulkmigrate').setDisabled(true);
+	}
+
+	if (!caps.nodes['Sys.Console']) {
+	    me.getComponent('shell').setDisabled(true);
+	}
+    }
+});
-- 
2.11.0





More information about the pve-devel mailing list