[pve-devel] [PATCH 09/11] add template right-click menu
Alexandre Derumier
aderumier at odiso.com
Thu Feb 14 12:04:04 CET 2013
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
www/manager/Makefile | 1 +
www/manager/qemu/TemplateMenu.js | 81 ++++++++++++++++++++++++++++++++++++++
www/manager/tree/ResourceTree.js | 6 ++-
3 files changed, 87 insertions(+), 1 deletion(-)
create mode 100644 www/manager/qemu/TemplateMenu.js
diff --git a/www/manager/Makefile b/www/manager/Makefile
index 7da2234..b2763da 100644
--- a/www/manager/Makefile
+++ b/www/manager/Makefile
@@ -7,6 +7,7 @@ JSSRC= \
button/Button.js \
qemu/SendKeyMenu.js \
qemu/CmdMenu.js \
+ qemu/TemplateMenu.js \
openvz/CmdMenu.js \
VNCConsole.js \
data/TimezoneStore.js \
diff --git a/www/manager/qemu/TemplateMenu.js b/www/manager/qemu/TemplateMenu.js
new file mode 100644
index 0000000..70ce034
--- /dev/null
+++ b/www/manager/qemu/TemplateMenu.js
@@ -0,0 +1,81 @@
+Ext.define('PVE.qemu.TemplateMenu', {
+ extend: 'Ext.menu.Menu',
+
+ initComponent: function() {
+ var me = this;
+
+ var nodename = me.pveSelNode.data.node;
+ if (!nodename) {
+ throw "no node name specified";
+ }
+
+ var vmid = me.pveSelNode.data.vmid;
+ if (!vmid) {
+ throw "no VM ID specified";
+ }
+
+ var vmname = me.pveSelNode.data.name;
+
+ var template = me.pveSelNode.data.template;
+
+ var vm_command = function(cmd, params) {
+ PVE.Utils.API2Request({
+ params: params,
+ url: '/nodes/' + nodename + '/qemu/' + vmid + "/status/" + cmd,
+ method: 'POST',
+ failure: function(response, opts) {
+ Ext.Msg.alert('Error', response.htmlStatus);
+ }
+ });
+ };
+
+ me.title = "VM " + vmid;
+
+ me.items = [
+ {
+ text: gettext('Migrate'),
+ icon: '/pve2/images/forward.png',
+ handler: function() {
+ var win = Ext.create('PVE.window.Migrate', {
+ vmtype: 'qemu',
+ nodename: nodename,
+ vmid: vmid
+ });
+ win.show();
+ }
+ },
+ {
+ text: gettext('Clone To VM'),
+ icon: '/pve2/images/forward.png',
+ handler: function() {
+ var clonefeature;
+ //check if linked clone feature is available
+ var params = { feature: 'clone' };
+
+ PVE.Utils.API2Request({
+ waitMsgTarget: me,
+ url: '/nodes/' + nodename + '/qemu/' + vmid + '/feature',
+ params: params,
+ method: 'GET',
+ success: function(response, options) {
+ var res = response.result.data;
+ if (res === 1) {
+ clonefeature = 1;
+ }
+ var win = Ext.create('PVE.window.Clone', {
+ snapname: 'current',
+ nodename: nodename,
+ vmid: vmid,
+ istemplate: template,
+ clonefeature: clonefeature
+ });
+ win.show();
+ }
+ });
+ }
+ },
+ ];
+
+ me.callParent();
+ }
+});
diff --git a/www/manager/tree/ResourceTree.js b/www/manager/tree/ResourceTree.js
index 56ab0a6..9798790 100644
--- a/www/manager/tree/ResourceTree.js
+++ b/www/manager/tree/ResourceTree.js
@@ -325,10 +325,14 @@ Ext.define('PVE.tree.ResourceTree', {
//v.select(record);
var menu;
- if (record.data.type === 'qemu') {
+ if (record.data.type === 'qemu' && !record.data.template) {
menu = Ext.create('PVE.qemu.CmdMenu', {
pveSelNode: record
});
+ } else if (record.data.type === 'qemu' && record.data.template) {
+ menu = Ext.create('PVE.qemu.TemplateMenu', {
+ pveSelNode: record
+ });
} else if (record.data.type === 'openvz') {
menu = Ext.create('PVE.openvz.CmdMenu', {
pveSelNode: record
--
1.7.10.4
More information about the pve-devel
mailing list