]>
git.proxmox.com Git - proxmox-backup.git/blob - www/Dashboard.js
1 Ext
.define('PBS.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'),
20 bodyPadding
: '10 10 10 10',
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
);
55 var sp
= Ext
.state
.Manager
.getProvider();
56 sp
.set('dashboard-hours', hours
);
61 updateSubscription: function(store
, records
, success
) {
62 if (!success
) { return; }
64 let subStatus
= records
[0].data
.status
=== 'Active' ? 2 : 0; // 2 = all good, 1 = different leves, 0 = none
65 me
.lookup('subscription').setSubStatus(subStatus
);
68 updateUsageStats: function(store
, records
, success
) {
72 if (records
=== undefined || records
.length
< 1) {
76 let viewmodel
= me
.getViewModel();
78 let res
= records
[0].data
;
84 var cpuPanel
= me
.lookup('cpu');
85 cpuPanel
.updateValue(cpu
);
87 var memPanel
= me
.lookup('mem');
88 memPanel
.updateValue(mem
.used
/ mem
.total
);
90 var hdPanel
= me
.lookup('root');
91 hdPanel
.updateValue(root
.used
/ root
.total
);
94 updateTasks: function(store
, records
, success
) {
98 records
.sort((a
, b
) => a
.data
.duration
- b
.data
.duration
);
99 let top10
= records
.slice(-10);
100 me
.lookup('longesttasks').updateTasks(top10
);
103 backup
: { error
: 0, warning
: 0, ok
: 0, },
104 prune
: { error
: 0, warning
: 0, ok
: 0, },
105 garbage_collection
: { error
: 0, warning
: 0, ok
: 0, },
106 sync
: { error
: 0, warning
: 0, ok
: 0, },
109 records
.forEach(record
=> {
110 let type
= record
.data
.worker_type
;
111 if (type
=== 'syncjob') {
115 if (data
[type
] && record
.data
.status
) {
116 let parsed
= Proxmox
.Utils
.parse_task_status(record
.data
.status
);
117 data
[type
][parsed
]++;
121 me
.lookup('tasksummary').updateTasks(data
);
124 init: function(view
) {
126 var sp
= Ext
.state
.Manager
.getProvider();
127 var hours
= sp
.get('dashboard-hours') || 12;
128 me
.setHours(hours
, false);
134 timespan
: 300, // in seconds
135 hours
: 12, // in hours
144 storeid
: 'dash-usage',
152 url
: '/api2/json/nodes/localhost/status'
155 load
: 'updateUsageStats'
159 storeid
: 'dash-subscription',
167 url
: '/api2/json/subscription'
170 load
: 'updateSubscription'
174 storeid
: 'dash-tasks',
180 model
: 'proxmox-tasks',
183 url
: '/api2/json/status/tasks'
192 title
: gettext('Dashboard') + ' - WIP',
198 bodyPadding
: '20 0 0 20',
211 iconCls
: 'fa fa-tasks',
212 title
: gettext('Server Resources'),
213 bodyPadding
: '0 20 0 20',
219 xtype
: 'proxmoxGauge',
220 spriteFontSize
: '20px',
225 title
: gettext('CPU'),
229 title
: gettext('Memory'),
233 title
: gettext('Root Disk'),
239 xtype
: 'pbsDatastoresStatistics',
243 xtype
: 'pbsLongestTasks',
244 reference
: 'longesttasks',
248 xtype
: 'pbsRunningTasks',
252 xtype
: 'pbsTaskSummary',
253 reference
: 'tasksummary',
256 iconCls
: 'fa fa-ticket',
257 title
: 'Subscription',
259 reference
: 'subscription',
260 xtype
: 'pbsSubscriptionInfo',
265 Ext
.define('PBS.dashboard.SubscriptionInfo', {
266 extend
: 'Ext.panel.Panel',
267 xtype
: 'pbsSubscriptionInfo',
283 icon
: 'question-circle',
286 tpl
: '<center><i class="fa fa-3x fa-{icon}"></i></center>',
292 message
: gettext('Unknown'),
295 tpl
: '<center>{message}</center>',
299 setSubStatus: function(status
) {
307 message
= gettext('Your subscription status is valid.');
310 icon
= 'exclamation-triangle warning';
311 message
= gettext('Warning: Your subscription levels are not the same.');
314 icon
= 'times-circle critical';
315 message
= gettext('This node does not have a subscription.');
318 throw 'invalid subscription status';
320 me
.getComponent('icon').update({ icon
});
321 me
.getComponent('message').update({ message
});
328 var mainview
= this.component
.up('mainview');
329 mainview
.getController().redirectTo('pbsSubscription');