[pve-devel] [PATCH manager 2/5] add a 'convert to template' in the vm action bar

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


this was only available on right clicking a vm, now it is also available
in the action bar

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/qemu/Config.js | 33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/www/manager6/qemu/Config.js b/www/manager6/qemu/Config.js
index 175e6a2d..43b4fcfc 100644
--- a/www/manager6/qemu/Config.js
+++ b/www/manager6/qemu/Config.js
@@ -73,13 +73,32 @@ Ext.define('PVE.qemu.Config', {
 	    iconCls: 'fa fa-send-o'
 	});
 
-	var cloneBtn = Ext.create('Ext.Button', {
-		text: gettext('Clone'),
-		iconCls: 'fa fa-fw fa-clone',
-		hidden: caps.vms['VM.Clone'] ? false : true,
-		handler: function() {
-		    PVE.window.Clone.wrap(nodename, vmid, template);
-		}
+	var cloneBtn = Ext.create('PVE.button.Split', {
+	    text: gettext('Clone'),
+	    iconCls: 'fa fa-fw fa-clone',
+	    hidden: caps.vms['VM.Clone'] ? false : true,
+	    handler: function() {
+		PVE.window.Clone.wrap(nodename, vmid, template);
+	    },
+	    menu: {
+		items: [{
+		    text: gettext('Convert to template'),
+		    disabled: template,
+		    iconCls: 'fa fa-fw fa-file-o',
+		    hidden: caps.vms['VM.Allocate'] ? false : true,
+		    confirmMsg: PVE.Utils.format_task_description('qmtemplate', vmid),
+		    handler: function() {
+			PVE.Utils.API2Request({
+			    url: base_url + '/template',
+			    waitMsgTarget: me,
+			    method: 'POST',
+			    failure: function(response, opts) {
+				Ext.Msg.alert('Error', response.htmlStatus);
+			    }
+			});
+		    }
+		}]
+	    }
 	});
 
 	var shutdownBtn = Ext.create('PVE.button.Split', {
-- 
2.11.0





More information about the pve-devel mailing list