]>
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 | 20 | style: { |
e5a857f7 | 21 | 'white-space': 'pre', |
f6710aac TL |
22 | 'font-family': 'monospace', |
23 | }, | |
e5a857f7 DM |
24 | }); |
25 | ||
26 | var win = Ext.create('Ext.window.Window', { | |
27 | title: gettext('Package versions'), | |
28 | width: 600, | |
43faab18 | 29 | height: 600, |
e5a857f7 DM |
30 | layout: 'fit', |
31 | modal: true, | |
8058410f | 32 | items: [view], |
43faab18 TL |
33 | buttons: [ |
34 | { | |
35 | xtype: 'button', | |
36 | iconCls: 'fa fa-clipboard', | |
37 | handler: function(button) { | |
38 | window.getSelection().selectAllChildren( | |
f6710aac | 39 | document.getElementById('pkgversions'), |
43faab18 TL |
40 | ); |
41 | document.execCommand("copy"); | |
42 | }, | |
43 | text: gettext('Copy'), | |
44 | }, | |
45 | { | |
46 | text: gettext('Ok'), | |
47 | handler: function() { | |
48 | this.up('window').close(); | |
49 | }, | |
50 | }, | |
51 | ], | |
e5a857f7 DM |
52 | }); |
53 | ||
e7ade592 | 54 | Proxmox.Utils.API2Request({ |
e5a857f7 | 55 | waitMsgTarget: me, |
3ddcdadc | 56 | url: `/nodes/${nodename}/apt/versions`, |
e5a857f7 DM |
57 | method: 'GET', |
58 | failure: function(response, opts) { | |
59 | win.close(); | |
60 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
61 | }, | |
62 | success: function(response, opts) { | |
63 | win.show(); | |
3ddcdadc | 64 | let text = ''; |
e5a857f7 | 65 | Ext.Array.each(response.result.data, function(rec) { |
3ddcdadc TL |
66 | let version = "not correctly installed"; |
67 | let pkg = rec.Package; | |
e5a857f7 DM |
68 | if (rec.OldVersion && rec.CurrentState === 'Installed') { |
69 | version = rec.OldVersion; | |
70 | } | |
71 | if (rec.RunningKernel) { | |
3ddcdadc | 72 | text += `${pkg}: ${version} (running kernel: ${rec.RunningKernel})\n`; |
e5a857f7 | 73 | } else if (rec.ManagerVersion) { |
3ddcdadc | 74 | text += `${pkg}: ${version} (running version: ${rec.ManagerVersion})\n`; |
e5a857f7 | 75 | } else { |
3ddcdadc | 76 | text += `${pkg}: ${version}\n`; |
e5a857f7 DM |
77 | } |
78 | }); | |
79 | ||
80 | view.update(Ext.htmlEncode(text)); | |
f6710aac | 81 | }, |
e5a857f7 DM |
82 | }); |
83 | }, | |
84 | ||
2bb75d1e FE |
85 | updateRepositoryStatus: function() { |
86 | let me = this; | |
b2f17bfd | 87 | let repoStatus = me.nodeStatus.down('#repositoryStatus'); |
2bb75d1e FE |
88 | |
89 | let nodename = me.pveSelNode.data.node; | |
90 | ||
91 | Proxmox.Utils.API2Request({ | |
92 | url: `/nodes/${nodename}/apt/repositories`, | |
93 | method: 'GET', | |
e950ab26 | 94 | failure: response => Ext.Msg.alert(gettext('Error'), response.htmlStatus), |
b2f17bfd | 95 | success: response => repoStatus.setRepositoryInfo(response.result.data['standard-repos']), |
2bb75d1e FE |
96 | }); |
97 | ||
98 | Proxmox.Utils.API2Request({ | |
99 | url: `/nodes/${nodename}/subscription`, | |
100 | method: 'GET', | |
e950ab26 | 101 | failure: response => Ext.Msg.alert(gettext('Error'), response.htmlStatus), |
2bb75d1e FE |
102 | success: function(response, opts) { |
103 | const res = response.result; | |
e950ab26 | 104 | const subscription = res?.data?.status.toLowerCase() === 'active'; |
b2f17bfd | 105 | repoStatus.setSubscriptionStatus(subscription); |
2bb75d1e FE |
106 | }, |
107 | }); | |
108 | }, | |
109 | ||
e5a857f7 DM |
110 | initComponent: function() { |
111 | var me = this; | |
112 | ||
113 | var nodename = me.pveSelNode.data.node; | |
114 | if (!nodename) { | |
115 | throw "no node name specified"; | |
116 | } | |
117 | ||
118 | if (!me.statusStore) { | |
119 | throw "no status storage specified"; | |
120 | } | |
121 | ||
122 | var rstore = me.statusStore; | |
123 | ||
e5a857f7 DM |
124 | var version_btn = new Ext.Button({ |
125 | text: gettext('Package versions'), | |
8058410f | 126 | handler: function() { |
e7ade592 | 127 | Proxmox.Utils.checked_command(function() { me.showVersions(); }); |
f6710aac | 128 | }, |
e5a857f7 DM |
129 | }); |
130 | ||
5536d678 DC |
131 | var rrdstore = Ext.create('Proxmox.data.RRDStore', { |
132 | rrdurl: "/api2/json/nodes/" + nodename + "/rrddata", | |
f6710aac | 133 | model: 'pve-rrd-node', |
13af4d51 DC |
134 | }); |
135 | ||
2bb75d1e FE |
136 | let nodeStatus = Ext.create('PVE.node.StatusView', { |
137 | xtype: 'pveNodeStatus', | |
138 | rstore: rstore, | |
139 | width: 770, | |
140 | pveSelNode: me.pveSelNode, | |
141 | }); | |
142 | ||
e5a857f7 | 143 | Ext.apply(me, { |
8058410f | 144 | tbar: [version_btn, '->', { xtype: 'proxmoxRRDTypeSelector' }], |
2bb75d1e | 145 | nodeStatus: nodeStatus, |
33f459ca DC |
146 | items: [ |
147 | { | |
148 | xtype: 'container', | |
f73a7334 | 149 | itemId: 'itemcontainer', |
33f459ca | 150 | layout: 'column', |
ed3e711e | 151 | minWidth: 700, |
33f459ca | 152 | defaults: { |
1f1d8bf3 | 153 | minHeight: 350, |
33f459ca | 154 | padding: 5, |
f6710aac | 155 | columnWidth: 1, |
33f459ca DC |
156 | }, |
157 | items: [ | |
2bb75d1e | 158 | nodeStatus, |
33f459ca DC |
159 | { |
160 | xtype: 'proxmoxRRDChart', | |
161 | title: gettext('CPU usage'), | |
f6710aac | 162 | fields: ['cpu', 'iowait'], |
33f459ca | 163 | fieldTitles: [gettext('CPU usage'), gettext('IO delay')], |
cf6b65a2 | 164 | unit: 'percent', |
f6710aac | 165 | store: rrdstore, |
33f459ca DC |
166 | }, |
167 | { | |
168 | xtype: 'proxmoxRRDChart', | |
169 | title: gettext('Server load'), | |
170 | fields: ['loadavg'], | |
171 | fieldTitles: [gettext('Load average')], | |
f6710aac | 172 | store: rrdstore, |
33f459ca DC |
173 | }, |
174 | { | |
175 | xtype: 'proxmoxRRDChart', | |
176 | title: gettext('Memory usage'), | |
f6710aac | 177 | fields: ['memtotal', 'memused'], |
33f459ca | 178 | fieldTitles: [gettext('Total'), gettext('RAM usage')], |
e67d454a TL |
179 | unit: 'bytes', |
180 | powerOfTwo: true, | |
f6710aac | 181 | store: rrdstore, |
33f459ca DC |
182 | }, |
183 | { | |
184 | xtype: 'proxmoxRRDChart', | |
185 | title: gettext('Network traffic'), | |
f6710aac TL |
186 | fields: ['netin', 'netout'], |
187 | store: rrdstore, | |
188 | }, | |
f73a7334 DC |
189 | ], |
190 | listeners: { | |
191 | resize: function(panel) { | |
2874be00 | 192 | Proxmox.Utils.updateColumns(panel); |
f73a7334 DC |
193 | }, |
194 | }, | |
195 | }, | |
33f459ca | 196 | ], |
e5a857f7 | 197 | listeners: { |
6d143caf TL |
198 | activate: function() { |
199 | rstore.setInterval(1000); | |
200 | rstore.startUpdate(); // just to be sure | |
201 | rrdstore.startUpdate(); | |
202 | }, | |
203 | destroy: function() { | |
204 | rstore.setInterval(5000); // don't stop it, it's not ours! | |
205 | rrdstore.stopUpdate(); | |
206 | }, | |
f6710aac | 207 | }, |
e5a857f7 DM |
208 | }); |
209 | ||
2bb75d1e FE |
210 | me.updateRepositoryStatus(); |
211 | ||
e5a857f7 | 212 | me.callParent(); |
f973c5b2 DC |
213 | |
214 | let sp = Ext.state.Manager.getProvider(); | |
215 | me.mon(sp, 'statechange', function(provider, key, value) { | |
216 | if (key !== 'summarycolumns') { | |
217 | return; | |
218 | } | |
2874be00 | 219 | Proxmox.Utils.updateColumns(me.getComponent('itemcontainer')); |
f973c5b2 | 220 | }); |
f6710aac | 221 | }, |
e5a857f7 | 222 | }); |