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