]> git.proxmox.com Git - pve-manager.git/blob - www/manager/node/Config.js
Added translations
[pve-manager.git] / www / manager / 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 restartBtn = Ext.create('PVE.button.Button', {
33 text: gettext('Restart'),
34 disabled: !caps.nodes['Sys.PowerMgmt'],
35 confirmMsg: Ext.String.format(gettext("Do you really want to restart node {0}?"), nodename),
36 handler: function() {
37 node_command('reboot');
38 }
39 });
40
41 var shutdownBtn = Ext.create('PVE.button.Button', {
42 text: gettext('Shutdown'),
43 disabled: !caps.nodes['Sys.PowerMgmt'],
44 confirmMsg: Ext.String.format(gettext("Do you really want to shutdown node {0}?"), nodename),
45 handler: function() {
46 node_command('shutdown');
47 }
48 });
49
50 var shellBtn = Ext.create('Ext.Button', {
51 text: gettext('Shell'),
52 disabled: !caps.nodes['Sys.Console'],
53 handler: function() {
54 var url = Ext.urlEncode({
55 console: 'shell',
56 node: nodename
57 });
58 var nw = window.open("?" + url, '_blank',
59 "innerWidth=745,innerheight=427");
60 nw.focus();
61 }
62 });
63
64 me.items = [];
65
66 Ext.apply(me, {
67 title: gettext('Node') + " '" + nodename + "'",
68 hstateid: 'nodetab',
69 defaults: { statusStore: me.statusStore },
70 tbar: [ restartBtn, shutdownBtn, shellBtn ]
71 });
72
73 if (caps.nodes['Sys.Audit']) {
74 me.items.push([
75 {
76 title: gettext('Summary'),
77 itemId: 'summary',
78 xtype: 'pveNodeSummary'
79 },
80 {
81 title: gettext('Services'),
82 itemId: 'services',
83 xtype: 'pveNodeServiceView'
84 },
85 {
86 title: gettext('Network'),
87 itemId: 'network',
88 xtype: 'pveNodeNetworkView'
89 },
90 {
91 title: gettext('DNS'),
92 itemId: 'dns',
93 xtype: 'pveNodeDNSView'
94 },
95 {
96 title: gettext('Time'),
97 itemId: 'time',
98 xtype: 'pveNodeTimeView'
99 }
100 ]);
101 }
102
103 if (caps.nodes['Sys.Syslog']) {
104 me.items.push([
105 {
106 title: 'Syslog',
107 itemId: 'syslog',
108 xtype: 'pveLogView',
109 url: "/api2/extjs/nodes/" + nodename + "/syslog"
110 }
111 ]);
112 me.items.push([
113 {
114 title: 'Bootlog',
115 itemId: 'bootlog',
116 xtype: 'pveLogView',
117 url: "/api2/extjs/nodes/" + nodename + "/bootlog"
118 }
119 ]);
120 }
121
122 me.items.push([
123 {
124 title: gettext('Task History'),
125 itemId: 'tasks',
126 xtype: 'pveNodeTasks'
127 }
128 ]);
129
130
131 if (caps.nodes['Sys.Audit']) {
132 me.items.push([
133 {
134 title: 'UBC',
135 itemId: 'ubc',
136 xtype: 'pveNodeBCFailCnt'
137 }
138 ]);
139 }
140
141 me.items.push([
142 {
143 title: gettext('Subscription'),
144 itemId: 'support',
145 xtype: 'pveNodeSubscription',
146 nodename: nodename
147 }
148 ]);
149
150 if (caps.nodes['Sys.Console']) {
151 me.items.push([{
152 title: gettext('Updates'),
153 itemId: 'apt',
154 xtype: 'pveNodeAPT',
155 nodename: nodename
156 }]);
157 }
158
159 me.callParent();
160
161 me.statusStore.on('load', function(s, records, success) {
162 var uptimerec = s.data.get('uptime');
163 var powermgmt = uptimerec ? uptimerec.data.value : false;
164 if (!caps.nodes['Sys.PowerMgmt']) {
165 powermgmt = false;
166 }
167 restartBtn.setDisabled(!powermgmt);
168 shutdownBtn.setDisabled(!powermgmt);
169 shellBtn.setDisabled(!powermgmt);
170 });
171
172 me.on('afterrender', function() {
173 me.statusStore.startUpdate();
174 });
175
176 me.on('destroy', function() {
177 me.statusStore.stopUpdate();
178 });
179 }
180 });