Commit 4fe1b0c0 authored by Alexandre Derumier's avatar Alexandre Derumier Committed by Dietmar Maurer

add template right-click menu

Signed-off-by: 's avatarAlexandre Derumier <aderumier@odiso.com>
parent 1a6c1876
...@@ -7,6 +7,7 @@ JSSRC= \ ...@@ -7,6 +7,7 @@ JSSRC= \
button/Button.js \ button/Button.js \
qemu/SendKeyMenu.js \ qemu/SendKeyMenu.js \
qemu/CmdMenu.js \ qemu/CmdMenu.js \
qemu/TemplateMenu.js \
openvz/CmdMenu.js \ openvz/CmdMenu.js \
VNCConsole.js \ VNCConsole.js \
data/TimezoneStore.js \ data/TimezoneStore.js \
......
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();
}
});
...@@ -326,10 +326,14 @@ Ext.define('PVE.tree.ResourceTree', { ...@@ -326,10 +326,14 @@ Ext.define('PVE.tree.ResourceTree', {
//v.select(record); //v.select(record);
var menu; var menu;
if (record.data.type === 'qemu') { if (record.data.type === 'qemu' && !record.data.template) {
menu = Ext.create('PVE.qemu.CmdMenu', { menu = Ext.create('PVE.qemu.CmdMenu', {
pveSelNode: record 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') { } else if (record.data.type === 'openvz') {
menu = Ext.create('PVE.openvz.CmdMenu', { menu = Ext.create('PVE.openvz.CmdMenu', {
pveSelNode: record pveSelNode: record
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment