]>
git.proxmox.com Git - pmg-gui.git/blob - js/Dashboard.js
4fc35fd0db8f0796cde3444f1c267cba0de7366d
2 Ext
.define('PMG.Dashboard', {
3 extend
: 'Ext.panel.Panel',
7 xclass
: 'Ext.app.ViewController',
9 openDashboardOptions: function() {
11 var viewModel
= me
.getViewModel();
12 Ext
.create('Ext.window.Window', {
15 title
: gettext('Dashboard Options'),
22 defaultButton
: 'savebutton',
24 xtype
: 'proxmoxintegerfield',
31 value
: viewModel
.get('hours'),
32 fieldLabel
: gettext('Hours to show')
35 text
: gettext('Save'),
36 reference
: 'loginButton',
39 var win
= this.up('window');
40 var hours
= win
.down('#hours').getValue();
41 me
.setHours(hours
, true);
49 setHours: function(hours
, setState
) {
51 var viewModel
= me
.getViewModel();
52 viewModel
.set('hours', hours
);
55 Ext
.Array
.forEach(['recentmails', 'receivers'], function(item
) {
56 viewModel
.get(item
).load();
60 var sp
= Ext
.state
.Manager
.getProvider();
61 sp
.set('dashboard-hours', hours
);
65 updateMailStats: function(store
, records
, success
) {
70 var viewModel
= me
.getViewModel();
78 records
.forEach(function(item
) {
79 bytes_in
+= item
.data
.bytes_in
;
80 bytes_out
+= item
.data
.bytes_out
;
82 count
+= (item
.data
.count
*item
.data
.timespan
)/60;
83 ptime
+= item
.data
.ptimesum
;
87 avg_ptime
= (ptime
/count
).toFixed(2);
90 viewModel
.set('bytes_in', Proxmox
.Utils
.format_size(bytes_in
));
91 viewModel
.set('bytes_out', Proxmox
.Utils
.format_size(bytes_out
));
92 viewModel
.set('avg_ptime', avg_ptime
+ " s");
95 updateClusterStats: function(store
, records
, success
) {
100 var viewmodel
= me
.getViewModel();
102 var subStatus
= 2; // 2 = all good, 1 = different leves, 0 = none
108 var count
= records
.length
;
110 records
.forEach(function(item
) {
111 // subscription level check
112 if (subStatus
&& item
.data
.level
) {
113 if (subLevel
!== "" && subLevel
!== item
.data
.level
) {
115 } else if (subLevel
=== "") {
116 subLevel
= item
.data
.level
;
123 cpu
+= item
.data
.cpu
;
124 mem
+= (item
.data
.memory
.used
/item
.data
.memory
.total
);
125 hd
+= (item
.data
.rootfs
.used
/item
.data
.rootfs
.total
);
128 var subscriptionPanel
= me
.lookup('subscription');
129 subscriptionPanel
.setSubStatus(subStatus
);
135 var cpuPanel
= me
.lookup('cpu');
136 cpuPanel
.updateValue(cpu
);
138 var memPanel
= me
.lookup('mem')
139 memPanel
.updateValue(mem
);
141 var hdPanel
= me
.lookup('hd')
142 hdPanel
.updateValue(hd
);
145 init: function(view
) {
147 var sp
= Ext
.state
.Manager
.getProvider();
148 var hours
= sp
.get('dashboard-hours') || 12;
149 me
.setHours(hours
, false);
155 timespan
: 300, // in seconds
156 hours
: 12, // in hours
164 storeid
: 'dash-cluster',
172 url
: '/api2/json/config/cluster/status'
175 load
: 'updateClusterStats'
179 storeid
: 'dash-recent',
187 url
: '/api2/json/statistics/recent',
190 timespan
: '{timespan}'
195 type
: 'number', name
: 'count',
196 convert
: PMG
.Utils
.convert_field_to_per_min
199 type
: 'number', name
: 'count_in',
200 convert
: PMG
.Utils
.convert_field_to_per_min
203 type
: 'number', name
: 'count_out',
204 convert
: PMG
.Utils
.convert_field_to_per_min
207 type
: 'number', name
: 'spam',
208 convert
: PMG
.Utils
.convert_field_to_per_min
211 type
: 'number', name
: 'spam_in',
212 convert
: PMG
.Utils
.convert_field_to_per_min
215 type
: 'number', name
: 'spam_out',
216 convert
: PMG
.Utils
.convert_field_to_per_min
219 type
: 'number', name
: 'virus',
220 convert
: PMG
.Utils
.convert_field_to_per_min
223 type
: 'number', name
: 'virus_in',
224 convert
: PMG
.Utils
.convert_field_to_per_min
226 { type
: 'integer', name
: 'virus_out' },
227 { type
: 'integer', name
: 'bytes_in' },
228 { type
: 'integer', name
: 'bytes_out' },
229 { type
: 'number', name
: 'ptimesum' },
230 { type
: 'date', dateFormat
: 'timestamp', name
: 'time' }
233 load
: 'updateMailStats'
237 storeid
: 'dash-receivers',
245 url
: '/api2/json/statistics/recentreceivers',
251 { type
: 'integer', name
: 'count' },
252 { type
: 'string', name
: 'receiver' }
259 title
: gettext('Dashboard') + ' (' +
260 Ext
.String
.format(gettext('{0} hours'), '{hours}') + ')'
266 bodyPadding
: '20 0 0 20',
277 handler
: 'openDashboardOptions'
287 iconCls
: 'fa fa-tachometer',
288 title
: gettext('E-Mail Volume'),
294 xtype
: 'pmgMiniGraph',
296 store
: '{recentmails}'
302 fieldTitles
: [ gettext('Mails / min') ],
304 colors
: [ '#00617F' ],
317 fieldTitles
: [ gettext('Spam / min') ],
319 colors
: [ '#E67300' ],
341 xtype
: 'pmgMailProcessing',
342 title
: gettext('E-Mail Processing'),
343 iconCls
: 'fa fa-hourglass-half',
348 'out': '{bytes_out}',
349 'ptime': '{avg_ptime}'
354 iconCls
: 'fa fa-ticket',
355 title
: 'Subscription',
356 reference
: 'subscription',
357 xtype
: 'pmgSubscriptionInfo',
365 iconCls
: 'fa fa-tasks',
366 title
: 'Node Resources',
367 bodyPadding
: '0 20 0 20',
373 xtype
: 'proxmoxGauge',
374 spriteFontSize
: '20px',
379 title
: gettext('CPU'),
383 title
: gettext('Memory'),
387 title
: gettext('Storage'),
394 iconCls
: 'fa fa-list',
395 title
: gettext('Top Receivers'),
409 emptyText
: gettext('No data in database'),
411 // remove all borders/lines/headers
424 dataIndex
: 'receiver',
426 text
: gettext('Receiver')
431 text
: gettext('Count')