]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/node/Config.js
use ServiceView from widget toolkit
[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('PVE.data.ObjectStore', {
18 url: "/api2/json/nodes/" + nodename + "/status",
19 interval: 1000
20 });
21
22 var node_command = function(cmd) {
23 PVE.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('PVE.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('PVE.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 }
131
132 if (caps.nodes['Sys.Console']) {
133 me.items.push(
134 {
135 title: gettext('Shell'),
136 iconCls: 'fa fa-terminal',
137 itemId: 'console',
138 xtype: 'pveNoVncConsole',
139 consoleType: 'shell',
140 nodename: nodename
141 },
142 {
143 title: gettext('Shell (JS)'),
144 iconCls: 'fa fa-terminal',
145 itemId: 'jsconsole',
146 xtype: 'pveNoVncConsole',
147 consoleType: 'shell',
148 xtermjs: true,
149 nodename: nodename
150 }
151 );
152 }
153
154 if (caps.nodes['Sys.Audit']) {
155 me.items.push(
156 {
157 title: gettext('System'),
158 iconCls: 'fa fa-cogs',
159 itemId: 'services',
160 expandedOnInit: true,
161 startOnlyServices: {
162 'pveproxy': true,
163 'pvedaemon': true,
164 'pve-cluster': true
165 },
166 nodename: nodename,
167 onlineHelp: 'pve_service_daemons',
168 xtype: 'proxmoxNodeServiceView'
169 },
170 {
171 title: gettext('Network'),
172 iconCls: 'fa fa-exchange',
173 itemId: 'network',
174 groups: ['services'],
175 nodename: nodename,
176 onlineHelp: 'sysadmin_network_configuration',
177 xtype: 'proxmoxNodeNetworkView'
178 },
179 {
180 title: gettext('DNS'),
181 iconCls: 'fa fa-globe',
182 groups: ['services'],
183 itemId: 'dns',
184 xtype: 'pveNodeDNSView'
185 },
186 {
187 title: gettext('Time'),
188 itemId: 'time',
189 groups: ['services'],
190 nodename: nodename,
191 xtype: 'proxmoxNodeTimeView',
192 iconCls: 'fa fa-clock-o'
193 });
194 }
195
196 if (caps.nodes['Sys.Syslog']) {
197 me.items.push({
198 title: 'Syslog',
199 iconCls: 'fa fa-list',
200 groups: ['services'],
201 disabled: !caps.nodes['Sys.Syslog'],
202 itemId: 'syslog',
203 xtype: 'pveLogView',
204 url: "/api2/extjs/nodes/" + nodename + "/syslog",
205 log_select_timespan: 1
206 });
207
208 if (caps.nodes['Sys.Modify']) {
209 me.items.push({
210 title: gettext('Updates'),
211 iconCls: 'fa fa-refresh',
212 disabled: !caps.nodes['Sys.Console'],
213 // do we want to link to system updates instead?
214 itemId: 'apt',
215 xtype: 'proxmoxNodeAPT',
216 upgradeBtn: {
217 xtype: 'pveConsoleButton',
218 disabled: PVE.UserName !== 'root@pam',
219 text: gettext('Upgrade'),
220 consoleType: 'upgrade',
221 nodename: nodename
222 },
223 nodename: nodename
224 });
225 }
226 }
227
228 if (caps.nodes['Sys.Audit']) {
229 me.items.push(
230 {
231 xtype: 'pveFirewallRules',
232 iconCls: 'fa fa-shield',
233 title: gettext('Firewall'),
234 allow_iface: true,
235 base_url: '/nodes/' + nodename + '/firewall/rules',
236 list_refs_url: '/cluster/firewall/refs',
237 itemId: 'firewall'
238 },
239 {
240 xtype: 'pveFirewallOptions',
241 title: gettext('Options'),
242 iconCls: 'fa fa-gear',
243 onlineHelp: 'pve_firewall_host_specific_configuration',
244 groups: ['firewall'],
245 base_url: '/nodes/' + nodename + '/firewall/options',
246 fwtype: 'node',
247 itemId: 'firewall-options'
248 });
249 }
250
251
252 if (caps.nodes['Sys.Audit']) {
253 me.items.push(
254 {
255 title: gettext('Disks'),
256 itemId: 'storage',
257 expandedOnInit: true,
258 iconCls: 'fa fa-hdd-o',
259 xtype: 'pveNodeDiskList'
260 },
261 {
262 title: 'Ceph',
263 itemId: 'ceph',
264 iconCls: 'fa fa-ceph',
265 xtype: 'pveNodeCephStatus'
266 },
267 {
268 xtype: 'pveReplicaView',
269 iconCls: 'fa fa-retweet',
270 title: gettext('Replication'),
271 itemId: 'replication'
272 },
273 {
274 xtype: 'pveNodeCephConfigCrush',
275 title: gettext('Configuration'),
276 iconCls: 'fa fa-gear',
277 groups: ['ceph'],
278 itemId: 'ceph-config'
279 },
280 {
281 xtype: 'pveNodeCephMonList',
282 title: gettext('Monitor'),
283 iconCls: 'fa fa-tv',
284 groups: ['ceph'],
285 itemId: 'ceph-monlist'
286 },
287 {
288 xtype: 'pveNodeCephOsdTree',
289 title: 'OSD',
290 iconCls: 'fa fa-hdd-o',
291 groups: ['ceph'],
292 itemId: 'ceph-osdtree'
293 },
294 {
295 xtype: 'pveNodeCephPoolList',
296 title: 'Pools',
297 iconCls: 'fa fa-sitemap',
298 groups: ['ceph'],
299 itemId: 'ceph-pools'
300 }
301 );
302 }
303
304 if (caps.nodes['Sys.Syslog']) {
305 me.items.push(
306 {
307 xtype: 'pveLogView',
308 title: gettext('Log'),
309 iconCls: 'fa fa-list',
310 groups: ['firewall'],
311 onlineHelp: 'chapter_pve_firewall',
312 url: '/api2/extjs/nodes/' + nodename + '/firewall/log',
313 itemId: 'firewall-fwlog'
314 },
315 {
316 title: gettext('Log'),
317 itemId: 'ceph-log',
318 iconCls: 'fa fa-list',
319 groups: ['ceph'],
320 onlineHelp: 'chapter_pveceph',
321 xtype: 'pveLogView',
322 url: "/api2/extjs/nodes/" + nodename + "/ceph/log"
323 });
324 }
325
326 me.items.push(
327 {
328 title: gettext('Task History'),
329 iconCls: 'fa fa-list',
330 itemId: 'tasks',
331 nodename: nodename,
332 xtype: 'proxmoxNodeTasks'
333 },
334 {
335 title: gettext('Subscription'),
336 iconCls: 'fa fa-support',
337 itemId: 'support',
338 xtype: 'pveNodeSubscription',
339 nodename: nodename
340 }
341 );
342
343 me.callParent();
344
345 me.mon(me.statusStore, 'load', function(s, records, success) {
346 var uptimerec = s.data.get('uptime');
347 var powermgmt = uptimerec ? uptimerec.data.value : false;
348 if (!caps.nodes['Sys.PowerMgmt']) {
349 powermgmt = false;
350 }
351 restartBtn.setDisabled(!powermgmt);
352 shutdownBtn.setDisabled(!powermgmt);
353 shellBtn.setDisabled(!powermgmt);
354 });
355
356 me.on('afterrender', function() {
357 me.statusStore.startUpdate();
358 });
359
360 me.on('destroy', function() {
361 me.statusStore.stopUpdate();
362 });
363 }
364 });