]>
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, | |
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 | ||
2bb75d1e FE |
86 | updateRepositoryStatus: function() { |
87 | let me = this; | |
b2f17bfd | 88 | let repoStatus = me.nodeStatus.down('#repositoryStatus'); |
2bb75d1e FE |
89 | |
90 | let nodename = me.pveSelNode.data.node; | |
91 | ||
92 | Proxmox.Utils.API2Request({ | |
93 | url: `/nodes/${nodename}/apt/repositories`, | |
94 | method: 'GET', | |
e950ab26 | 95 | failure: response => Ext.Msg.alert(gettext('Error'), response.htmlStatus), |
b2f17bfd | 96 | success: response => repoStatus.setRepositoryInfo(response.result.data['standard-repos']), |
2bb75d1e FE |
97 | }); |
98 | ||
99 | Proxmox.Utils.API2Request({ | |
100 | url: `/nodes/${nodename}/subscription`, | |
101 | method: 'GET', | |
e950ab26 | 102 | failure: response => Ext.Msg.alert(gettext('Error'), response.htmlStatus), |
2bb75d1e FE |
103 | success: function(response, opts) { |
104 | const res = response.result; | |
e950ab26 | 105 | const subscription = res?.data?.status.toLowerCase() === 'active'; |
b2f17bfd | 106 | repoStatus.setSubscriptionStatus(subscription); |
2bb75d1e FE |
107 | }, |
108 | }); | |
109 | }, | |
110 | ||
e5a857f7 DM |
111 | initComponent: function() { |
112 | var me = this; | |
113 | ||
114 | var nodename = me.pveSelNode.data.node; | |
115 | if (!nodename) { | |
116 | throw "no node name specified"; | |
117 | } | |
118 | ||
119 | if (!me.statusStore) { | |
120 | throw "no status storage specified"; | |
121 | } | |
122 | ||
123 | var rstore = me.statusStore; | |
124 | ||
e5a857f7 DM |
125 | var version_btn = new Ext.Button({ |
126 | text: gettext('Package versions'), | |
8058410f | 127 | handler: function() { |
e7ade592 | 128 | Proxmox.Utils.checked_command(function() { me.showVersions(); }); |
f6710aac | 129 | }, |
e5a857f7 DM |
130 | }); |
131 | ||
5536d678 DC |
132 | var rrdstore = Ext.create('Proxmox.data.RRDStore', { |
133 | rrdurl: "/api2/json/nodes/" + nodename + "/rrddata", | |
f6710aac | 134 | model: 'pve-rrd-node', |
13af4d51 DC |
135 | }); |
136 | ||
2bb75d1e FE |
137 | let nodeStatus = Ext.create('PVE.node.StatusView', { |
138 | xtype: 'pveNodeStatus', | |
139 | rstore: rstore, | |
140 | width: 770, | |
141 | pveSelNode: me.pveSelNode, | |
142 | }); | |
143 | ||
e5a857f7 | 144 | Ext.apply(me, { |
8058410f | 145 | tbar: [version_btn, '->', { xtype: 'proxmoxRRDTypeSelector' }], |
2bb75d1e | 146 | nodeStatus: nodeStatus, |
33f459ca DC |
147 | items: [ |
148 | { | |
149 | xtype: 'container', | |
f73a7334 | 150 | itemId: 'itemcontainer', |
33f459ca | 151 | layout: 'column', |
ed3e711e | 152 | minWidth: 700, |
33f459ca | 153 | defaults: { |
e5457c1e | 154 | minHeight: 325, |
33f459ca | 155 | padding: 5, |
f6710aac | 156 | columnWidth: 1, |
33f459ca DC |
157 | }, |
158 | items: [ | |
2bb75d1e | 159 | nodeStatus, |
33f459ca DC |
160 | { |
161 | xtype: 'proxmoxRRDChart', | |
162 | title: gettext('CPU usage'), | |
f6710aac | 163 | fields: ['cpu', 'iowait'], |
33f459ca | 164 | fieldTitles: [gettext('CPU usage'), gettext('IO delay')], |
cf6b65a2 | 165 | unit: 'percent', |
f6710aac | 166 | store: rrdstore, |
33f459ca DC |
167 | }, |
168 | { | |
169 | xtype: 'proxmoxRRDChart', | |
170 | title: gettext('Server load'), | |
171 | fields: ['loadavg'], | |
172 | fieldTitles: [gettext('Load average')], | |
f6710aac | 173 | store: rrdstore, |
33f459ca DC |
174 | }, |
175 | { | |
176 | xtype: 'proxmoxRRDChart', | |
177 | title: gettext('Memory usage'), | |
f6710aac | 178 | fields: ['memtotal', 'memused'], |
33f459ca | 179 | fieldTitles: [gettext('Total'), gettext('RAM usage')], |
e67d454a TL |
180 | unit: 'bytes', |
181 | powerOfTwo: true, | |
f6710aac | 182 | store: rrdstore, |
33f459ca DC |
183 | }, |
184 | { | |
185 | xtype: 'proxmoxRRDChart', | |
186 | title: gettext('Network traffic'), | |
f6710aac TL |
187 | fields: ['netin', 'netout'], |
188 | store: rrdstore, | |
189 | }, | |
f73a7334 DC |
190 | ], |
191 | listeners: { | |
192 | resize: function(panel) { | |
2874be00 | 193 | Proxmox.Utils.updateColumns(panel); |
f73a7334 DC |
194 | }, |
195 | }, | |
196 | }, | |
33f459ca | 197 | ], |
e5a857f7 | 198 | listeners: { |
6d143caf TL |
199 | activate: function() { |
200 | rstore.setInterval(1000); | |
201 | rstore.startUpdate(); // just to be sure | |
202 | rrdstore.startUpdate(); | |
203 | }, | |
204 | destroy: function() { | |
205 | rstore.setInterval(5000); // don't stop it, it's not ours! | |
206 | rrdstore.stopUpdate(); | |
207 | }, | |
f6710aac | 208 | }, |
e5a857f7 DM |
209 | }); |
210 | ||
2bb75d1e FE |
211 | me.updateRepositoryStatus(); |
212 | ||
e5a857f7 | 213 | me.callParent(); |
f973c5b2 DC |
214 | |
215 | let sp = Ext.state.Manager.getProvider(); | |
216 | me.mon(sp, 'statechange', function(provider, key, value) { | |
217 | if (key !== 'summarycolumns') { | |
218 | return; | |
219 | } | |
2874be00 | 220 | Proxmox.Utils.updateColumns(me.getComponent('itemcontainer')); |
f973c5b2 | 221 | }); |
f6710aac | 222 | }, |
e5a857f7 | 223 | }); |