]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/lxc/CmdMenu.js
jslint: remove trailing commas
[pve-manager.git] / www / manager6 / lxc / CmdMenu.js
1 Ext.define('PVE.lxc.CmdMenu', {
2 extend: 'Ext.menu.Menu',
3
4 showSeparator: false,
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 }
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
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
46 me.title = 'CT ' + vmid;
47
48 me.items = [
49 {
50 text: gettext('Start'),
51 iconCls: 'fa fa-fw fa-play',
52 disabled: running,
53 handler: function() {
54 vm_command('start');
55 }
56 },
57 // {
58 // text: gettext('Suspend'),
59 // iconCls: 'fa fa-fw fa-pause',
60 // hidde: suspended,
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',
76 // hidden: !suspended,
77 // handler: function() {
78 // vm_command('resume');
79 // }
80 // },
81 {
82 text: gettext('Shutdown'),
83 iconCls: 'fa fa-fw fa-power-off',
84 disabled: stopped || suspended,
85 handler: function() {
86 var msg = PVE.Utils.format_task_description('vzshutdown', vmid);
87 Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
88 if (btn !== 'yes') {
89 return;
90 }
91
92 vm_command('shutdown');
93 });
94 }
95 },
96 {
97 text: gettext('Stop'),
98 iconCls: 'fa fa-fw fa-stop',
99 disabled: stopped,
100 handler: function() {
101 var msg = PVE.Utils.format_task_description('vzstop', vmid);
102 Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
103 if (btn !== 'yes') {
104 return;
105 }
106
107 vm_command("stop");
108 });
109 }
110 },
111 { xtype: 'menuseparator' },
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 },
124 // {
125 // text: gettext('Convert to template'),
126 // icon: '/pve2/images/forward.png',
127 // handler: function() {
128 // var msg = PVE.Utils.format_task_description('vztemplate', vmid);
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 // },
144 { xtype: 'menuseparator' },
145 {
146 text: gettext('Console'),
147 iconCls: 'fa fa-fw fa-terminal',
148 handler: function() {
149 PVE.Utils.openDefaultConsoleWindow(true, 'lxc', vmid, nodename, vmname);
150 }
151 }
152 ];
153
154 me.callParent();
155 }
156 });