]>
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('days'),
31 fieldLabel
: gettext('Days to show'),
34 text
: gettext('Save'),
35 reference
: 'savebutton',
38 var win
= this.up('window');
39 var days
= win
.down('#days').getValue();
40 me
.setDays(days
, true);
48 setDays: function(days
, setState
) {
50 var viewModel
= me
.getViewModel();
51 viewModel
.set('days', days
);
54 viewModel
.getStore('tasks').reload();
57 var sp
= Ext
.state
.Manager
.getProvider();
58 sp
.set('dashboard-days', days
);
63 updateSubscription: function(store
, records
, success
) {
64 if (!success
) { return; }
66 let subStatus
= records
[0].data
.status
=== 'Active' ? 2 : 0; // 2 = all good, 1 = different leves, 0 = none
67 me
.lookup('subscription').setSubStatus(subStatus
);
70 updateUsageStats: function(store
, records
, success
) {
74 if (records
=== undefined || records
.length
< 1) {
78 let viewmodel
= me
.getViewModel();
80 let res
= records
[0].data
;
81 viewmodel
.set('fingerprint', res
.info
.fingerprint
|| Proxmox
.Utils
.unknownText
);
87 var cpuPanel
= me
.lookup('cpu');
88 cpuPanel
.updateValue(cpu
);
90 var memPanel
= me
.lookup('mem');
91 memPanel
.updateValue(mem
.used
/ mem
.total
);
93 var hdPanel
= me
.lookup('root');
94 hdPanel
.updateValue(root
.used
/ root
.total
);
97 showFingerPrint: function() {
99 let vm
= me
.getViewModel();
100 let fingerprint
= vm
.get('fingerprint');
101 Ext
.create('Ext.window.Window', {
104 title
: gettext('Fingerprint'),
110 inputId
: 'fingerprintField',
118 iconCls
: 'fa fa-clipboard',
119 handler: function(b
) {
120 var el
= document
.getElementById('fingerprintField');
122 document
.execCommand("copy");
124 text
: gettext('Copy'),
128 handler: function() {
129 this.up('window').close();
136 updateTasks: function(store
, records
, success
) {
137 if (!success
) return;
139 let viewModel
= me
.getViewModel();
141 records
.sort((a
, b
) => a
.data
.duration
- b
.data
.duration
);
142 let top10
= records
.slice(-10);
143 me
.lookup('longesttasks').updateTasks(top10
);
146 backup
: { error
: 0, warning
: 0, ok
: 0 },
147 prune
: { error
: 0, warning
: 0, ok
: 0 },
148 garbage_collection
: { error
: 0, warning
: 0, ok
: 0 },
149 sync
: { error
: 0, warning
: 0, ok
: 0 },
150 verify
: { error
: 0, warning
: 0, ok
: 0 },
153 records
.forEach(record
=> {
154 let task
= record
.data
;
155 let type
= task
.worker_type
;
156 if (type
=== 'syncjob') {
160 if (type
.startsWith('verify')) {
164 if (data
[type
] && task
.status
) {
165 let parsed
= Proxmox
.Utils
.parse_task_status(task
.status
);
166 data
[type
][parsed
]++;
170 me
.lookup('tasksummary').updateTasks(data
, viewModel
.get('sinceEpoch'));
173 init: function(view
) {
175 var sp
= Ext
.state
.Manager
.getProvider();
176 var days
= sp
.get('dashboard-days') || 30;
177 me
.setDays(days
, false);
188 disableFPButton
: (get) => get('fingerprint') === "",
189 sinceEpoch
: (get) => (Date
.now()/1000 - get('days') * 24*3600).toFixed(0),
194 storeid
: 'dash-usage',
202 url
: '/api2/json/nodes/localhost/status',
205 load
: 'updateUsageStats',
209 storeid
: 'dash-subscription',
217 url
: '/api2/json/nodes/localhost/subscription',
220 load
: 'updateSubscription',
224 storeid
: 'dash-tasks',
230 model
: 'proxmox-tasks',
233 url
: '/api2/json/status/tasks',
235 since
: '{sinceEpoch}',
245 title
: gettext('Dashboard'),
251 bodyPadding
: '20 0 0 20',
262 tooltip
: gettext('Edit dashboard settings'),
263 handler
: 'openDashboardOptions',
272 iconCls
: 'fa fa-tasks',
273 title
: gettext('Server Resources'),
274 bodyPadding
: '0 20 0 20',
278 text
: gettext('Show Fingerprint'),
279 handler
: 'showFingerPrint',
281 disabled
: '{disableFPButton}',
290 xtype
: 'proxmoxGauge',
291 spriteFontSize
: '20px',
296 title
: gettext('CPU'),
300 title
: gettext('Memory'),
304 title
: gettext('Root Disk'),
310 xtype
: 'pbsDatastoresStatistics',
314 xtype
: 'pbsLongestTasks',
316 title
: gettext('Longest Tasks') + ' (' +
317 Ext
.String
.format(gettext('{0} days'), '{days}') + ')',
319 reference
: 'longesttasks',
323 xtype
: 'pbsRunningTasks',
328 title
: gettext('Task Summary') + ' (' +
329 Ext
.String
.format(gettext('{0} days'), '{days}') + ')',
331 xtype
: 'pbsTaskSummary',
332 reference
: 'tasksummary',
335 iconCls
: 'fa fa-ticket',
336 title
: 'Subscription',
338 reference
: 'subscription',
339 xtype
: 'pbsSubscriptionInfo',
344 Ext
.define('PBS.dashboard.SubscriptionInfo', {
345 extend
: 'Ext.panel.Panel',
346 xtype
: 'pbsSubscriptionInfo',
362 icon
: 'question-circle',
365 tpl
: '<center><i class="fa fa-3x fa-{icon}"></i></center>',
371 message
: gettext('Unknown'),
374 tpl
: '<center>{message}</center>',
378 setSubStatus: function(status
) {
386 message
= gettext('Your subscription status is valid.');
389 icon
= 'exclamation-triangle warning';
390 message
= gettext('Warning: Your subscription levels are not the same.');
393 icon
= 'times-circle critical';
394 message
= gettext('This node does not have a subscription.');
397 throw 'invalid subscription status';
399 me
.getComponent('icon').update({ icon
});
400 me
.getComponent('message').update({ message
});
407 var mainview
= this.component
.up('mainview');
408 mainview
.getController().redirectTo('pbsSubscription');