]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/qemu/Config.js
use Proxmox.Utils instead of PVE.Utils
[pve-manager.git] / www / manager6 / qemu / Config.js
index 879ea322da271ffc0a94effb06ea9a9ec4e3e92f..4114b7c0e692f60cfd60616a8d64f9e749a4ad1e 100644 (file)
@@ -17,7 +17,9 @@ Ext.define('PVE.qemu.Config', {
            throw "no VM ID specified";
        }
 
-       var template = me.pveSelNode.data.template;
+       var template = !!me.pveSelNode.data.template;
+
+       var running = !!me.pveSelNode.data.uptime;
 
        var caps = Ext.state.Manager.get('GuiCap');
 
@@ -29,7 +31,7 @@ Ext.define('PVE.qemu.Config', {
        });
 
        var vm_command = function(cmd, params) {
-           PVE.Utils.API2Request({
+           Proxmox.Utils.API2Request({
                params: params,
                url: base_url + '/status/' + cmd,
                waitMsgTarget: me,
@@ -52,7 +54,8 @@ Ext.define('PVE.qemu.Config', {
 
        var startBtn = Ext.create('Ext.Button', {
            text: gettext('Start'),
-           disabled: !caps.vms['VM.PowerMgmt'],
+           disabled: !caps.vms['VM.PowerMgmt'] || running,
+           hidden: template,
            handler: function() {
                vm_command('start');
            },
@@ -62,6 +65,7 @@ Ext.define('PVE.qemu.Config', {
        var migrateBtn = Ext.create('Ext.Button', {
            text: gettext('Migrate'),
            disabled: !caps.vms['VM.Migrate'],
+           hidden: PVE.data.ResourceStore.getNodes().length < 2,
            handler: function() {
                var win = Ext.create('PVE.window.Migrate', {
                    vmtype: 'qemu',
@@ -73,22 +77,26 @@ Ext.define('PVE.qemu.Config', {
            iconCls: 'fa fa-send-o'
        });
 
-       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: [{
+       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);
+                   }
+               },
+               {
                    text: gettext('Convert to template'),
                    disabled: template,
+                   xtype: 'pveMenuItem',
                    iconCls: 'fa fa-fw fa-file-o',
                    hidden: caps.vms['VM.Allocate'] ? false : true,
-                   confirmMsg: PVE.Utils.format_task_description('qmtemplate', vmid),
+                   confirmMsg: Proxmox.Utils.format_task_description('qmtemplate', vmid),
                    handler: function() {
-                       PVE.Utils.API2Request({
+                       Proxmox.Utils.API2Request({
                            url: base_url + '/template',
                            waitMsgTarget: me,
                            method: 'POST',
@@ -97,14 +105,39 @@ Ext.define('PVE.qemu.Config', {
                            }
                        });
                    }
-               }]
-           }
+               },
+               {
+                   iconCls: 'fa fa-heartbeat ',
+                   hidden: !caps.nodes['Sys.Console'],
+                   text: gettext('Manage HA'),
+                   handler: function() {
+                       var ha = me.pveSelNode.data.hastate;
+                       Ext.create('PVE.ha.VMResourceEdit', {
+                           vmid: vmid,
+                           isCreate: (!ha || ha === 'unmanaged')
+                       }).show();
+                   }
+               },
+               {
+                   text: gettext('Remove'),
+                   itemId: 'removeBtn',
+                   disabled: !caps.vms['VM.Allocate'],
+                   handler: function() {
+                       Ext.create('PVE.window.SafeDestroy', {
+                           url: base_url,
+                           item: { type: 'VM', id: vmid }
+                       }).show();
+                   },
+                   iconCls: 'fa fa-trash-o'
+               }
+           ]}
        });
 
        var shutdownBtn = Ext.create('PVE.button.Split', {
            text: gettext('Shutdown'),
-           disabled: !caps.vms['VM.PowerMgmt'],
-           confirmMsg: PVE.Utils.format_task_description('qmshutdown', vmid),
+           disabled: !caps.vms['VM.PowerMgmt'] || !running,
+           hidden: template,
+           confirmMsg: Proxmox.Utils.format_task_description('qmshutdown', vmid),
            handler: function() {
                vm_command('shutdown');
            },
@@ -113,7 +146,7 @@ Ext.define('PVE.qemu.Config', {
                    text: gettext('Stop'),
                    disabled: !caps.vms['VM.PowerMgmt'],
                    dangerous: true,
-                   confirmMsg: PVE.Utils.format_task_description('qmstop', vmid),
+                   confirmMsg: Proxmox.Utils.format_task_description('qmstop', vmid),
                    handler: function() {
                        vm_command("stop", { timeout: 30 });
                    },
@@ -121,7 +154,7 @@ Ext.define('PVE.qemu.Config', {
                },{
                    text: gettext('Reset'),
                    disabled: !caps.vms['VM.PowerMgmt'],
-                   confirmMsg: PVE.Utils.format_task_description('qmreset', vmid),
+                   confirmMsg: Proxmox.Utils.format_task_description('qmreset', vmid),
                    handler: function() {
                        vm_command("reset");
                    },
@@ -131,36 +164,21 @@ Ext.define('PVE.qemu.Config', {
            iconCls: 'fa fa-power-off'
        });
 
-       var removeBtn = Ext.create('PVE.button.Button', {
-           text: gettext('Remove'),
-           disabled: !caps.vms['VM.Allocate'],
-           handler: function() {
-               Ext.create('PVE.window.SafeDestroy', {
-                   url: base_url,
-                   item: { type: 'VM', id: vmid }
-               }).show();
-           },
-           iconCls: 'fa fa-trash-o'
-       });
-
-       var vmname = me.pveSelNode.data.name;
+       var vm = me.pveSelNode.data;
 
        var consoleBtn = Ext.create('PVE.button.ConsoleButton', {
            disabled: !caps.vms['VM.Console'],
+           hidden: template,
            consoleType: 'kvm',
-           consoleName: vmname,
+           consoleName: vm.name,
            nodename: nodename,
-           vmid: vmid,
-           iconCls: 'fa fa-terminal'
+           vmid: vmid
        });
 
-       var descr = vmid + " (" + (vmname ? "'" + vmname + "' " : "'VM " + vmid + "'") + ")";
-
        Ext.apply(me, {
-           title: Ext.String.format(gettext("Virtual Machine {0} on node {1}"), descr, "'" + nodename + "'"),
+           title: Ext.String.format(gettext("Virtual Machine {0} on node '{1}'"), vm.text, nodename),
            hstateid: 'kvmtab',
-           tbar: [ resumeBtn, startBtn, shutdownBtn,
-                   removeBtn, migrateBtn, cloneBtn, consoleBtn],
+           tbar: [ resumeBtn, startBtn, shutdownBtn, migrateBtn, consoleBtn, moreBtn ],
            defaults: { statusStore: me.statusStore },
            items: [
                {
@@ -200,8 +218,9 @@ Ext.define('PVE.qemu.Config', {
            {
                title: gettext('Task History'),
                itemId: 'tasks',
-               xtype: 'pveNodeTasks',
+               xtype: 'proxmoxNodeTasks',
                iconCls: 'fa fa-list',
+               nodename: nodename,
                vmidFilter: vmid
            }
        );
@@ -230,7 +249,7 @@ Ext.define('PVE.qemu.Config', {
            });
        }
 
-       if (caps.vms['VM.Snapshot'] && !template) {
+       if ((caps.vms['VM.Snapshot'] || caps.vms['VM.Snapshot.Rollback']) && !template) {
            me.items.push({
                title: gettext('Snapshots'),
                iconCls: 'fa fa-history',
@@ -307,7 +326,6 @@ Ext.define('PVE.qemu.Config', {
            var spice = false;
 
            if (!success) {
-               me.workspace.checkVmMigration(me.pveSelNode);
                status = qmpstatus = 'unknown';
            } else {
                var rec = s.data.get('status');
@@ -321,6 +339,10 @@ Ext.define('PVE.qemu.Config', {
 
            }
 
+           if (template) {
+               return;
+           }
+
            if (qmpstatus === 'prelaunch' || qmpstatus === 'paused' || qmpstatus === 'suspended') {
                startBtn.setVisible(false);
                resumeBtn.setVisible(true);
@@ -333,7 +355,7 @@ Ext.define('PVE.qemu.Config', {
 
            startBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'running' || template);
            shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running');
-           removeBtn.setDisabled(!caps.vms['VM.Allocate'] || status !== 'stopped');
+           me.down('#removeBtn').setDisabled(!caps.vms['VM.Allocate'] || status !== 'stopped');
            consoleBtn.setDisabled(template);
        });