]>
git.proxmox.com Git - pmg-gui.git/blob - js/Dashboard.js
2 /*jslint confusion: true*/
3 /* load is a function and string
4 * hours is a number and string
5 * timespan is a number and string
6 * bind is a function and object
7 * handler is a function and string
9 Ext
.define('PMG.Dashboard', {
10 extend
: 'Ext.panel.Panel',
11 xtype
: 'pmgDashboard',
14 xclass
: 'Ext.app.ViewController',
16 openDashboardOptions: function() {
18 var viewModel
= me
.getViewModel();
19 Ext
.create('Ext.window.Window', {
22 title
: gettext('Dashboard Options'),
28 bodyPadding
: '10 10 10 10',
29 defaultButton
: 'savebutton',
31 xtype
: 'proxmoxintegerfield',
38 value
: viewModel
.get('hours'),
39 fieldLabel
: gettext('Hours to show')
42 text
: gettext('Save'),
43 reference
: 'loginButton',
46 var win
= this.up('window');
47 var hours
= win
.down('#hours').getValue();
48 me
.setHours(hours
, true);
56 setHours: function(hours
, setState
) {
58 var viewModel
= me
.getViewModel();
59 viewModel
.set('hours', hours
);
62 Ext
.Array
.forEach(['recentmails', 'receivers'], function(item
) {
63 viewModel
.get(item
).load();
67 var sp
= Ext
.state
.Manager
.getProvider();
68 sp
.set('dashboard-hours', hours
);
72 updateMailStats: function(store
, records
, success
) {
77 var viewModel
= me
.getViewModel();
85 records
.forEach(function(item
) {
86 bytes_in
+= item
.data
.bytes_in
;
87 bytes_out
+= item
.data
.bytes_out
;
89 count
+= (item
.data
.count
*item
.data
.timespan
)/60;
90 ptime
+= item
.data
.ptimesum
;
94 avg_ptime
= (ptime
/count
).toFixed(2);
97 viewModel
.set('bytes_in', Proxmox
.Utils
.format_size(bytes_in
));
98 viewModel
.set('bytes_out', Proxmox
.Utils
.format_size(bytes_out
));
99 viewModel
.set('avg_ptime', avg_ptime
+ " s");
102 updateClusterStats: function(store
, records
, success
) {
107 var viewmodel
= me
.getViewModel();
109 var subStatus
= 2; // 2 = all good, 1 = different leves, 0 = none
115 var count
= records
.length
;
117 records
.forEach(function(item
) {
118 // subscription level check
119 if (subStatus
&& item
.data
.level
) {
120 if (subLevel
!== "" && subLevel
!== item
.data
.level
) {
122 } else if (subLevel
=== "") {
123 subLevel
= item
.data
.level
;
130 cpu
+= item
.data
.cpu
;
131 mem
+= (item
.data
.memory
.used
/item
.data
.memory
.total
);
132 hd
+= (item
.data
.rootfs
.used
/item
.data
.rootfs
.total
);
135 var subscriptionPanel
= me
.lookup('subscription');
136 subscriptionPanel
.setSubStatus(subStatus
);
142 var cpuPanel
= me
.lookup('cpu');
143 cpuPanel
.updateValue(cpu
);
145 var memPanel
= me
.lookup('mem');
146 memPanel
.updateValue(mem
);
148 var hdPanel
= me
.lookup('hd');
149 hdPanel
.updateValue(hd
);
152 init: function(view
) {
154 var sp
= Ext
.state
.Manager
.getProvider();
155 var hours
= sp
.get('dashboard-hours') || 12;
156 me
.setHours(hours
, false);
162 timespan
: 300, // in seconds
163 hours
: 12, // in hours
171 storeid
: 'dash-cluster',
179 url
: '/api2/json/config/cluster/status'
182 load
: 'updateClusterStats'
186 storeid
: 'dash-recent',
194 url
: '/api2/json/statistics/recent',
197 timespan
: '{timespan}'
202 type
: 'number', name
: 'count',
203 convert
: PMG
.Utils
.convert_field_to_per_min
206 type
: 'number', name
: 'count_in',
207 convert
: PMG
.Utils
.convert_field_to_per_min
210 type
: 'number', name
: 'count_out',
211 convert
: PMG
.Utils
.convert_field_to_per_min
214 type
: 'number', name
: 'spam',
215 convert
: PMG
.Utils
.convert_field_to_per_min
218 type
: 'number', name
: 'spam_in',
219 convert
: PMG
.Utils
.convert_field_to_per_min
222 type
: 'number', name
: 'spam_out',
223 convert
: PMG
.Utils
.convert_field_to_per_min
226 type
: 'number', name
: 'virus',
227 convert
: PMG
.Utils
.convert_field_to_per_min
230 type
: 'number', name
: 'virus_in',
231 convert
: PMG
.Utils
.convert_field_to_per_min
233 { type
: 'integer', name
: 'virus_out' },
234 { type
: 'integer', name
: 'bytes_in' },
235 { type
: 'integer', name
: 'bytes_out' },
236 { type
: 'number', name
: 'ptimesum' },
237 { type
: 'date', dateFormat
: 'timestamp', name
: 'time' }
240 load
: 'updateMailStats'
244 storeid
: 'dash-receivers',
252 url
: '/api2/json/statistics/recentreceivers',
258 { type
: 'integer', name
: 'count' },
259 { type
: 'string', name
: 'receiver' }
266 title
: gettext('Dashboard') + ' (' +
267 Ext
.String
.format(gettext('{0} hours'), '{hours}') + ')'
275 bodyPadding
: '20 0 0 20',
286 handler
: 'openDashboardOptions'
296 iconCls
: 'fa fa-tachometer',
297 title
: gettext('E-Mail Volume'),
303 xtype
: 'pmgMiniGraph',
305 store
: '{recentmails}'
311 fieldTitles
: [ gettext('Mails / min') ],
313 colors
: [ '#00617F' ],
326 fieldTitles
: [ gettext('Spam / min') ],
328 colors
: [ '#E67300' ],
350 xtype
: 'pmgMailProcessing',
351 title
: gettext('E-Mail Processing'),
352 iconCls
: 'fa fa-hourglass-half',
357 'out': '{bytes_out}',
358 'ptime': '{avg_ptime}'
363 iconCls
: 'fa fa-ticket',
364 title
: 'Subscription',
365 reference
: 'subscription',
366 xtype
: 'pmgSubscriptionInfo',
374 iconCls
: 'fa fa-tasks',
375 title
: 'Node Resources',
376 bodyPadding
: '0 20 0 20',
382 xtype
: 'proxmoxGauge',
383 spriteFontSize
: '20px',
388 title
: gettext('CPU'),
392 title
: gettext('Memory'),
396 title
: gettext('Storage'),
403 iconCls
: 'fa fa-list',
404 title
: gettext('Top Receivers'),
406 bodyPadding
: '20 20 20 20',
418 emptyText
: gettext('No data in database'),
420 // remove all borders/lines/headers
433 dataIndex
: 'receiver',
435 text
: gettext('Receiver')
440 text
: gettext('Count')