]>
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
.getStore(item
).reload();
67 var sp
= Ext
.state
.Manager
.getProvider();
68 sp
.set('dashboard-hours', hours
);
72 updateMailStats: function(store
, records
, success
) {
77 var viewModel
= me
.getViewModel();
83 var avg_ptime
= 'N/A';
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) + " s";
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
);
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',
178 extraParams
: { list_single_node
: 1 },
180 url
: '/api2/json/config/cluster/status'
183 load
: 'updateClusterStats'
187 storeid
: 'dash-recent',
195 url
: '/api2/json/statistics/recent',
198 timespan
: '{timespan}'
203 type
: 'number', name
: 'count',
204 convert
: PMG
.Utils
.convert_field_to_per_min
207 type
: 'number', name
: 'count_in',
208 convert
: PMG
.Utils
.convert_field_to_per_min
211 type
: 'number', name
: 'count_out',
212 convert
: PMG
.Utils
.convert_field_to_per_min
215 type
: 'number', name
: 'spam',
216 convert
: PMG
.Utils
.convert_field_to_per_min
219 type
: 'number', name
: 'spam_in',
220 convert
: PMG
.Utils
.convert_field_to_per_min
223 type
: 'number', name
: 'spam_out',
224 convert
: PMG
.Utils
.convert_field_to_per_min
227 type
: 'number', name
: 'virus',
228 convert
: PMG
.Utils
.convert_field_to_per_min
231 type
: 'number', name
: 'virus_in',
232 convert
: PMG
.Utils
.convert_field_to_per_min
234 { type
: 'integer', name
: 'virus_out' },
235 { type
: 'integer', name
: 'bytes_in' },
236 { type
: 'integer', name
: 'bytes_out' },
237 { type
: 'number', name
: 'ptimesum' },
238 { type
: 'date', dateFormat
: 'timestamp', name
: 'time' }
241 load
: 'updateMailStats'
245 storeid
: 'dash-receivers',
253 url
: '/api2/json/statistics/recentreceivers',
259 { type
: 'integer', name
: 'count' },
260 { type
: 'string', name
: 'receiver' }
267 title
: gettext('Dashboard') + ' (' +
268 Ext
.String
.format(gettext('{0} hours'), '{hours}') + ')'
276 bodyPadding
: '20 0 0 20',
287 handler
: 'openDashboardOptions'
297 iconCls
: 'fa fa-tachometer',
298 title
: gettext('E-Mail Volume'),
304 xtype
: 'pmgMiniGraph',
306 store
: '{recentmails}'
312 fieldTitles
: [ gettext('Mails / min') ],
314 colors
: [ '#00617F' ],
327 fieldTitles
: [ gettext('Spam / min') ],
329 colors
: [ '#E67300' ],
351 xtype
: 'pmgMailProcessing',
352 title
: gettext('E-Mail Processing'),
353 iconCls
: 'fa fa-hourglass-half',
357 'bytes_in': '{bytes_in}',
358 'bytes_out': '{bytes_out}',
359 'avg_ptime': '{avg_ptime}'
364 iconCls
: 'fa fa-ticket',
365 title
: 'Subscription',
366 reference
: 'subscription',
367 xtype
: 'pmgSubscriptionInfo',
375 iconCls
: 'fa fa-tasks',
376 title
: 'Node Resources',
377 bodyPadding
: '0 20 0 20',
383 xtype
: 'proxmoxGauge',
384 spriteFontSize
: '20px',
389 title
: gettext('CPU'),
393 title
: gettext('Memory'),
397 title
: gettext('Storage'),
404 iconCls
: 'fa fa-list',
405 title
: gettext('Top Receivers'),
407 bodyPadding
: '20 20 20 20',
419 emptyText
: gettext('No data in database'),
421 // remove all borders/lines/headers
434 dataIndex
: 'receiver',
436 text
: gettext('Receiver')
441 text
: gettext('Count')