]>
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
.Utils
.isStandaloneNode();
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'),
70 Ext
.create('PVE.GuestStop', {
78 text
: gettext('Reboot'),
79 iconCls
: 'fa fa-fw fa-refresh',
81 tooltip
: Ext
.String
.format(gettext('Reboot {0}'), 'CT'),
82 handler
: () => confirmedVMCommand('reboot'),
85 xtype
: 'menuseparator',
86 hidden
: (standalone
|| !caps
.vms
['VM.Migrate']) && !caps
.vms
['VM.Allocate'] && !caps
.vms
['VM.Clone'],
89 text
: gettext('Clone'),
90 iconCls
: 'fa fa-fw fa-clone',
91 hidden
: !caps
.vms
['VM.Clone'],
92 handler
: () => PVE
.window
.Clone
.wrap(info
.node
, info
.vmid
, me
.isTemplate
, 'lxc'),
95 text
: gettext('Migrate'),
96 iconCls
: 'fa fa-fw fa-send-o',
97 hidden
: standalone
|| !caps
.vms
['VM.Migrate'],
99 Ext
.create('PVE.window.Migrate', {
108 text
: gettext('Convert to template'),
109 iconCls
: 'fa fa-fw fa-file-o',
110 handler: function() {
111 let msg
= Proxmox
.Utils
.format_task_description('vztemplate', info
.vmid
);
112 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
114 Proxmox
.Utils
.API2Request({
115 url
: `/nodes/${info.node}/lxc/${info.vmid}/template`,
117 failure
: (response
, opts
) => Ext
.Msg
.alert('Error', response
.htmlStatus
),
123 { xtype
: 'menuseparator' },
125 text
: gettext('Console'),
126 iconCls
: 'fa fa-fw fa-terminal',
128 PVE
.Utils
.openDefaultConsoleWindow(true, 'lxc', info
.vmid
, info
.node
, info
.vmname
),