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