]>
Commit | Line | Data |
---|---|---|
e5a857f7 DM |
1 | Ext.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, | |
33f459ca | 18 | padding: 5, |
e5a857f7 DM |
19 | style: { |
20 | 'background-color': 'white', | |
21 | 'white-space': 'pre', | |
33f459ca | 22 | 'font-family': 'monospace' |
e5a857f7 DM |
23 | } |
24 | }); | |
25 | ||
26 | var win = Ext.create('Ext.window.Window', { | |
27 | title: gettext('Package versions'), | |
28 | width: 600, | |
29 | height: 400, | |
30 | layout: 'fit', | |
31 | modal: true, | |
86d31227 | 32 | items: [ view ] |
e5a857f7 DM |
33 | }); |
34 | ||
e7ade592 | 35 | Proxmox.Utils.API2Request({ |
e5a857f7 | 36 | waitMsgTarget: me, |
3ddcdadc | 37 | url: `/nodes/${nodename}/apt/versions`, |
e5a857f7 DM |
38 | method: 'GET', |
39 | failure: function(response, opts) { | |
40 | win.close(); | |
41 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
42 | }, | |
43 | success: function(response, opts) { | |
44 | win.show(); | |
3ddcdadc | 45 | let text = ''; |
e5a857f7 | 46 | Ext.Array.each(response.result.data, function(rec) { |
3ddcdadc TL |
47 | let version = "not correctly installed"; |
48 | let pkg = rec.Package; | |
e5a857f7 DM |
49 | if (rec.OldVersion && rec.CurrentState === 'Installed') { |
50 | version = rec.OldVersion; | |
51 | } | |
52 | if (rec.RunningKernel) { | |
3ddcdadc | 53 | text += `${pkg}: ${version} (running kernel: ${rec.RunningKernel})\n`; |
e5a857f7 | 54 | } else if (rec.ManagerVersion) { |
3ddcdadc | 55 | text += `${pkg}: ${version} (running version: ${rec.ManagerVersion})\n`; |
e5a857f7 | 56 | } else { |
3ddcdadc | 57 | text += `${pkg}: ${version}\n`; |
e5a857f7 DM |
58 | } |
59 | }); | |
60 | ||
61 | view.update(Ext.htmlEncode(text)); | |
62 | } | |
63 | }); | |
64 | }, | |
65 | ||
66 | initComponent: function() { | |
67 | var me = this; | |
68 | ||
69 | var nodename = me.pveSelNode.data.node; | |
70 | if (!nodename) { | |
71 | throw "no node name specified"; | |
72 | } | |
73 | ||
74 | if (!me.statusStore) { | |
75 | throw "no status storage specified"; | |
76 | } | |
77 | ||
78 | var rstore = me.statusStore; | |
79 | ||
e5a857f7 DM |
80 | var version_btn = new Ext.Button({ |
81 | text: gettext('Package versions'), | |
82 | handler: function(){ | |
e7ade592 | 83 | Proxmox.Utils.checked_command(function() { me.showVersions(); }); |
e5a857f7 DM |
84 | } |
85 | }); | |
86 | ||
5536d678 DC |
87 | var rrdstore = Ext.create('Proxmox.data.RRDStore', { |
88 | rrdurl: "/api2/json/nodes/" + nodename + "/rrddata", | |
89 | model: 'pve-rrd-node' | |
13af4d51 DC |
90 | }); |
91 | ||
e5a857f7 | 92 | Ext.apply(me, { |
ce7eeea1 | 93 | tbar: [version_btn, '->', { xtype: 'proxmoxRRDTypeSelector' } ], |
33f459ca DC |
94 | items: [ |
95 | { | |
96 | xtype: 'container', | |
f73a7334 | 97 | itemId: 'itemcontainer', |
33f459ca | 98 | layout: 'column', |
ed3e711e | 99 | minWidth: 700, |
33f459ca DC |
100 | defaults: { |
101 | minHeight: 320, | |
102 | padding: 5, | |
f73a7334 | 103 | columnWidth: 1 |
33f459ca DC |
104 | }, |
105 | items: [ | |
106 | { | |
107 | xtype: 'pveNodeStatus', | |
108 | rstore: rstore, | |
109 | width: 770, | |
110 | pveSelNode: me.pveSelNode | |
111 | }, | |
112 | { | |
113 | xtype: 'proxmoxRRDChart', | |
114 | title: gettext('CPU usage'), | |
115 | fields: ['cpu','iowait'], | |
116 | fieldTitles: [gettext('CPU usage'), gettext('IO delay')], | |
117 | store: rrdstore | |
118 | }, | |
119 | { | |
120 | xtype: 'proxmoxRRDChart', | |
121 | title: gettext('Server load'), | |
122 | fields: ['loadavg'], | |
123 | fieldTitles: [gettext('Load average')], | |
124 | store: rrdstore | |
125 | }, | |
126 | { | |
127 | xtype: 'proxmoxRRDChart', | |
128 | title: gettext('Memory usage'), | |
129 | fields: ['memtotal','memused'], | |
130 | fieldTitles: [gettext('Total'), gettext('RAM usage')], | |
131 | store: rrdstore | |
132 | }, | |
133 | { | |
134 | xtype: 'proxmoxRRDChart', | |
135 | title: gettext('Network traffic'), | |
136 | fields: ['netin','netout'], | |
137 | store: rrdstore | |
138 | } | |
f73a7334 DC |
139 | ], |
140 | listeners: { | |
141 | resize: function(panel) { | |
142 | PVE.Utils.updateColumns(panel); | |
143 | }, | |
144 | }, | |
145 | }, | |
33f459ca | 146 | ], |
e5a857f7 | 147 | listeners: { |
6d143caf TL |
148 | activate: function() { |
149 | rstore.setInterval(1000); | |
150 | rstore.startUpdate(); // just to be sure | |
151 | rrdstore.startUpdate(); | |
152 | }, | |
153 | destroy: function() { | |
154 | rstore.setInterval(5000); // don't stop it, it's not ours! | |
155 | rrdstore.stopUpdate(); | |
156 | }, | |
e5a857f7 DM |
157 | } |
158 | }); | |
159 | ||
160 | me.callParent(); | |
f973c5b2 DC |
161 | |
162 | let sp = Ext.state.Manager.getProvider(); | |
163 | me.mon(sp, 'statechange', function(provider, key, value) { | |
164 | if (key !== 'summarycolumns') { | |
165 | return; | |
166 | } | |
167 | PVE.Utils.updateColumns(me.getComponent('itemcontainer')); | |
168 | }); | |
e5a857f7 DM |
169 | } |
170 | }); |