]> git.proxmox.com Git - pve-manager-legacy.git/commitdiff
make container clones/template available in the gui
authorDominik Csapak <d.csapak@proxmox.com>
Wed, 21 Mar 2018 14:12:17 +0000 (15:12 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 21 Mar 2018 14:54:32 +0000 (15:54 +0100)
also refactor the right click menu logic

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
www/manager6/Utils.js
www/manager6/lxc/CmdMenu.js
www/manager6/lxc/Config.js

index 7b495890c4d8f938ae085d605c16ae597dda1aa1..6345b2b487cd780eb8dab957885b04ddf8f6ec1a 100644 (file)
@@ -831,32 +831,22 @@ Ext.define('PVE.Utils', { utilities: {
            v.select(record);
        }
        var menu;
+       var template = !!record.data.template;
+       var type = record.data.type;
 
-       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.menu.TemplateMenu', {
-               pveSelNode: record
-           });
-       } else if (record.data.type === 'lxc' && !record.data.template) {
-           menu = Ext.create('PVE.lxc.CmdMenu', {
-               pveSelNode: record
-           });
-       } else if (record.data.type === 'lxc' && record.data.template) {
-           /* since clone does not work reliably, disable for now
-           menu = Ext.create('PVE.lxc.TemplateMenu', {
-               pveSelNode: record
-           });
-           */
-           return;
-
-       } else if (record.data.type === 'node' ){
-           menu = Ext.create('PVE.node.CmdMenu', {
+       if (template) {
+           if (type === 'qemu' || type == 'lxc') {
+               menu = Ext.create('PVE.menu.TemplateMenu', {
+                   pveSelNode: record
+               });
+           }
+       } else if (type === 'qemu' ||
+                  type === 'lxc' ||
+                  type === 'node') {
+           menu = Ext.create('PVE.' + type + '.CmdMenu', {
+               pveSelNode: record,
                nodename: record.data.node
            });
-
        } else {
            return;
        }
index 6ad3ca2964f8ffc4063f142590fcf5d88a824141..13edcb2e988a35715ceb2c361dcf4376e7ccff62 100644 (file)
@@ -115,6 +115,14 @@ Ext.define('PVE.lxc.CmdMenu', {
                xtype: 'menuseparator',
                hidden: standalone || !caps.vms['VM.Migrate']
            },
+           {
+               text: gettext('Clone'),
+               iconCls: 'fa fa-fw fa-clone',
+               hidden: !caps.vms['VM.Clone'],
+               handler: function() {
+                   PVE.window.Clone.wrap(nodename, vmid, me.isTemplate, 'lxc');
+               }
+           },
            {
                text: gettext('Migrate'),
                iconCls: 'fa fa-fw fa-send-o',
@@ -128,26 +136,26 @@ Ext.define('PVE.lxc.CmdMenu', {
                    win.show();
                }
            },
-//         {
-//             text: gettext('Convert to template'),
-//             icon: '/pve2/images/forward.png',
-//             handler: function() {
-//                 var msg = Proxmox.Utils.format_task_description('vztemplate', vmid);
-//                 Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
-//                     if (btn !== 'yes') {
-//                         return;
-//                     }
-//
-//                     Proxmox.Utils.API2Request({
-//                          url: '/nodes/' + nodename + '/lxc/' + vmid + '/template',
-//                          method: 'POST',
-//                          failure: function(response, opts) {
-//                             Ext.Msg.alert('Error', response.htmlStatus);
-//                          }
-//                     });
-//                 });
-//             }
-//         },
+           {
+               text: gettext('Convert to template'),
+               iconCls: 'fa fa-fw fa-file-o',
+               handler: function() {
+                   var msg = Proxmox.Utils.format_task_description('vztemplate', vmid);
+                   Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
+                       if (btn !== 'yes') {
+                           return;
+                       }
+
+                       Proxmox.Utils.API2Request({
+                           url: '/nodes/' + nodename + '/lxc/' + vmid + '/template',
+                           method: 'POST',
+                           failure: function(response, opts) {
+                               Ext.Msg.alert('Error', response.htmlStatus);
+                           }
+                       });
+                   });
+               }
+           },
            { xtype: 'menuseparator' },
            {
                text: gettext('Console'),
index 52569901087efadfb85cf971fb6138b65f71c92c..c9c49177eb6c98e055e5097d81a2fca2403028f3 100644 (file)
@@ -93,6 +93,32 @@ Ext.define('PVE.lxc.Config', {
        var moreBtn = Ext.create('Proxmox.button.Button', {
            text: gettext('More'),
            menu: { items: [
+               {
+                   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, 'lxc');
+                   }
+               },
+               {
+                   text: gettext('Convert to template'),
+                   disabled: template,
+                   xtype: 'pveMenuItem',
+                   iconCls: 'fa fa-fw fa-file-o',
+                   hidden: caps.vms['VM.Allocate'] ? false : true,
+                   confirmMsg: Proxmox.Utils.format_task_description('vztemplate', vmid),
+                   handler: function() {
+                       Proxmox.Utils.API2Request({
+                           url: base_url + '/template',
+                           waitMsgTarget: me,
+                           method: 'POST',
+                           failure: function(response, opts) {
+                               Ext.Msg.alert('Error', response.htmlStatus);
+                           }
+                       });
+                   }
+               },
                {
                    iconCls: 'fa fa-heartbeat ',
                    hidden: !caps.nodes['Sys.Console'],