]>
git.proxmox.com Git - pmg-gui.git/blob - js/Dashboard.js
1 Ext
.define('PMG.Dashboard', {
2 extend
: 'Ext.panel.Panel',
6 xclass
: 'Ext.app.ViewController',
8 openDashboardOptions: function() {
10 var viewModel
= me
.getViewModel();
11 Ext
.create('Ext.window.Window', {
14 title
: gettext('Dashboard Options'),
21 defaultButton
: 'savebutton',
23 xtype
: 'proxmoxintegerfield',
30 value
: viewModel
.get('hours'),
31 fieldLabel
: gettext('Hours to show')
34 text
: gettext('Save'),
35 reference
: 'loginButton',
38 var win
= this.up('window');
39 var hours
= win
.down('#hours').getValue();
40 me
.setHours(hours
, true);
48 setHours: function(hours
, setState
) {
50 var viewModel
= me
.getViewModel();
51 viewModel
.set('hours', hours
);
54 Ext
.Array
.forEach(['recentmails', 'receivers'], function(item
) {
55 viewModel
.get(item
).load();
59 var sp
= Ext
.state
.Manager
.getProvider();
60 sp
.set('dashboard-hours', hours
);
64 updateMailStats: function(store
, records
, success
) {
69 var viewModel
= me
.getViewModel();
77 records
.forEach(function(item
) {
78 bytes_in
+= item
.data
.bytes_in
;
79 bytes_out
+= item
.data
.bytes_out
;
81 count
+= (item
.data
.count
*item
.data
.timespan
)/60;
82 ptime
+= item
.data
.ptimesum
;
86 avg_ptime
= (ptime
/count
).toFixed(2);
89 viewModel
.set('bytes_in', Proxmox
.Utils
.format_size(bytes_in
));
90 viewModel
.set('bytes_out', Proxmox
.Utils
.format_size(bytes_out
));
91 viewModel
.set('avg_ptime', avg_ptime
+ " s");
94 updateClusterStats: function(store
, records
, success
) {
99 var viewmodel
= me
.getViewModel();
101 var subStatus
= 2; // 2 = all good, 1 = different leves, 0 = none
107 var count
= records
.length
;
109 records
.forEach(function(item
) {
110 // subscription level check
111 if (subStatus
&& item
.data
.level
) {
112 if (subLevel
!== "" && subLevel
!== item
.data
.level
) {
114 } else if (subLevel
=== "") {
115 subLevel
= item
.data
.level
;
122 cpu
+= item
.data
.cpu
;
123 mem
+= (item
.data
.memory
.used
/item
.data
.memory
.total
);
124 hd
+= (item
.data
.rootfs
.used
/item
.data
.rootfs
.total
);
127 var subscriptionPanel
= me
.lookup('subscription');
128 subscriptionPanel
.setSubStatus(subStatus
);
134 var cpuPanel
= me
.lookup('cpu');
135 cpuPanel
.updateValue(cpu
);
137 var memPanel
= me
.lookup('mem')
138 memPanel
.updateValue(mem
);
140 var hdPanel
= me
.lookup('hd')
141 hdPanel
.updateValue(hd
);
144 init: function(view
) {
146 var sp
= Ext
.state
.Manager
.getProvider();
147 var hours
= sp
.get('dashboard-hours') || 12;
148 me
.setHours(hours
, false);
154 timespan
: 300, // in seconds
155 hours
: 12, // in hours
163 storeid
: 'dash-cluster',
171 url
: '/api2/json/config/cluster/status'
174 load
: 'updateClusterStats'
178 storeid
: 'dash-recent',
186 url
: '/api2/json/statistics/recent',
189 timespan
: '{timespan}'
194 type
: 'number', name
: 'count',
195 convert
: PMG
.Utils
.convert_field_to_per_min
198 type
: 'number', name
: 'count_in',
199 convert
: PMG
.Utils
.convert_field_to_per_min
202 type
: 'number', name
: 'count_out',
203 convert
: PMG
.Utils
.convert_field_to_per_min
206 type
: 'number', name
: 'spam',
207 convert
: PMG
.Utils
.convert_field_to_per_min
210 type
: 'number', name
: 'spam_in',
211 convert
: PMG
.Utils
.convert_field_to_per_min
214 type
: 'number', name
: 'spam_out',
215 convert
: PMG
.Utils
.convert_field_to_per_min
218 type
: 'number', name
: 'virus',
219 convert
: PMG
.Utils
.convert_field_to_per_min
222 type
: 'number', name
: 'virus_in',
223 convert
: PMG
.Utils
.convert_field_to_per_min
225 { type
: 'integer', name
: 'virus_out' },
226 { type
: 'integer', name
: 'bytes_in' },
227 { type
: 'integer', name
: 'bytes_out' },
228 { type
: 'number', name
: 'ptimesum' },
229 { type
: 'date', dateFormat
: 'timestamp', name
: 'time' }
232 load
: 'updateMailStats'
236 storeid
: 'dash-receivers',
244 url
: '/api2/json/statistics/recentreceivers',
250 { type
: 'integer', name
: 'count' },
251 { type
: 'string', name
: 'receiver' }
258 title
: gettext('Dashboard') + ' (' +
259 Ext
.String
.format(gettext('{0} hours'), '{hours}') + ')'
265 bodyPadding
: '20 0 0 20',
276 handler
: 'openDashboardOptions'
286 iconCls
: 'fa fa-tachometer',
287 title
: gettext('E-Mail Volume'),
293 xtype
: 'pmgMiniGraph',
295 store
: '{recentmails}'
301 fieldTitles
: [ gettext('Mails / min') ],
303 colors
: [ '#00617F' ],
316 fieldTitles
: [ gettext('Spam / min') ],
318 colors
: [ '#E67300' ],
340 xtype
: 'pmgMailProcessing',
341 title
: gettext('E-Mail Processing'),
342 iconCls
: 'fa fa-hourglass-half',
347 'out': '{bytes_out}',
348 'ptime': '{avg_ptime}'
353 iconCls
: 'fa fa-ticket',
354 title
: 'Subscription',
355 reference
: 'subscription',
356 xtype
: 'pmgSubscriptionInfo',
364 iconCls
: 'fa fa-tasks',
365 title
: 'Node Resources',
366 bodyPadding
: '0 20 0 20',
372 xtype
: 'proxmoxGauge',
373 spriteFontSize
: '20px',
378 title
: gettext('CPU'),
382 title
: gettext('Memory'),
386 title
: gettext('Storage'),
393 iconCls
: 'fa fa-list',
394 title
: gettext('Top Receivers'),
408 emptyText
: gettext('No data in database'),
410 // remove all borders/lines/headers
423 dataIndex
: 'receiver',
425 text
: gettext('Receiver')
430 text
: gettext('Count')