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