]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/node/Config.js
6d60bfcf80798eeff7f23abf0b08ee10a74abdfc
[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 initComponent: function() {
6 var me = this;
7
8 var nodename = me.pveSelNode.data.node;
9 if (!nodename) {
10 throw "no node name specified";
11 }
12
13 var caps = Ext.state.Manager.get('GuiCap');
14
15 me.statusStore = Ext.create('PVE.data.ObjectStore', {
16 url: "/api2/json/nodes/" + nodename + "/status",
17 interval: 1000
18 });
19
20 var node_command = function(cmd) {
21 PVE.Utils.API2Request({
22 params: { command: cmd },
23 url: '/nodes/' + nodename + '/status',
24 method: 'POST',
25 waitMsgTarget: me,
26 failure: function(response, opts) {
27 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
28 }
29 });
30 };
31
32 var actionBtn = Ext.create('Ext.Button', {
33 text: gettext('More'),
34 disabled: !caps.nodes['Sys.PowerMgmt'],
35 menu: new Ext.menu.Menu({
36 items: [
37 {
38 text: gettext('Start All VMs'),
39 icon: '/pve2/images/start.png',
40 handler: function() {
41 var msg = Ext.String.format(gettext("Do you really want to start all Vms on node {0}?"), nodename);
42 Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
43 if (btn !== 'yes') {
44 return;
45 }
46 PVE.Utils.API2Request({
47 params: { force: 1 },
48 url: '/nodes/' + nodename + '/startall',
49 method: 'POST',
50 waitMsgTarget: me,
51 failure: function(response, opts) {
52 Ext.Msg.alert('Error', response.htmlStatus);
53 }
54 });
55 });
56 }
57 },
58 {
59 text: gettext('Stop All VMs'),
60 icon: '/pve2/images/gtk-stop.png',
61 handler: function() {
62 var msg = Ext.String.format(gettext("Do you really want to stop all Vms on node {0}?"), nodename);
63 Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
64 if (btn !== 'yes') {
65 return;
66 }
67
68 PVE.Utils.API2Request({
69 url: '/nodes/' + nodename + '/stopall',
70 method: 'POST',
71 waitMsgTarget: me,
72 failure: function(response, opts) {
73 Ext.Msg.alert('Error', response.htmlStatus);
74 }
75 });
76 });
77 }
78 },
79 {
80 text: gettext('Migrate All VMs'),
81 icon: '/pve2/images/forward.png',
82 handler: function() {
83 var win = Ext.create('PVE.window.MigrateAll', {
84 nodename: nodename,
85 });
86 win.show();
87 }
88 }
89 ]
90 })
91 });
92
93 var restartBtn = Ext.create('PVE.button.Button', {
94 text: gettext('Restart'),
95 disabled: !caps.nodes['Sys.PowerMgmt'],
96 confirmMsg: Ext.String.format(gettext("Do you really want to restart node {0}?"), nodename),
97 handler: function() {
98 node_command('reboot');
99 }
100 });
101
102 var shutdownBtn = Ext.create('PVE.button.Button', {
103 text: gettext('Shutdown'),
104 disabled: !caps.nodes['Sys.PowerMgmt'],
105 confirmMsg: Ext.String.format(gettext("Do you really want to shutdown node {0}?"), nodename),
106 handler: function() {
107 node_command('shutdown');
108 }
109 });
110
111 var shellBtn = Ext.create('PVE.button.ConsoleButton', {
112 disabled: !caps.nodes['Sys.Console'],
113 text: gettext('Shell'),
114 consoleType: 'shell',
115 nodename: nodename
116 });
117
118 me.items = [];
119
120 Ext.apply(me, {
121 title: gettext('Node') + " '" + nodename + "'",
122 hstateid: 'nodetab',
123 defaults: { statusStore: me.statusStore },
124 tbar: [ restartBtn, shutdownBtn, shellBtn, actionBtn]
125 });
126
127 if (caps.nodes['Sys.Audit']) {
128 me.items.push(
129 {
130 title: gettext('Summary'),
131 itemId: 'summary',
132 xtype: 'pveNodeSummary'
133 },
134 {
135 title: gettext('Services'),
136 itemId: 'services',
137 xtype: 'pveNodeServiceView',
138 },
139 {
140 title: gettext('Network'),
141 itemId: 'network',
142 xtype: 'pveNodeNetworkView'
143 },
144 {
145 title: gettext('DNS'),
146 itemId: 'dns',
147 xtype: 'pveNodeDNSView'
148 },
149 {
150 title: gettext('Time'),
151 itemId: 'time',
152 xtype: 'pveNodeTimeView'
153 }
154 );
155 }
156
157 if (caps.nodes['Sys.Syslog']) {
158 me.items.push(
159 {
160 title: 'Syslog',
161 itemId: 'syslog',
162 xtype: 'pveLogView',
163 url: "/api2/extjs/nodes/" + nodename + "/syslog",
164 log_select_timespan: 1
165 }
166 );
167 }
168
169 me.items.push(
170 {
171 title: gettext('Task History'),
172 itemId: 'tasks',
173 xtype: 'pveNodeTasks'
174 }
175 );
176
177 if (caps.nodes['Sys.Console']) {
178 me.items.push(
179 {
180 xtype: 'pveFirewallPanel',
181 title: gettext('Firewall'),
182 base_url: '/nodes/' + nodename + '/firewall',
183 fwtype: 'node',
184 phstateid: me.hstateid,
185 itemId: 'firewall'
186 },
187 {
188 title: gettext('Updates'),
189 itemId: 'apt',
190 xtype: 'pveNodeAPT',
191 nodename: nodename
192 },
193 {
194 title: gettext('Console'),
195 itemId: 'console',
196 xtype: 'pveNoVncConsole',
197 consoleType: 'shell',
198 nodename: nodename
199 },
200 {
201 title: 'Ceph',
202 itemId: 'ceph',
203 xtype: 'pveNodeCeph',
204 phstateid: me.hstateid,
205 nodename: nodename
206 }
207 );
208 }
209
210 me.items.push(
211 {
212 title: gettext('Subscription'),
213 itemId: 'support',
214 xtype: 'pveNodeSubscription',
215 nodename: nodename
216 }
217 );
218
219 me.callParent();
220
221 me.mon(me.statusStore, 'load', function(s, records, success) {
222 var uptimerec = s.data.get('uptime');
223 var powermgmt = uptimerec ? uptimerec.data.value : false;
224 if (!caps.nodes['Sys.PowerMgmt']) {
225 powermgmt = false;
226 }
227 restartBtn.setDisabled(!powermgmt);
228 shutdownBtn.setDisabled(!powermgmt);
229 shellBtn.setDisabled(!powermgmt);
230 });
231
232 me.on('afterrender', function() {
233 me.statusStore.startUpdate();
234 });
235
236 me.on('destroy', function() {
237 me.statusStore.stopUpdate();
238 });
239 }
240 });