]>
git.proxmox.com Git - pmg-gui.git/blob - js/Dashboard.js
4684a58786fd59b4c3dabaeb88098450f183ab66
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
|| 0;
132 var memory
= item
.data
.memory
|| { used
: 0, total
: 1 };
133 mem
+= (memory
.used
/memory
.total
);
135 var rootfs
= item
.data
.rootfs
|| { used
: 0, total
: 1 };
136 hd
+= (rootfs
.used
/rootfs
.total
);
140 var subscriptionPanel
= me
.lookup('subscription');
141 subscriptionPanel
.setSubStatus(subStatus
);
147 var cpuPanel
= me
.lookup('cpu');
148 cpuPanel
.updateValue(cpu
);
150 var memPanel
= me
.lookup('mem');
151 memPanel
.updateValue(mem
);
153 var hdPanel
= me
.lookup('hd');
154 hdPanel
.updateValue(hd
);
157 init: function(view
) {
159 var sp
= Ext
.state
.Manager
.getProvider();
160 var hours
= sp
.get('dashboard-hours') || 12;
161 me
.setHours(hours
, false);
167 timespan
: 300, // in seconds
168 hours
: 12, // in hours
176 storeid
: 'dash-cluster',
183 extraParams
: { list_single_node
: 1 },
185 url
: '/api2/json/config/cluster/status'
188 load
: 'updateClusterStats'
192 storeid
: 'dash-recent',
200 url
: '/api2/json/statistics/recent',
203 timespan
: '{timespan}'
208 type
: 'number', name
: 'count',
209 convert
: PMG
.Utils
.convert_field_to_per_min
212 type
: 'number', name
: 'count_in',
213 convert
: PMG
.Utils
.convert_field_to_per_min
216 type
: 'number', name
: 'count_out',
217 convert
: PMG
.Utils
.convert_field_to_per_min
220 type
: 'number', name
: 'spam',
221 convert
: PMG
.Utils
.convert_field_to_per_min
224 type
: 'number', name
: 'spam_in',
225 convert
: PMG
.Utils
.convert_field_to_per_min
228 type
: 'number', name
: 'spam_out',
229 convert
: PMG
.Utils
.convert_field_to_per_min
232 type
: 'number', name
: 'virus',
233 convert
: PMG
.Utils
.convert_field_to_per_min
236 type
: 'number', name
: 'virus_in',
237 convert
: PMG
.Utils
.convert_field_to_per_min
239 { type
: 'integer', name
: 'virus_out' },
240 { type
: 'integer', name
: 'bytes_in' },
241 { type
: 'integer', name
: 'bytes_out' },
242 { type
: 'number', name
: 'ptimesum' },
243 { type
: 'date', dateFormat
: 'timestamp', name
: 'time' }
246 load
: 'updateMailStats'
250 storeid
: 'dash-receivers',
258 url
: '/api2/json/statistics/recentreceivers',
264 { type
: 'integer', name
: 'count' },
265 { type
: 'string', name
: 'receiver' }
272 title
: gettext('Dashboard') + ' (' +
273 Ext
.String
.format(gettext('{0} hours'), '{hours}') + ')'
281 bodyPadding
: '20 0 0 20',
292 handler
: 'openDashboardOptions'
302 iconCls
: 'fa fa-tachometer',
303 title
: gettext('E-Mail Volume'),
309 xtype
: 'pmgMiniGraph',
311 store
: '{recentmails}'
317 fieldTitles
: [ gettext('Mails / min') ],
319 colors
: [ '#00617F' ],
332 fieldTitles
: [ gettext('Spam / min') ],
334 colors
: [ '#E67300' ],
356 xtype
: 'pmgMailProcessing',
357 title
: gettext('E-Mail Processing'),
358 iconCls
: 'fa fa-hourglass-half',
362 'bytes_in': '{bytes_in}',
363 'bytes_out': '{bytes_out}',
364 'avg_ptime': '{avg_ptime}'
369 iconCls
: 'fa fa-ticket',
370 title
: 'Subscription',
371 reference
: 'subscription',
372 xtype
: 'pmgSubscriptionInfo',
380 iconCls
: 'fa fa-tasks',
381 title
: gettext('Node Resources'),
382 bodyPadding
: '0 20 0 20',
388 xtype
: 'proxmoxGauge',
389 spriteFontSize
: '20px',
394 title
: gettext('CPU'),
398 title
: gettext('Memory'),
402 title
: gettext('Storage'),
409 iconCls
: 'fa fa-list',
410 title
: gettext('Top Receivers'),
412 bodyPadding
: '20 20 20 20',
424 emptyText
: gettext('No data in database'),
426 // remove all borders/lines/headers
439 dataIndex
: 'receiver',
441 text
: gettext('Receiver')
446 text
: gettext('Count')