]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/node/Summary.js
ui: use byte unit and power-of-two base for memory rrd graphs
[pve-manager.git] / www / manager6 / node / Summary.js
CommitLineData
e5a857f7
DM
1Ext.define('PVE.node.Summary', {
2 extend: 'Ext.panel.Panel',
3 alias: 'widget.pveNodeSummary',
4
355ac51e 5 scrollable: true,
33f459ca 6 bodyPadding: 5,
355ac51e 7
e5a857f7
DM
8 showVersions: function() {
9 var me = this;
10
11 // Note: we use simply text/html here, because ExtJS grid has problems
12 // with cut&paste
13
14 var nodename = me.pveSelNode.data.node;
15
16 var view = Ext.createWidget('component', {
17 autoScroll: true,
43faab18 18 id: 'pkgversions',
33f459ca 19 padding: 5,
e5a857f7
DM
20 style: {
21 'background-color': 'white',
22 'white-space': 'pre',
f6710aac
TL
23 'font-family': 'monospace',
24 },
e5a857f7
DM
25 });
26
27 var win = Ext.create('Ext.window.Window', {
28 title: gettext('Package versions'),
29 width: 600,
43faab18 30 height: 600,
e5a857f7
DM
31 layout: 'fit',
32 modal: true,
8058410f 33 items: [view],
43faab18
TL
34 buttons: [
35 {
36 xtype: 'button',
37 iconCls: 'fa fa-clipboard',
38 handler: function(button) {
39 window.getSelection().selectAllChildren(
f6710aac 40 document.getElementById('pkgversions'),
43faab18
TL
41 );
42 document.execCommand("copy");
43 },
44 text: gettext('Copy'),
45 },
46 {
47 text: gettext('Ok'),
48 handler: function() {
49 this.up('window').close();
50 },
51 },
52 ],
e5a857f7
DM
53 });
54
e7ade592 55 Proxmox.Utils.API2Request({
e5a857f7 56 waitMsgTarget: me,
3ddcdadc 57 url: `/nodes/${nodename}/apt/versions`,
e5a857f7
DM
58 method: 'GET',
59 failure: function(response, opts) {
60 win.close();
61 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
62 },
63 success: function(response, opts) {
64 win.show();
3ddcdadc 65 let text = '';
e5a857f7 66 Ext.Array.each(response.result.data, function(rec) {
3ddcdadc
TL
67 let version = "not correctly installed";
68 let pkg = rec.Package;
e5a857f7
DM
69 if (rec.OldVersion && rec.CurrentState === 'Installed') {
70 version = rec.OldVersion;
71 }
72 if (rec.RunningKernel) {
3ddcdadc 73 text += `${pkg}: ${version} (running kernel: ${rec.RunningKernel})\n`;
e5a857f7 74 } else if (rec.ManagerVersion) {
3ddcdadc 75 text += `${pkg}: ${version} (running version: ${rec.ManagerVersion})\n`;
e5a857f7 76 } else {
3ddcdadc 77 text += `${pkg}: ${version}\n`;
e5a857f7
DM
78 }
79 });
80
81 view.update(Ext.htmlEncode(text));
f6710aac 82 },
e5a857f7
DM
83 });
84 },
85
86 initComponent: function() {
87 var me = this;
88
89 var nodename = me.pveSelNode.data.node;
90 if (!nodename) {
91 throw "no node name specified";
92 }
93
94 if (!me.statusStore) {
95 throw "no status storage specified";
96 }
97
98 var rstore = me.statusStore;
99
e5a857f7
DM
100 var version_btn = new Ext.Button({
101 text: gettext('Package versions'),
8058410f 102 handler: function() {
e7ade592 103 Proxmox.Utils.checked_command(function() { me.showVersions(); });
f6710aac 104 },
e5a857f7
DM
105 });
106
5536d678
DC
107 var rrdstore = Ext.create('Proxmox.data.RRDStore', {
108 rrdurl: "/api2/json/nodes/" + nodename + "/rrddata",
f6710aac 109 model: 'pve-rrd-node',
13af4d51
DC
110 });
111
e5a857f7 112 Ext.apply(me, {
8058410f 113 tbar: [version_btn, '->', { xtype: 'proxmoxRRDTypeSelector' }],
33f459ca
DC
114 items: [
115 {
116 xtype: 'container',
f73a7334 117 itemId: 'itemcontainer',
33f459ca 118 layout: 'column',
ed3e711e 119 minWidth: 700,
33f459ca
DC
120 defaults: {
121 minHeight: 320,
122 padding: 5,
f6710aac 123 columnWidth: 1,
33f459ca
DC
124 },
125 items: [
126 {
127 xtype: 'pveNodeStatus',
128 rstore: rstore,
129 width: 770,
f6710aac 130 pveSelNode: me.pveSelNode,
33f459ca
DC
131 },
132 {
133 xtype: 'proxmoxRRDChart',
134 title: gettext('CPU usage'),
f6710aac 135 fields: ['cpu', 'iowait'],
33f459ca 136 fieldTitles: [gettext('CPU usage'), gettext('IO delay')],
f6710aac 137 store: rrdstore,
33f459ca
DC
138 },
139 {
140 xtype: 'proxmoxRRDChart',
141 title: gettext('Server load'),
142 fields: ['loadavg'],
143 fieldTitles: [gettext('Load average')],
f6710aac 144 store: rrdstore,
33f459ca
DC
145 },
146 {
147 xtype: 'proxmoxRRDChart',
148 title: gettext('Memory usage'),
f6710aac 149 fields: ['memtotal', 'memused'],
33f459ca 150 fieldTitles: [gettext('Total'), gettext('RAM usage')],
e67d454a
TL
151 unit: 'bytes',
152 powerOfTwo: true,
f6710aac 153 store: rrdstore,
33f459ca
DC
154 },
155 {
156 xtype: 'proxmoxRRDChart',
157 title: gettext('Network traffic'),
f6710aac
TL
158 fields: ['netin', 'netout'],
159 store: rrdstore,
160 },
f73a7334
DC
161 ],
162 listeners: {
163 resize: function(panel) {
164 PVE.Utils.updateColumns(panel);
165 },
166 },
167 },
33f459ca 168 ],
e5a857f7 169 listeners: {
6d143caf
TL
170 activate: function() {
171 rstore.setInterval(1000);
172 rstore.startUpdate(); // just to be sure
173 rrdstore.startUpdate();
174 },
175 destroy: function() {
176 rstore.setInterval(5000); // don't stop it, it's not ours!
177 rrdstore.stopUpdate();
178 },
f6710aac 179 },
e5a857f7
DM
180 });
181
182 me.callParent();
f973c5b2
DC
183
184 let sp = Ext.state.Manager.getProvider();
185 me.mon(sp, 'statechange', function(provider, key, value) {
186 if (key !== 'summarycolumns') {
187 return;
188 }
189 PVE.Utils.updateColumns(me.getComponent('itemcontainer'));
190 });
f6710aac 191 },
e5a857f7 192});