]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/lxc/CmdMenu.js
make container clones/template available in the gui
[pve-manager.git] / www / manager6 / lxc / CmdMenu.js
index 5506c26d8569b9ca86519980a1b2ca952a7f08eb..13edcb2e988a35715ceb2c361dcf4376e7ccff62 100644 (file)
@@ -1,6 +1,7 @@
 Ext.define('PVE.lxc.CmdMenu', {
     extend: 'Ext.menu.Menu',
 
+    showSeparator: false,
     initComponent: function() {
        var me = this;
 
@@ -16,7 +17,7 @@ Ext.define('PVE.lxc.CmdMenu', {
        var vmname = me.pveSelNode.data.name;
 
        var vm_command = function(cmd, params) {
-           PVE.Utils.API2Request({
+           Proxmox.Utils.API2Request({
                params: params,
                url: '/nodes/' + nodename + '/lxc/' + vmid + "/status/" + cmd,
                method: 'POST',
@@ -26,9 +27,12 @@ Ext.define('PVE.lxc.CmdMenu', {
            });
        };
 
+       var caps = Ext.state.Manager.get('GuiCap');
+
        var running = false;
        var stopped = true;
        var suspended = false;
+       var standalone = PVE.data.ResourceStore.getNodes().length < 2;
 
        switch (me.pveSelNode.data.status) {
            case 'running':
@@ -53,24 +57,13 @@ Ext.define('PVE.lxc.CmdMenu', {
                    vm_command('start');
                }
            },
-           {
-               text: gettext('Migrate'),
-               iconCls: 'fa fa-fw fa-send-o',
-               handler: function() {
-                   var win = Ext.create('PVE.window.Migrate', {
-                       vmtype: 'lxc',
-                       nodename: nodename,
-                       vmid: vmid
-                   });
-                   win.show();
-               }
-           },
 //         {
 //             text: gettext('Suspend'),
 //             iconCls: 'fa fa-fw fa-pause',
+//             hidde: suspended,
 //             disabled: stopped || suspended,
 //             handler: function() {
-//                 var msg = PVE.Utils.format_task_description('vzsuspend', vmid);
+//                 var msg = Proxmox.Utils.format_task_description('vzsuspend', vmid);
 //                 Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
 //                     if (btn !== 'yes') {
 //                         return;
@@ -83,7 +76,7 @@ Ext.define('PVE.lxc.CmdMenu', {
 //         {
 //             text: gettext('Resume'),
 //             iconCls: 'fa fa-fw fa-play',
-//             disabled: !suspended,
+//             hidden: !suspended,
 //             handler: function() {
 //                 vm_command('resume');
 //             }
@@ -93,7 +86,7 @@ Ext.define('PVE.lxc.CmdMenu', {
                iconCls: 'fa fa-fw fa-power-off',
                disabled: stopped || suspended,
                handler: function() {
-                   var msg = PVE.Utils.format_task_description('vzshutdown', vmid);
+                   var msg = Proxmox.Utils.format_task_description('vzshutdown', vmid);
                    Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
                        if (btn !== 'yes') {
                            return;
@@ -108,7 +101,7 @@ Ext.define('PVE.lxc.CmdMenu', {
                iconCls: 'fa fa-fw fa-stop',
                disabled: stopped,
                handler: function() {
-                   var msg = PVE.Utils.format_task_description('vzstop', vmid);
+                   var msg = Proxmox.Utils.format_task_description('vzstop', vmid);
                    Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
                        if (btn !== 'yes') {
                            return;
@@ -118,26 +111,52 @@ Ext.define('PVE.lxc.CmdMenu', {
                    });
                }
            },
-//         {
-//             text: gettext('Convert to template'),
-//             icon: '/pve2/images/forward.png',
-//             handler: function() {
-//                 var msg = PVE.Utils.format_task_description('vztemplate', vmid);
-//                 Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
-//                     if (btn !== 'yes') {
-//                         return;
-//                     }
-//
-//                     PVE.Utils.API2Request({
-//                          url: '/nodes/' + nodename + '/lxc/' + vmid + '/template',
-//                          method: 'POST',
-//                          failure: function(response, opts) {
-//                             Ext.Msg.alert('Error', response.htmlStatus);
-//                          }
-//                     });
-//                 });
-//             }
-//         },
+           {
+               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',
+               hidden: standalone || !caps.vms['VM.Migrate'],
+               handler: function() {
+                   var win = Ext.create('PVE.window.Migrate', {
+                       vmtype: 'lxc',
+                       nodename: nodename,
+                       vmid: vmid
+                   });
+                   win.show();
+               }
+           },
+           {
+               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'),
                iconCls: 'fa fa-fw fa-terminal',