]> git.proxmox.com Git - proxmox-backup.git/blob - www/panel/NodeInfo.js
run cargo fmt
[proxmox-backup.git] / www / panel / NodeInfo.js
1 Ext.define('PBS.NodeInfoPanel', {
2 extend: 'Proxmox.panel.StatusView',
3 alias: 'widget.pbsNodeInfoPanel',
4
5 height: 300,
6 bodyPadding: '15 5 15 5',
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',
20 padding: '0 10 5 10',
21 },
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 },
64 },
65
66 tools: [
67 {
68 xtype: 'button',
69 reference: 'fpButton',
70 text: gettext('Show Fingerprint'),
71 handler: 'showFingerPrint',
72 disabled: true,
73 },
74 ],
75
76 items: [
77 {
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',
87 iconCls: 'pmx-icon-size fa fa-fw fa-clock-o',
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',
106 iconCls: 'pmx-icon-size fa fa-fw fa-tasks',
107 title: gettext('Load average'),
108 printBar: false,
109 textField: 'loadavg',
110 },
111 {
112 iconCls: 'pmx-icon-size fa fa-fw fa-hdd-o',
113 itemId: 'rootfs',
114 title: gettext('HD space') + '(root)',
115 valueField: 'root',
116 maxField: 'root',
117 renderer: ({ used, total }) => Proxmox.Utils.render_size_usage(used, total, true),
118 },
119 {
120 iconCls: 'pmx-icon-size fa fa-fw fa-refresh',
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 {
143 itemId: 'kversion',
144 colspan: 2,
145 title: gettext('Kernel Version'),
146 printBar: false,
147 textField: 'kversion',
148 value: '',
149 },
150 {
151 xtype: 'pmxNodeInfoRepoStatus',
152 itemId: 'repositoryStatus',
153 product: 'Proxmox Backup Server',
154 repoLink: '#pbsServerAdministration:aptrepositories',
155 },
156 ],
157
158 updateTitle: function() {
159 var me = this;
160 var uptime = Proxmox.Utils.render_uptime(me.getRecordValue('uptime'));
161 me.setTitle(Proxmox.NodeName + ' (' + gettext('Uptime') + ': ' + uptime + ')');
162 },
163
164 initComponent: function() {
165 let me = this;
166
167 me.rstore = Ext.create('Proxmox.data.ObjectStore', {
168 interval: 3000,
169 url: '/api2/json/nodes/localhost/status',
170 autoStart: true,
171 });
172
173 me.callParent();
174
175 me.mon(me.rstore, 'load', function(store, records, success) {
176 if (!success) {
177 return;
178 }
179
180 let info = me.getRecordValue('info');
181 me.fingerprint = info.fingerprint;
182 me.lookup('fpButton').setDisabled(!me.fingerprint);
183 });
184 me.on('destroy', function() { me.rstore.stopUpdate(); });
185 },
186 });