]> git.proxmox.com Git - proxmox-backup.git/blame - www/panel/NodeInfo.js
fix #5117: ui: node info: avoid invalid array access for certain foreign kernels
[proxmox-backup.git] / www / panel / NodeInfo.js
CommitLineData
e584593c 1Ext.define('PBS.NodeInfoPanel', {
b20368ee 2 extend: 'Proxmox.panel.StatusView',
e584593c
DC
3 alias: 'widget.pbsNodeInfoPanel',
4
b20368ee 5 height: 300,
7a39b41c 6 bodyPadding: '15 5 15 5',
b20368ee
DC
7
8 layout: {
9 type: 'table',
10 columns: 2,
11 tableAttrs: {
12 style: {
13 width: '100%',
14 },
15 },
16 },
17
18 defaults: {
19 xtype: 'pmxInfoWidget',
7a39b41c 20 padding: '0 10 5 10',
b20368ee 21 },
e584593c
DC
22
23 controller: {
24 xclass: 'Ext.app.ViewController',
25
26 showFingerPrint: function() {
27 let me = this;
28 let view = me.getView();
29 let fingerprint = view.fingerprint;
30 Ext.create('Ext.window.Window', {
31 modal: true,
32 width: 600,
33 title: gettext('Fingerprint'),
34 layout: 'form',
35 bodyPadding: '10 0',
36 items: [
37 {
38 xtype: 'textfield',
39 inputId: 'fingerprintField',
40 value: fingerprint,
41 editable: false,
42 },
43 ],
44 buttons: [
45 {
46 xtype: 'button',
47 iconCls: 'fa fa-clipboard',
48 handler: function(b) {
49 var el = document.getElementById('fingerprintField');
50 el.select();
51 document.execCommand("copy");
52 },
53 text: gettext('Copy'),
54 },
55 {
56 text: gettext('Ok'),
57 handler: function() {
58 this.up('window').close();
59 },
60 },
61 ],
62 }).show();
63 },
e584593c
DC
64 },
65
e584593c
DC
66 tools: [
67 {
68 xtype: 'button',
69 reference: 'fpButton',
70 text: gettext('Show Fingerprint'),
71 handler: 'showFingerPrint',
72 disabled: true,
73 },
74 ],
75
e584593c
DC
76 items: [
77 {
b20368ee
DC
78 itemId: 'cpu',
79 iconCls: 'fa fa-fw pmx-itype-icon-processor pmx-icon',
80 title: gettext('CPU usage'),
81 valueField: 'cpu',
82 maxField: 'cpuinfo',
83 renderer: Proxmox.Utils.render_node_cpu_usage,
84 },
85 {
86 itemId: 'wait',
7d3482f5 87 iconCls: 'pmx-icon-size fa fa-fw fa-clock-o',
b20368ee
DC
88 title: gettext('IO delay'),
89 valueField: 'wait',
90 },
91 {
92 xtype: 'box',
93 colspan: 2,
94 padding: '0 0 20 0',
95 },
96 {
97 iconCls: 'fa fa-fw pmx-itype-icon-memory pmx-icon',
98 itemId: 'memory',
99 title: gettext('RAM usage'),
100 valueField: 'memory',
101 maxField: 'memory',
102 renderer: Proxmox.Utils.render_node_size_usage,
103 },
104 {
105 itemId: 'load',
7d3482f5 106 iconCls: 'pmx-icon-size fa fa-fw fa-tasks',
b20368ee
DC
107 title: gettext('Load average'),
108 printBar: false,
109 textField: 'loadavg',
e584593c
DC
110 },
111 {
7d3482f5 112 iconCls: 'pmx-icon-size fa fa-fw fa-hdd-o',
b20368ee
DC
113 itemId: 'rootfs',
114 title: gettext('HD space') + '(root)',
115 valueField: 'root',
116 maxField: 'root',
8af1fa54 117 renderer: ({ used, total }) => Proxmox.Utils.render_size_usage(used, total, true),
e584593c
DC
118 },
119 {
7d3482f5 120 iconCls: 'pmx-icon-size fa fa-fw fa-refresh',
b20368ee
DC
121 itemId: 'swap',
122 printSize: true,
123 title: gettext('SWAP usage'),
124 valueField: 'swap',
125 maxField: 'swap',
126 renderer: Proxmox.Utils.render_node_size_usage,
127 },
128 {
129 xtype: 'box',
130 colspan: 2,
131 padding: '0 0 20 0',
132 },
133 {
134 itemId: 'cpus',
135 colspan: 2,
136 printBar: false,
137 title: gettext('CPU(s)'),
138 textField: 'cpuinfo',
139 renderer: Proxmox.Utils.render_cpu_model,
140 value: '',
141 },
142 {
b20368ee
DC
143 colspan: 2,
144 title: gettext('Kernel Version'),
145 printBar: false,
48792275
GG
146 // TODO: remove with next major and only use newish current-kernel textfield
147 multiField: true,
148 //textField: 'current-kernel',
149 renderer: ({ data }) => {
150 if (!data['current-kernel']) {
151 return data.kversion;
152 }
153 let kernel = data['current-kernel'];
50abd38a 154 let buildDate = kernel.version.match(/\((.+)\)\s*$/)?.[1] ?? 'unknown';
48792275
GG
155 return `${kernel.sysname} ${kernel.release} (${buildDate})`;
156 },
b20368ee 157 value: '',
e584593c 158 },
220f3c1c
GG
159 {
160 colspan: 2,
161 title: gettext('Boot Mode'),
162 printBar: false,
163 textField: 'boot-info',
164 renderer: boot => {
165 if (boot.mode === 'legacy-bios') {
166 return 'Legacy BIOS';
167 } else if (boot.mode === 'efi') {
168 return `EFI${boot.secureboot ? ' (Secure Boot)' : ''}`;
169 }
170 return Proxmox.Utils.unknownText;
171 },
172 value: '',
173 },
4672273f 174 {
6a7b6738 175 xtype: 'pmxNodeInfoRepoStatus',
4672273f 176 itemId: 'repositoryStatus',
d74172bf 177 product: 'Proxmox Backup Server',
6a7b6738 178 repoLink: '#pbsServerAdministration:aptrepositories',
4672273f 179 },
e584593c 180 ],
b20368ee
DC
181
182 updateTitle: function() {
183 var me = this;
184 var uptime = Proxmox.Utils.render_uptime(me.getRecordValue('uptime'));
185 me.setTitle(Proxmox.NodeName + ' (' + gettext('Uptime') + ': ' + uptime + ')');
186 },
187
188 initComponent: function() {
189 let me = this;
190
191 me.rstore = Ext.create('Proxmox.data.ObjectStore', {
192 interval: 3000,
193 url: '/api2/json/nodes/localhost/status',
194 autoStart: true,
195 });
196
197 me.callParent();
198
199 me.mon(me.rstore, 'load', function(store, records, success) {
200 if (!success) {
201 return;
202 }
203
204 let info = me.getRecordValue('info');
205 me.fingerprint = info.fingerprint;
206 me.lookup('fpButton').setDisabled(!me.fingerprint);
207 });
208 me.on('destroy', function() { me.rstore.stopUpdate(); });
209 },
e584593c 210});