]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/lxc/CmdMenu.js
1 Ext
.define('PVE.lxc.CmdMenu', {
2 extend
: 'Ext.menu.Menu',
5 initComponent: function() {
8 let info
= me
.pveSelNode
.data
;
10 throw "no node name specified";
13 throw "no CT 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(`vz${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
) {
49 me
.title
= 'CT ' + info
.vmid
;
53 text
: gettext('Start'),
54 iconCls
: 'fa fa-fw fa-play',
56 handler
: () => vm_command('start'),
59 text
: gettext('Shutdown'),
60 iconCls
: 'fa fa-fw fa-power-off',
61 disabled
: stopped
|| suspended
,
62 handler
: () => confirmedVMCommand('shutdown'),
65 text
: gettext('Stop'),
66 iconCls
: 'fa fa-fw fa-stop',
68 tooltip
: Ext
.String
.format(gettext('Stop {0} immediately'), 'CT'),
69 handler
: () => confirmedVMCommand('stop'),
72 text
: gettext('Reboot'),
73 iconCls
: 'fa fa-fw fa-refresh',
75 tooltip
: Ext
.String
.format(gettext('Reboot {0}'), 'CT'),
76 handler
: () => confirmedVMCommand('reboot'),
79 xtype
: 'menuseparator',
80 hidden
: (standalone
|| !caps
.vms
['VM.Migrate']) && !caps
.vms
['VM.Allocate'] && !caps
.vms
['VM.Clone'],
83 text
: gettext('Clone'),
84 iconCls
: 'fa fa-fw fa-clone',
85 hidden
: !caps
.vms
['VM.Clone'],
86 handler
: () => PVE
.window
.Clone
.wrap(info
.node
, info
.vmid
, me
.isTemplate
, 'lxc'),
89 text
: gettext('Migrate'),
90 iconCls
: 'fa fa-fw fa-send-o',
91 hidden
: standalone
|| !caps
.vms
['VM.Migrate'],
93 Ext
.create('PVE.window.Migrate', {
102 text
: gettext('Convert to template'),
103 iconCls
: 'fa fa-fw fa-file-o',
104 handler: function() {
105 let msg
= Proxmox
.Utils
.format_task_description('vztemplate', info
.vmid
);
106 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
108 Proxmox
.Utils
.API2Request({
109 url
: `/nodes/${info.node}/lxc/${info.vmid}/template`,
111 failure
: (response
, opts
) => Ext
.Msg
.alert('Error', response
.htmlStatus
),
117 { xtype
: 'menuseparator' },
119 text
: gettext('Console'),
120 iconCls
: 'fa fa-fw fa-terminal',
122 PVE
.Utils
.openDefaultConsoleWindow(true, 'lxc', info
.vmid
, info
.node
, info
.vmname
),