]>
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 var nodename
= me
.pveSelNode
.data
.node
;
10 throw "no node name specified";
13 var vmid
= me
.pveSelNode
.data
.vmid
;
15 throw "no CT ID specified";
17 var vmname
= me
.pveSelNode
.data
.name
;
19 var vm_command = function(cmd
, params
) {
20 Proxmox
.Utils
.API2Request({
22 url
: '/nodes/' + nodename
+ '/lxc/' + vmid
+ "/status/" + cmd
,
24 failure: function(response
, opts
) {
25 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
30 var caps
= Ext
.state
.Manager
.get('GuiCap');
34 var suspended
= false;
35 var standalone
= PVE
.data
.ResourceStore
.getNodes().length
< 2;
37 switch (me
.pveSelNode
.data
.status
) {
49 me
.title
= 'CT ' + vmid
;
53 text
: gettext('Start'),
54 iconCls
: 'fa fa-fw fa-play',
61 // text: gettext('Suspend'),
62 // iconCls: 'fa fa-fw fa-pause',
64 // disabled: stopped || suspended,
65 // handler: function() {
66 // var msg = Proxmox.Utils.format_task_description('vzsuspend', vmid);
67 // Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
68 // if (btn !== 'yes') {
72 // vm_command('suspend');
77 // text: gettext('Resume'),
78 // iconCls: 'fa fa-fw fa-play',
79 // hidden: !suspended,
80 // handler: function() {
81 // vm_command('resume');
85 text
: gettext('Shutdown'),
86 iconCls
: 'fa fa-fw fa-power-off',
87 disabled
: stopped
|| suspended
,
89 var msg
= Proxmox
.Utils
.format_task_description('vzshutdown', vmid
);
90 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
95 vm_command('shutdown');
100 text
: gettext('Stop'),
101 iconCls
: 'fa fa-fw fa-stop',
103 tooltip
: Ext
.String
.format(gettext('Stop {0} immediately'), 'CT'),
104 handler: function() {
105 var msg
= Proxmox
.Utils
.format_task_description('vzstop', vmid
);
106 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
116 text
: gettext('Reboot'),
117 iconCls
: 'fa fa-fw fa-refresh',
119 tooltip
: Ext
.String
.format(gettext('Reboot {0}'), 'CT'),
120 handler: function() {
121 var msg
= Proxmox
.Utils
.format_task_description('vzreboot', vmid
);
122 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
127 vm_command("reboot");
132 xtype
: 'menuseparator',
133 hidden
: (standalone
|| !caps
.vms
['VM.Migrate']) && !caps
.vms
['VM.Allocate'] && !caps
.vms
['VM.Clone']
136 text
: gettext('Clone'),
137 iconCls
: 'fa fa-fw fa-clone',
138 hidden
: !caps
.vms
['VM.Clone'],
139 handler: function() {
140 PVE
.window
.Clone
.wrap(nodename
, vmid
, me
.isTemplate
, 'lxc');
144 text
: gettext('Migrate'),
145 iconCls
: 'fa fa-fw fa-send-o',
146 hidden
: standalone
|| !caps
.vms
['VM.Migrate'],
147 handler: function() {
148 var win
= Ext
.create('PVE.window.Migrate', {
157 text
: gettext('Convert to template'),
158 iconCls
: 'fa fa-fw fa-file-o',
159 handler: function() {
160 var msg
= Proxmox
.Utils
.format_task_description('vztemplate', vmid
);
161 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
166 Proxmox
.Utils
.API2Request({
167 url
: '/nodes/' + nodename
+ '/lxc/' + vmid
+ '/template',
169 failure: function(response
, opts
) {
170 Ext
.Msg
.alert('Error', response
.htmlStatus
);
176 { xtype
: 'menuseparator' },
178 text
: gettext('Console'),
179 iconCls
: 'fa fa-fw fa-terminal',
180 handler: function() {
181 PVE
.Utils
.openDefaultConsoleWindow(true, 'lxc', vmid
, nodename
, vmname
);