]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/lxc/Config.js
add onlineHelp to nodes
[pve-manager.git] / www / manager6 / lxc / Config.js
CommitLineData
56166a78
DM
1Ext.define('PVE.lxc.Config', {
2 extend: 'PVE.panel.Config',
3 alias: 'widget.PVE.lxc.Config',
4
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 VM ID specified";
16 }
17
3a8508a8
DM
18 var template = me.pveSelNode.data.template;
19
56166a78
DM
20 var caps = Ext.state.Manager.get('GuiCap');
21
22 var base_url = '/nodes/' + nodename + '/lxc/' + vmid;
540fdc8b 23
56166a78
DM
24 me.statusStore = Ext.create('PVE.data.ObjectStore', {
25 url: '/api2/json' + base_url + '/status/current',
26 interval: 1000
27 });
28
29 var vm_command = function(cmd, params) {
30 PVE.Utils.API2Request({
31 params: params,
32 url: base_url + "/status/" + cmd,
33 waitMsgTarget: me,
34 method: 'POST',
35 failure: function(response, opts) {
36 Ext.Msg.alert('Error', response.htmlStatus);
37 }
38 });
39 };
40
540fdc8b 41 var startBtn = Ext.create('Ext.Button', {
56166a78
DM
42 text: gettext('Start'),
43 disabled: !caps.vms['VM.PowerMgmt'],
44 handler: function() {
45 vm_command('start');
d4333933
DC
46 },
47 iconCls: 'fa fa-play'
540fdc8b 48 });
56166a78 49
540fdc8b 50 var umountBtn = Ext.create('Ext.Button', {
56166a78
DM
51 text: gettext('Unmount'),
52 disabled: true,
53 hidden: true,
54 handler: function() {
55 vm_command('umount');
540fdc8b
DC
56 }
57 });
58
889c7083 59 var stopBtn = Ext.create('Ext.menu.Item',{
56166a78
DM
60 text: gettext('Stop'),
61 disabled: !caps.vms['VM.PowerMgmt'],
16152937 62 confirmMsg: PVE.Utils.format_task_description('vzstop', vmid),
889c7083 63 dangerous: true,
56166a78
DM
64 handler: function() {
65 vm_command("stop");
d4333933
DC
66 },
67 iconCls: 'fa fa-stop'
56166a78 68 });
540fdc8b 69
889c7083 70 var shutdownBtn = Ext.create('PVE.button.Split', {
56166a78
DM
71 text: gettext('Shutdown'),
72 disabled: !caps.vms['VM.PowerMgmt'],
16152937 73 confirmMsg: PVE.Utils.format_task_description('vzshutdown', vmid),
56166a78
DM
74 handler: function() {
75 vm_command('shutdown');
889c7083
DC
76 },
77 menu: {
78 items:[stopBtn]
d4333933
DC
79 },
80 iconCls: 'fa fa-power-off'
56166a78 81 });
540fdc8b
DC
82
83 var migrateBtn = Ext.create('Ext.Button', {
56166a78
DM
84 text: gettext('Migrate'),
85 disabled: !caps.vms['VM.Migrate'],
86 handler: function() {
540fdc8b 87 var win = Ext.create('PVE.window.Migrate', {
56166a78
DM
88 vmtype: 'lxc',
89 nodename: nodename,
90 vmid: vmid
91 });
92 win.show();
d4333933
DC
93 },
94 iconCls: 'fa fa-send-o'
56166a78
DM
95 });
96
97 var removeBtn = Ext.create('PVE.button.Button', {
98 text: gettext('Remove'),
99 disabled: !caps.vms['VM.Allocate'],
56166a78 100 handler: function() {
32f469f3 101 Ext.create('PVE.window.SafeDestroy', {
bcecf280
DM
102 url: base_url,
103 item: { type: 'CT', id: vmid }
32f469f3 104 }).show();
d4333933
DC
105 },
106 iconCls: 'fa fa-trash-o'
56166a78
DM
107 });
108
109 var vmname = me.pveSelNode.data.name;
110
111 var consoleBtn = Ext.create('PVE.button.ConsoleButton', {
112 disabled: !caps.vms['VM.Console'],
113 consoleType: 'lxc',
114 consoleName: vmname,
115 nodename: nodename,
d4333933
DC
116 vmid: vmid,
117 iconCls: 'fa fa-terminal'
56166a78
DM
118 });
119
120 var descr = vmid + " (" + (vmname ? "'" + vmname + "' " : "'CT " + vmid + "'") + ")";
121
122 Ext.apply(me, {
123 title: Ext.String.format(gettext("Container {0} on node {1}"), descr, "'" + nodename + "'"),
124 hstateid: 'lxctab',
889c7083 125 tbar: [ startBtn, shutdownBtn, umountBtn, removeBtn,
56166a78
DM
126 migrateBtn, consoleBtn ],
127 defaults: { statusStore: me.statusStore },
128 items: [
129 {
8132a620
EK
130 title: gettext('Summary'),
131 xtype: 'pveLxcSummary',
e62ebded 132 iconCls: 'fa fa-book',
56166a78 133 itemId: 'summary'
4224e7c4 134 }
56166a78
DM
135 ]
136 });
137
4224e7c4
EK
138 if (caps.vms['VM.Console']) {
139 me.items.push({
140 title: gettext('Console'),
141 itemId: 'console',
e62ebded 142 iconCls: 'fa fa-terminal',
4224e7c4
EK
143 xtype: 'pveNoVncConsole',
144 vmid: vmid,
145 consoleType: 'lxc',
146 nodename: nodename
147 });
148 }
540fdc8b 149
e72f4285
DC
150 me.items.push(
151 {
152 title: gettext('Resources'),
153 itemId: 'resources',
154 expandedOnInit: true,
155 iconCls: 'fa fa-cube',
156 xtype: 'pveLxcRessourceView'
157 },
158 {
159 title: gettext('Network'),
160 iconCls: 'fa fa-exchange',
161 itemId: 'network',
162 xtype: 'pveLxcNetworkView'
163 },
164 {
165 title: gettext('DNS'),
166 iconCls: 'fa fa-globe',
167 itemId: 'dns',
168 xtype: 'pveLxcDNS'
169 },
170 {
171 title: gettext('Options'),
172 itemId: 'options',
173 iconCls: 'fa fa-gear',
174 xtype: 'pveLxcOptions'
175 },
176 {
177 title: gettext('Task History'),
178 itemId: 'tasks',
179 iconCls: 'fa fa-list',
180 xtype: 'pveNodeTasks',
181 vmidFilter: vmid
182 }
183 );
184
185 if (caps.vms['VM.Backup']) {
186 me.items.push({
187 title: gettext('Backup'),
188 iconCls: 'fa fa-floppy-o',
189 xtype: 'pveBackupView',
190 itemId: 'backup'
191 });
192 }
193
4224e7c4
EK
194 if (caps.vms['VM.Snapshot']) {
195 me.items.push({
196 title: gettext('Snapshots'),
e62ebded 197 iconCls: 'fa fa-history',
4224e7c4
EK
198 xtype: 'pveLxcSnapshotTree',
199 itemId: 'snapshot'
200 });
201 }
b70496d6 202
4224e7c4
EK
203 if (caps.vms['VM.Console']) {
204 me.items.push(
205 {
e62ebded 206 xtype: 'pveFirewallRules',
4224e7c4 207 title: gettext('Firewall'),
e62ebded
DC
208 iconCls: 'fa fa-shield',
209 allow_iface: true,
210 base_url: base_url + '/firewall/rules',
816b62b0 211 list_refs_url: base_url + '/firewall/refs',
4224e7c4 212 itemId: 'firewall'
e62ebded
DC
213 },
214 {
215 xtype: 'pveFirewallOptions',
216 groups: ['firewall'],
217 iconCls: 'fa fa-gear',
218 title: gettext('Options'),
219 base_url: base_url + '/firewall/options',
220 fwtype: 'vm',
221 itemId: 'firewall-options'
222 },
223 {
224 xtype: 'pveFirewallAliases',
225 title: gettext('Alias'),
226 groups: ['firewall'],
227 iconCls: 'fa fa-external-link',
228 base_url: base_url + '/firewall/aliases',
229 itemId: 'firewall-aliases'
230 },
231 {
232 xtype: 'pveIPSet',
233 title: gettext('IPSet'),
234 groups: ['firewall'],
235 iconCls: 'fa fa-list-ol',
236 base_url: base_url + '/firewall/ipset',
816b62b0 237 list_refs_url: base_url + '/firewall/refs',
e62ebded
DC
238 itemId: 'firewall-ipset'
239 },
240 {
241 title: gettext('Log'),
242 groups: ['firewall'],
243 iconCls: 'fa fa-list',
244 itemId: 'firewall-fwlog',
245 xtype: 'pveLogView',
246 url: '/api2/extjs' + base_url + '/firewall/log'
4224e7c4
EK
247 }
248 );
249 }
b70496d6 250
8132a620
EK
251 if (caps.vms['Permissions.Modify']) {
252 me.items.push({
253 xtype: 'pveACLView',
254 title: gettext('Permissions'),
255 itemId: 'permissions',
e62ebded 256 iconCls: 'fa fa-unlock',
8132a620
EK
257 path: '/vms/' + vmid
258 });
259 }
56166a78
DM
260
261 me.callParent();
262
540fdc8b 263 me.mon(me.statusStore, 'load', function(s, records, success) {
56166a78
DM
264 var status;
265 if (!success) {
266 me.workspace.checkVmMigration(me.pveSelNode);
267 status = 'unknown';
268 } else {
269 var rec = s.data.get('status');
270 status = rec ? rec.data.value : 'unknown';
3a8508a8
DM
271 rec = s.data.get('template');
272 template = rec.data.value || false;
56166a78 273 }
3a8508a8 274 startBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'running' || template);
56166a78
DM
275 shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running');
276 stopBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'stopped');
277 removeBtn.setDisabled(!caps.vms['VM.Allocate'] || status !== 'stopped');
3a8508a8 278 consoleBtn.setDisabled(template);
56166a78
DM
279
280 if (status === 'mounted') {
281 umountBtn.setDisabled(false);
282 umountBtn.setVisible(true);
889c7083 283 stopBtn.setDisabled(true);
56166a78
DM
284 } else {
285 umountBtn.setDisabled(true);
286 umountBtn.setVisible(false);
889c7083 287 stopBtn.setDisabled(false);
56166a78
DM
288 }
289 });
290
291 me.on('afterrender', function() {
292 me.statusStore.startUpdate();
293 });
294
295 me.on('destroy', function() {
296 me.statusStore.stopUpdate();
297 });
298 }
299});