]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/node/Config.js
ui: subscription panel: code reduction and modernization
[pve-manager.git] / www / manager6 / node / Config.js
1 Ext.define('PVE.node.Config', {
2 extend: 'PVE.panel.Config',
3 alias: 'widget.PVE.node.Config',
4
5 onlineHelp: 'chapter_system_administration',
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 caps = Ext.state.Manager.get('GuiCap');
16
17 me.statusStore = Ext.create('Proxmox.data.ObjectStore', {
18 url: "/api2/json/nodes/" + nodename + "/status",
19 interval: 5000,
20 });
21
22 var node_command = function(cmd) {
23 Proxmox.Utils.API2Request({
24 params: { command: cmd },
25 url: '/nodes/' + nodename + '/status',
26 method: 'POST',
27 waitMsgTarget: me,
28 failure: function(response, opts) {
29 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
30 },
31 });
32 };
33
34 var actionBtn = Ext.create('Ext.Button', {
35 text: gettext('Bulk Actions'),
36 iconCls: 'fa fa-fw fa-ellipsis-v',
37 disabled: !caps.vms['VM.PowerMgmt'] && !caps.vms['VM.Migrate'],
38 menu: new Ext.menu.Menu({
39 items: [
40 {
41 text: gettext('Bulk Start'),
42 iconCls: 'fa fa-fw fa-play',
43 disabled: !caps.vms['VM.PowerMgmt'],
44 handler: function() {
45 Ext.create('PVE.window.BulkAction', {
46 autoShow: true,
47 nodename: nodename,
48 title: gettext('Bulk Start'),
49 btnText: gettext('Start'),
50 action: 'startall',
51 });
52 },
53 },
54 {
55 text: gettext('Bulk Shutdown'),
56 iconCls: 'fa fa-fw fa-stop',
57 disabled: !caps.vms['VM.PowerMgmt'],
58 handler: function() {
59 Ext.create('PVE.window.BulkAction', {
60 autoShow: true,
61 nodename: nodename,
62 title: gettext('Bulk Shutdown'),
63 btnText: gettext('Shutdown'),
64 action: 'stopall',
65 });
66 },
67 },
68 {
69 text: gettext('Bulk Migrate'),
70 iconCls: 'fa fa-fw fa-send-o',
71 disabled: !caps.vms['VM.Migrate'],
72 handler: function() {
73 Ext.create('PVE.window.BulkAction', {
74 autoShow: true,
75 nodename: nodename,
76 title: gettext('Bulk Migrate'),
77 btnText: gettext('Migrate'),
78 action: 'migrateall',
79 });
80 },
81 },
82 ],
83 }),
84 });
85
86 let restartBtn = Ext.create('Proxmox.button.Button', {
87 text: gettext('Reboot'),
88 disabled: !caps.nodes['Sys.PowerMgmt'],
89 dangerous: true,
90 confirmMsg: Ext.String.format(gettext("Reboot node '{0}'?"), nodename),
91 handler: function() {
92 node_command('reboot');
93 },
94 iconCls: 'fa fa-undo',
95 });
96
97 var shutdownBtn = Ext.create('Proxmox.button.Button', {
98 text: gettext('Shutdown'),
99 disabled: !caps.nodes['Sys.PowerMgmt'],
100 dangerous: true,
101 confirmMsg: Ext.String.format(gettext("Shutdown node '{0}'?"), nodename),
102 handler: function() {
103 node_command('shutdown');
104 },
105 iconCls: 'fa fa-power-off',
106 });
107
108 var shellBtn = Ext.create('PVE.button.ConsoleButton', {
109 disabled: !caps.nodes['Sys.Console'],
110 text: gettext('Shell'),
111 consoleType: 'shell',
112 nodename: nodename,
113 });
114
115 me.items = [];
116
117 Ext.apply(me, {
118 title: gettext('Node') + " '" + nodename + "'",
119 hstateid: 'nodetab',
120 defaults: {
121 statusStore: me.statusStore,
122 },
123 tbar: [restartBtn, shutdownBtn, shellBtn, actionBtn],
124 });
125
126 if (caps.nodes['Sys.Audit']) {
127 me.items.push(
128 {
129 xtype: 'pveNodeSummary',
130 title: gettext('Summary'),
131 iconCls: 'fa fa-book',
132 itemId: 'summary',
133 },
134 {
135 xtype: 'pmxNotesView',
136 title: gettext('Notes'),
137 iconCls: 'fa fa-sticky-note-o',
138 itemId: 'notes',
139 },
140 );
141 }
142
143 if (caps.nodes['Sys.Console']) {
144 me.items.push(
145 {
146 xtype: 'pveNoVncConsole',
147 title: gettext('Shell'),
148 iconCls: 'fa fa-terminal',
149 itemId: 'jsconsole',
150 consoleType: 'shell',
151 xtermjs: true,
152 nodename: nodename,
153 },
154 );
155 }
156
157 if (caps.nodes['Sys.Audit']) {
158 me.items.push(
159 {
160 xtype: 'proxmoxNodeServiceView',
161 title: gettext('System'),
162 iconCls: 'fa fa-cogs',
163 itemId: 'services',
164 expandedOnInit: true,
165 restartCommand: 'reload', // avoid disruptions
166 startOnlyServices: {
167 'pveproxy': true,
168 'pvedaemon': true,
169 'pve-cluster': true,
170 },
171 nodename: nodename,
172 onlineHelp: 'pve_service_daemons',
173 },
174 {
175 xtype: 'proxmoxNodeNetworkView',
176 title: gettext('Network'),
177 iconCls: 'fa fa-exchange',
178 itemId: 'network',
179 showApplyBtn: true,
180 groups: ['services'],
181 nodename: nodename,
182 onlineHelp: 'sysadmin_network_configuration',
183 },
184 {
185 xtype: 'pveCertificatesView',
186 title: gettext('Certificates'),
187 iconCls: 'fa fa-certificate',
188 itemId: 'certificates',
189 groups: ['services'],
190 nodename: nodename,
191 },
192 {
193 xtype: 'proxmoxNodeDNSView',
194 title: gettext('DNS'),
195 iconCls: 'fa fa-globe',
196 groups: ['services'],
197 itemId: 'dns',
198 nodename: nodename,
199 onlineHelp: 'sysadmin_network_configuration',
200 },
201 {
202 xtype: 'proxmoxNodeHostsView',
203 title: gettext('Hosts'),
204 iconCls: 'fa fa-globe',
205 groups: ['services'],
206 itemId: 'hosts',
207 nodename: nodename,
208 onlineHelp: 'sysadmin_network_configuration',
209 },
210 {
211 xtype: 'proxmoxNodeOptionsView',
212 title: gettext('Options'),
213 iconCls: 'fa fa-gear',
214 groups: ['services'],
215 itemId: 'options',
216 nodename: nodename,
217 onlineHelp: 'proxmox_node_management',
218 },
219 {
220 xtype: 'proxmoxNodeTimeView',
221 title: gettext('Time'),
222 itemId: 'time',
223 groups: ['services'],
224 nodename: nodename,
225 iconCls: 'fa fa-clock-o',
226 });
227 }
228
229 if (caps.nodes['Sys.Syslog']) {
230 me.items.push({
231 xtype: 'proxmoxJournalView',
232 title: 'Syslog',
233 iconCls: 'fa fa-list',
234 groups: ['services'],
235 disabled: !caps.nodes['Sys.Syslog'],
236 itemId: 'syslog',
237 url: "/api2/extjs/nodes/" + nodename + "/journal",
238 });
239
240 if (caps.nodes['Sys.Modify']) {
241 me.items.push({
242 xtype: 'proxmoxNodeAPT',
243 title: gettext('Updates'),
244 iconCls: 'fa fa-refresh',
245 expandedOnInit: true,
246 disabled: !caps.nodes['Sys.Console'],
247 // do we want to link to system updates instead?
248 itemId: 'apt',
249 upgradeBtn: {
250 xtype: 'pveConsoleButton',
251 disabled: Proxmox.UserName !== 'root@pam',
252 text: gettext('Upgrade'),
253 consoleType: 'upgrade',
254 nodename: nodename,
255 },
256 nodename: nodename,
257 });
258
259 me.items.push({
260 xtype: 'proxmoxNodeAPTRepositories',
261 title: gettext('Repositories'),
262 iconCls: 'fa fa-files-o',
263 itemId: 'aptrepositories',
264 nodename: nodename,
265 onlineHelp: 'sysadmin_package_repositories',
266 groups: ['apt'],
267 });
268 }
269 }
270
271 if (caps.nodes['Sys.Audit']) {
272 me.items.push(
273 {
274 xtype: 'pveFirewallRules',
275 iconCls: 'fa fa-shield',
276 title: gettext('Firewall'),
277 allow_iface: true,
278 base_url: '/nodes/' + nodename + '/firewall/rules',
279 list_refs_url: '/cluster/firewall/refs',
280 itemId: 'firewall',
281 },
282 {
283 xtype: 'pveFirewallOptions',
284 title: gettext('Options'),
285 iconCls: 'fa fa-gear',
286 onlineHelp: 'pve_firewall_host_specific_configuration',
287 groups: ['firewall'],
288 base_url: '/nodes/' + nodename + '/firewall/options',
289 fwtype: 'node',
290 itemId: 'firewall-options',
291 });
292 }
293
294
295 if (caps.nodes['Sys.Audit']) {
296 me.items.push(
297 {
298 xtype: 'pmxDiskList',
299 title: gettext('Disks'),
300 itemId: 'storage',
301 expandedOnInit: true,
302 iconCls: 'fa fa-hdd-o',
303 nodename: nodename,
304 includePartitions: true,
305 supportsWipeDisk: true,
306 },
307 {
308 xtype: 'pveLVMList',
309 title: 'LVM',
310 itemId: 'lvm',
311 onlineHelp: 'chapter_lvm',
312 iconCls: 'fa fa-square',
313 groups: ['storage'],
314 },
315 {
316 xtype: 'pveLVMThinList',
317 title: 'LVM-Thin',
318 itemId: 'lvmthin',
319 onlineHelp: 'chapter_lvm',
320 iconCls: 'fa fa-square-o',
321 groups: ['storage'],
322 },
323 {
324 xtype: 'pveDirectoryList',
325 title: Proxmox.Utils.directoryText,
326 itemId: 'directory',
327 onlineHelp: 'chapter_storage',
328 iconCls: 'fa fa-folder',
329 groups: ['storage'],
330 },
331 {
332 title: 'ZFS',
333 itemId: 'zfs',
334 onlineHelp: 'chapter_zfs',
335 iconCls: 'fa fa-th-large',
336 groups: ['storage'],
337 xtype: 'pveZFSList',
338 },
339 {
340 xtype: 'pveNodeCephStatus',
341 title: 'Ceph',
342 itemId: 'ceph',
343 iconCls: 'fa fa-ceph',
344 },
345 {
346 xtype: 'pveNodeCephConfigCrush',
347 title: gettext('Configuration'),
348 iconCls: 'fa fa-gear',
349 groups: ['ceph'],
350 itemId: 'ceph-config',
351 },
352 {
353 xtype: 'pveNodeCephMonMgr',
354 title: gettext('Monitor'),
355 iconCls: 'fa fa-tv',
356 groups: ['ceph'],
357 itemId: 'ceph-monlist',
358 },
359 {
360 xtype: 'pveNodeCephOsdTree',
361 title: 'OSD',
362 iconCls: 'fa fa-hdd-o',
363 groups: ['ceph'],
364 itemId: 'ceph-osdtree',
365 },
366 {
367 xtype: 'pveNodeCephFSPanel',
368 title: 'CephFS',
369 iconCls: 'fa fa-folder',
370 groups: ['ceph'],
371 nodename: nodename,
372 itemId: 'ceph-cephfspanel',
373 },
374 {
375 xtype: 'pveNodeCephPoolList',
376 title: gettext('Pools'),
377 iconCls: 'fa fa-sitemap',
378 groups: ['ceph'],
379 itemId: 'ceph-pools',
380 },
381 {
382 xtype: 'pveReplicaView',
383 iconCls: 'fa fa-retweet',
384 title: gettext('Replication'),
385 itemId: 'replication',
386 },
387 );
388 }
389
390 if (caps.nodes['Sys.Syslog']) {
391 me.items.push(
392 {
393 xtype: 'proxmoxLogView',
394 title: gettext('Log'),
395 iconCls: 'fa fa-list',
396 groups: ['firewall'],
397 onlineHelp: 'chapter_pve_firewall',
398 url: '/api2/extjs/nodes/' + nodename + '/firewall/log',
399 itemId: 'firewall-fwlog',
400 },
401 {
402 xtype: 'cephLogView',
403 title: gettext('Log'),
404 itemId: 'ceph-log',
405 iconCls: 'fa fa-list',
406 groups: ['ceph'],
407 onlineHelp: 'chapter_pveceph',
408 url: "/api2/extjs/nodes/" + nodename + "/ceph/log",
409 nodename: nodename,
410 });
411 }
412
413 me.items.push(
414 {
415 title: gettext('Task History'),
416 iconCls: 'fa fa-list-alt',
417 itemId: 'tasks',
418 nodename: nodename,
419 xtype: 'proxmoxNodeTasks',
420 extraFilter: [
421 {
422 xtype: 'pveGuestIDSelector',
423 fieldLabel: gettext('VMID'),
424 allowBlank: true,
425 name: 'vmid',
426 },
427 ],
428 },
429 {
430 title: gettext('Subscription'),
431 iconCls: 'fa fa-support',
432 itemId: 'support',
433 xtype: 'pveNodeSubscription',
434 nodename: nodename,
435 },
436 );
437
438 me.callParent();
439
440 me.mon(me.statusStore, 'load', function(store, records, success) {
441 let uptimerec = store.data.get('uptime');
442 let powermgmt = caps.nodes['Sys.PowerMgmt'] && uptimerec && uptimerec.data.value;
443
444 restartBtn.setDisabled(!powermgmt);
445 shutdownBtn.setDisabled(!powermgmt);
446 shellBtn.setDisabled(!powermgmt);
447 });
448
449 me.on('afterrender', function() {
450 me.statusStore.startUpdate();
451 });
452
453 me.on('destroy', function() {
454 me.statusStore.stopUpdate();
455 });
456 },
457 });