]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/qemu/CmdMenu.js
1 Ext
.define('PVE.qemu.CmdMenu', {
2 extend
: 'Ext.menu.Menu',
5 initComponent: function() {
8 let info
= me
.pveSelNode
.data
;
10 throw "no node name specified";
13 throw "no VM ID specified";
16 let vm_command = function(cmd
, params
) {
17 Proxmox
.Utils
.API2Request({
19 url
: `/nodes/${info.node}/${info.type}/${info.vmid}/status/${cmd}`,
21 failure
: (response
, opts
) => Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
),
24 let confirmedVMCommand
= (cmd
, params
) => {
25 let msg
= Proxmox
.Utils
.format_task_description(`qm${cmd}`, info
.vmid
);
26 Ext
.Msg
.confirm(gettext('Confirm'), msg
, btn
=> {
28 vm_command(cmd
, params
);
33 let caps
= Ext
.state
.Manager
.get('GuiCap');
34 let standalone
= PVE
.data
.ResourceStore
.getNodes().length
< 2;
36 let running
= false, stopped
= true, suspended
= false;
37 switch (info
.status
) {
53 me
.title
= "VM " + info
.vmid
;
57 text
: gettext('Start'),
58 iconCls
: 'fa fa-fw fa-play',
59 hidden
: running
|| suspended
,
60 disabled
: running
|| suspended
,
61 handler
: () => vm_command('start'),
64 text
: gettext('Pause'),
65 iconCls
: 'fa fa-fw fa-pause',
66 hidden
: stopped
|| suspended
,
67 disabled
: stopped
|| suspended
,
68 handler
: () => confirmedVMCommand('suspend'),
71 text
: gettext('Hibernate'),
72 iconCls
: 'fa fa-fw fa-download',
73 hidden
: stopped
|| suspended
,
74 disabled
: stopped
|| suspended
,
75 tooltip
: gettext('Suspend to disk'),
76 handler
: () => confirmedVMCommand('suspend', { todisk
: 1 }),
79 text
: gettext('Resume'),
80 iconCls
: 'fa fa-fw fa-play',
82 handler
: () => vm_command('resume'),
85 text
: gettext('Shutdown'),
86 iconCls
: 'fa fa-fw fa-power-off',
87 disabled
: stopped
|| suspended
,
88 handler
: () => confirmedVMCommand('shutdown'),
91 text
: gettext('Stop'),
92 iconCls
: 'fa fa-fw fa-stop',
94 tooltip
: Ext
.String
.format(gettext('Stop {0} immediately'), 'VM'),
95 handler
: () => confirmedVMCommand('stop'),
98 text
: gettext('Reboot'),
99 iconCls
: 'fa fa-fw fa-refresh',
101 tooltip
: Ext
.String
.format(gettext('Reboot {0}'), 'VM'),
102 handler
: () => confirmedVMCommand('reboot'),
105 xtype
: 'menuseparator',
106 hidden
: (standalone
|| !caps
.vms
['VM.Migrate']) && !caps
.vms
['VM.Allocate'] && !caps
.vms
['VM.Clone'],
109 text
: gettext('Migrate'),
110 iconCls
: 'fa fa-fw fa-send-o',
111 hidden
: standalone
|| !caps
.vms
['VM.Migrate'],
112 handler: function() {
113 Ext
.create('PVE.window.Migrate', {
122 text
: gettext('Clone'),
123 iconCls
: 'fa fa-fw fa-clone',
124 hidden
: !caps
.vms
['VM.Clone'],
125 handler
: () => PVE
.window
.Clone
.wrap(info
.node
, info
.vmid
, me
.isTemplate
, 'qemu'),
128 text
: gettext('Convert to template'),
129 iconCls
: 'fa fa-fw fa-file-o',
130 hidden
: !caps
.vms
['VM.Allocate'],
131 handler: function() {
132 let msg
= Proxmox
.Utils
.format_task_description('qmtemplate', info
.vmid
);
133 Ext
.Msg
.confirm(gettext('Confirm'), msg
, btn
=> {
135 Proxmox
.Utils
.API2Request({
136 url
: `/nodes/${info.node}/qemu/${info.vmid}/template`,
138 failure
: (response
, opts
) => Ext
.Msg
.alert('Error', response
.htmlStatus
),
144 { xtype
: 'menuseparator' },
146 text
: gettext('Console'),
147 iconCls
: 'fa fa-fw fa-terminal',
148 handler: function() {
149 Proxmox
.Utils
.API2Request({
150 url
: `/nodes/${info.node}/qemu/${info.vmid}/status/current`,
151 failure
: (response
, opts
) => Ext
.Msg
.alert('Error', response
.htmlStatus
),
152 success: function({ result
: { data
} }, opts
) {
153 PVE
.Utils
.openDefaultConsoleWindow(
156 xtermjs
: data
.serial
,