]>
Commit | Line | Data |
---|---|---|
b92ba0a7 DM |
1 | Ext.define('PVE.lxc.CmdMenu', { |
2 | extend: 'Ext.menu.Menu', | |
3 | ||
efbc9f5d | 4 | showSeparator: false, |
b92ba0a7 DM |
5 | initComponent: function() { |
6 | var me = this; | |
7 | ||
8 | var nodename = me.pveSelNode.data.node; | |
9 | if (!nodename) { | |
10 | throw "no node name specified"; | |
11 | } | |
12 | ||
13 | var vmid = me.pveSelNode.data.vmid; | |
14 | if (!vmid) { | |
15 | throw "no CT ID specified"; | |
16 | } | |
b92ba0a7 DM |
17 | var vmname = me.pveSelNode.data.name; |
18 | ||
19 | var vm_command = function(cmd, params) { | |
20 | PVE.Utils.API2Request({ | |
21 | params: params, | |
22 | url: '/nodes/' + nodename + '/lxc/' + vmid + "/status/" + cmd, | |
23 | method: 'POST', | |
24 | failure: function(response, opts) { | |
25 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
26 | } | |
27 | }); | |
28 | }; | |
29 | ||
ce8dac51 DC |
30 | var running = false; |
31 | var stopped = true; | |
32 | var suspended = false; | |
33 | ||
34 | switch (me.pveSelNode.data.status) { | |
35 | case 'running': | |
36 | running = true; | |
37 | stopped = false; | |
38 | break; | |
39 | case 'paused': | |
40 | stopped = false; | |
41 | suspended = true; | |
42 | break; | |
43 | default: break; | |
44 | } | |
45 | ||
d59ed79b | 46 | me.title = 'CT ' + vmid; |
b92ba0a7 DM |
47 | |
48 | me.items = [ | |
49 | { | |
50 | text: gettext('Start'), | |
d4333933 | 51 | iconCls: 'fa fa-fw fa-play', |
ce8dac51 | 52 | disabled: running, |
b92ba0a7 DM |
53 | handler: function() { |
54 | vm_command('start'); | |
55 | } | |
56 | }, | |
1b711780 DC |
57 | // { |
58 | // text: gettext('Suspend'), | |
59 | // iconCls: 'fa fa-fw fa-pause', | |
efbc9f5d | 60 | // hidde: suspended, |
1b711780 DC |
61 | // disabled: stopped || suspended, |
62 | // handler: function() { | |
63 | // var msg = PVE.Utils.format_task_description('vzsuspend', vmid); | |
64 | // Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) { | |
65 | // if (btn !== 'yes') { | |
66 | // return; | |
67 | // } | |
68 | // | |
69 | // vm_command('suspend'); | |
70 | // }); | |
71 | // } | |
72 | // }, | |
73 | // { | |
74 | // text: gettext('Resume'), | |
75 | // iconCls: 'fa fa-fw fa-play', | |
efbc9f5d | 76 | // hidden: !suspended, |
1b711780 DC |
77 | // handler: function() { |
78 | // vm_command('resume'); | |
79 | // } | |
80 | // }, | |
b92ba0a7 DM |
81 | { |
82 | text: gettext('Shutdown'), | |
d4333933 | 83 | iconCls: 'fa fa-fw fa-power-off', |
ce8dac51 | 84 | disabled: stopped || suspended, |
b92ba0a7 | 85 | handler: function() { |
16152937 | 86 | var msg = PVE.Utils.format_task_description('vzshutdown', vmid); |
b92ba0a7 DM |
87 | Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) { |
88 | if (btn !== 'yes') { | |
89 | return; | |
90 | } | |
91 | ||
92 | vm_command('shutdown'); | |
93 | }); | |
9bd6cd80 | 94 | } |
b92ba0a7 DM |
95 | }, |
96 | { | |
97 | text: gettext('Stop'), | |
d4333933 | 98 | iconCls: 'fa fa-fw fa-stop', |
ce8dac51 | 99 | disabled: stopped, |
b92ba0a7 | 100 | handler: function() { |
16152937 | 101 | var msg = PVE.Utils.format_task_description('vzstop', vmid); |
b92ba0a7 DM |
102 | Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) { |
103 | if (btn !== 'yes') { | |
104 | return; | |
105 | } | |
106 | ||
107 | vm_command("stop"); | |
108 | }); | |
109 | } | |
110 | }, | |
22f2f9d6 | 111 | { xtype: 'menuseparator' }, |
efbc9f5d DC |
112 | { |
113 | text: gettext('Migrate'), | |
114 | iconCls: 'fa fa-fw fa-send-o', | |
115 | handler: function() { | |
116 | var win = Ext.create('PVE.window.Migrate', { | |
117 | vmtype: 'lxc', | |
118 | nodename: nodename, | |
119 | vmid: vmid | |
120 | }); | |
121 | win.show(); | |
122 | } | |
123 | }, | |
eafa845f DC |
124 | // { |
125 | // text: gettext('Convert to template'), | |
126 | // icon: '/pve2/images/forward.png', | |
127 | // handler: function() { | |
7c7ae44f | 128 | // var msg = PVE.Utils.format_task_description('vztemplate', vmid); |
eafa845f DC |
129 | // Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) { |
130 | // if (btn !== 'yes') { | |
131 | // return; | |
132 | // } | |
133 | // | |
134 | // PVE.Utils.API2Request({ | |
135 | // url: '/nodes/' + nodename + '/lxc/' + vmid + '/template', | |
136 | // method: 'POST', | |
137 | // failure: function(response, opts) { | |
138 | // Ext.Msg.alert('Error', response.htmlStatus); | |
139 | // } | |
140 | // }); | |
141 | // }); | |
142 | // } | |
143 | // }, | |
22f2f9d6 | 144 | { xtype: 'menuseparator' }, |
b92ba0a7 DM |
145 | { |
146 | text: gettext('Console'), | |
d4333933 | 147 | iconCls: 'fa fa-fw fa-terminal', |
b92ba0a7 DM |
148 | handler: function() { |
149 | PVE.Utils.openDefaultConsoleWindow(true, 'lxc', vmid, nodename, vmname); | |
150 | } | |
151 | } | |
152 | ]; | |
153 | ||
154 | me.callParent(); | |
155 | } | |
156 | }); |