]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/node/Config.js
move DiskSelector to its own file, for generic use
[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: 1000
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.nodes['Sys.PowerMgmt'],
38 menu: new Ext.menu.Menu({
39 items: [
40 {
41 text: gettext('Bulk Start'),
42 iconCls: 'fa fa-fw fa-play',
43 handler: function() {
44 var win = Ext.create('PVE.window.BulkAction', {
45 nodename: nodename,
46 title: gettext('Bulk Start'),
47 btnText: gettext('Start'),
48 action: 'startall'
49 });
50 win.show();
51 }
52 },
53 {
54 text: gettext('Bulk Stop'),
55 iconCls: 'fa fa-fw fa-stop',
56 handler: function() {
57 var win = Ext.create('PVE.window.BulkAction', {
58 nodename: nodename,
59 title: gettext('Bulk Stop'),
60 btnText: gettext('Stop'),
61 action: 'stopall'
62 });
63 win.show();
64 }
65 },
66 {
67 text: gettext('Bulk Migrate'),
68 iconCls: 'fa fa-fw fa-send-o',
69 handler: function() {
70 var win = Ext.create('PVE.window.BulkAction', {
71 nodename: nodename,
72 title: gettext('Bulk Migrate'),
73 btnText: gettext('Migrate'),
74 action: 'migrateall'
75 });
76 win.show();
77 }
78 }
79 ]
80 })
81 });
82
83 var restartBtn = Ext.create('Proxmox.button.Button', {
84 text: gettext('Restart'),
85 disabled: !caps.nodes['Sys.PowerMgmt'],
86 dangerous: true,
87 confirmMsg: gettext('Node') + " '" + nodename + "' - " + gettext('Restart'),
88 handler: function() {
89 node_command('reboot');
90 },
91 iconCls: 'fa fa-undo'
92 });
93
94 var shutdownBtn = Ext.create('Proxmox.button.Button', {
95 text: gettext('Shutdown'),
96 disabled: !caps.nodes['Sys.PowerMgmt'],
97 dangerous: true,
98 confirmMsg: gettext('Node') + " '" + nodename + "' - " + gettext('Shutdown'),
99 handler: function() {
100 node_command('shutdown');
101 },
102 iconCls: 'fa fa-power-off'
103 });
104
105 var shellBtn = Ext.create('PVE.button.ConsoleButton', {
106 disabled: !caps.nodes['Sys.Console'],
107 text: gettext('Shell'),
108 consoleType: 'shell',
109 nodename: nodename
110 });
111
112 me.items = [];
113
114 Ext.apply(me, {
115 title: gettext('Node') + " '" + nodename + "'",
116 hstateid: 'nodetab',
117 defaults: { statusStore: me.statusStore },
118 tbar: [ restartBtn, shutdownBtn, shellBtn, actionBtn]
119 });
120
121 if (caps.nodes['Sys.Audit']) {
122 me.items.push(
123 {
124 title: gettext('Summary'),
125 iconCls: 'fa fa-book',
126 itemId: 'summary',
127 xtype: 'pveNodeSummary'
128 },
129 {
130 title: gettext('Notes'),
131 iconCls: 'fa fa-sticky-note-o',
132 itemId: 'notes',
133 xtype: 'pveNotesView'
134 }
135 );
136 }
137
138 if (caps.nodes['Sys.Console']) {
139 me.items.push(
140 {
141 title: gettext('Shell'),
142 iconCls: 'fa fa-terminal',
143 itemId: 'jsconsole',
144 xtype: 'pveNoVncConsole',
145 consoleType: 'shell',
146 xtermjs: true,
147 nodename: nodename
148 }
149 );
150 }
151
152 if (caps.nodes['Sys.Audit']) {
153 me.items.push(
154 {
155 title: gettext('System'),
156 iconCls: 'fa fa-cogs',
157 itemId: 'services',
158 expandedOnInit: true,
159 startOnlyServices: {
160 'pveproxy': true,
161 'pvedaemon': true,
162 'pve-cluster': true
163 },
164 nodename: nodename,
165 onlineHelp: 'pve_service_daemons',
166 xtype: 'proxmoxNodeServiceView'
167 },
168 {
169 title: gettext('Network'),
170 iconCls: 'fa fa-exchange',
171 itemId: 'network',
172 groups: ['services'],
173 nodename: nodename,
174 onlineHelp: 'sysadmin_network_configuration',
175 xtype: 'proxmoxNodeNetworkView'
176 },
177 {
178 title: gettext('Certificates'),
179 iconCls: 'fa fa-certificate',
180 itemId: 'certificates',
181 groups: ['services'],
182 nodename: nodename,
183 xtype: 'pveCertificatesView'
184 },
185 {
186 title: gettext('DNS'),
187 iconCls: 'fa fa-globe',
188 groups: ['services'],
189 itemId: 'dns',
190 nodename: nodename,
191 onlineHelp: 'sysadmin_network_configuration',
192 xtype: 'proxmoxNodeDNSView'
193 },
194 {
195 title: gettext('Time'),
196 itemId: 'time',
197 groups: ['services'],
198 nodename: nodename,
199 xtype: 'proxmoxNodeTimeView',
200 iconCls: 'fa fa-clock-o'
201 });
202 }
203
204 if (caps.nodes['Sys.Syslog']) {
205 me.items.push({
206 title: 'Syslog',
207 iconCls: 'fa fa-list',
208 groups: ['services'],
209 disabled: !caps.nodes['Sys.Syslog'],
210 itemId: 'syslog',
211 xtype: 'proxmoxLogView',
212 url: "/api2/extjs/nodes/" + nodename + "/syslog",
213 log_select_timespan: 1
214 });
215
216 if (caps.nodes['Sys.Modify']) {
217 me.items.push({
218 title: gettext('Updates'),
219 iconCls: 'fa fa-refresh',
220 disabled: !caps.nodes['Sys.Console'],
221 // do we want to link to system updates instead?
222 itemId: 'apt',
223 xtype: 'proxmoxNodeAPT',
224 upgradeBtn: {
225 xtype: 'pveConsoleButton',
226 disabled: Proxmox.UserName !== 'root@pam',
227 text: gettext('Upgrade'),
228 consoleType: 'upgrade',
229 nodename: nodename
230 },
231 nodename: nodename
232 });
233 }
234 }
235
236 if (caps.nodes['Sys.Audit']) {
237 me.items.push(
238 {
239 xtype: 'pveFirewallRules',
240 iconCls: 'fa fa-shield',
241 title: gettext('Firewall'),
242 allow_iface: true,
243 base_url: '/nodes/' + nodename + '/firewall/rules',
244 list_refs_url: '/cluster/firewall/refs',
245 itemId: 'firewall'
246 },
247 {
248 xtype: 'pveFirewallOptions',
249 title: gettext('Options'),
250 iconCls: 'fa fa-gear',
251 onlineHelp: 'pve_firewall_host_specific_configuration',
252 groups: ['firewall'],
253 base_url: '/nodes/' + nodename + '/firewall/options',
254 fwtype: 'node',
255 itemId: 'firewall-options'
256 });
257 }
258
259
260 if (caps.nodes['Sys.Audit']) {
261 me.items.push(
262 {
263 title: gettext('Disks'),
264 itemId: 'storage',
265 expandedOnInit: true,
266 iconCls: 'fa fa-hdd-o',
267 xtype: 'pveNodeDiskList'
268 },
269 {
270 title: 'Ceph',
271 itemId: 'ceph',
272 iconCls: 'fa fa-ceph',
273 xtype: 'pveNodeCephStatus'
274 },
275 {
276 xtype: 'pveReplicaView',
277 iconCls: 'fa fa-retweet',
278 title: gettext('Replication'),
279 itemId: 'replication'
280 },
281 {
282 xtype: 'pveNodeCephConfigCrush',
283 title: gettext('Configuration'),
284 iconCls: 'fa fa-gear',
285 groups: ['ceph'],
286 itemId: 'ceph-config'
287 },
288 {
289 xtype: 'pveNodeCephMonList',
290 title: gettext('Monitor'),
291 iconCls: 'fa fa-tv',
292 groups: ['ceph'],
293 itemId: 'ceph-monlist'
294 },
295 {
296 xtype: 'pveNodeCephOsdTree',
297 title: 'OSD',
298 iconCls: 'fa fa-hdd-o',
299 groups: ['ceph'],
300 itemId: 'ceph-osdtree'
301 },
302 {
303 xtype: 'pveNodeCephPoolList',
304 title: 'Pools',
305 iconCls: 'fa fa-sitemap',
306 groups: ['ceph'],
307 itemId: 'ceph-pools'
308 }
309 );
310 }
311
312 if (caps.nodes['Sys.Syslog']) {
313 me.items.push(
314 {
315 xtype: 'proxmoxLogView',
316 title: gettext('Log'),
317 iconCls: 'fa fa-list',
318 groups: ['firewall'],
319 onlineHelp: 'chapter_pve_firewall',
320 url: '/api2/extjs/nodes/' + nodename + '/firewall/log',
321 itemId: 'firewall-fwlog'
322 },
323 {
324 title: gettext('Log'),
325 itemId: 'ceph-log',
326 iconCls: 'fa fa-list',
327 groups: ['ceph'],
328 onlineHelp: 'chapter_pveceph',
329 xtype: 'proxmoxLogView',
330 url: "/api2/extjs/nodes/" + nodename + "/ceph/log"
331 });
332 }
333
334 me.items.push(
335 {
336 title: gettext('Task History'),
337 iconCls: 'fa fa-list',
338 itemId: 'tasks',
339 nodename: nodename,
340 xtype: 'proxmoxNodeTasks'
341 },
342 {
343 title: gettext('Subscription'),
344 iconCls: 'fa fa-support',
345 itemId: 'support',
346 xtype: 'pveNodeSubscription',
347 nodename: nodename
348 }
349 );
350
351 me.callParent();
352
353 me.mon(me.statusStore, 'load', function(s, records, success) {
354 var uptimerec = s.data.get('uptime');
355 var powermgmt = uptimerec ? uptimerec.data.value : false;
356 if (!caps.nodes['Sys.PowerMgmt']) {
357 powermgmt = false;
358 }
359 restartBtn.setDisabled(!powermgmt);
360 shutdownBtn.setDisabled(!powermgmt);
361 shellBtn.setDisabled(!powermgmt);
362 });
363
364 me.on('afterrender', function() {
365 me.statusStore.startUpdate();
366 });
367
368 me.on('destroy', function() {
369 me.statusStore.stopUpdate();
370 });
371 }
372 });