]>
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
);
62 updateRepositoryStatus: function(store
, records
, success
) {
63 if (!success
) { return; }
65 let view
= me
.getView();
66 view
.down('#repositoryStatus').setRepositoryInfo(records
[0].data
['standard-repos']);
69 updateSubscription: function(store
, records
, success
) {
70 if (!success
) { return; }
72 let view
= me
.getView();
73 let status
= records
[0].data
.status
|| 'unknown';
74 // 2 = all good, 1 = different levels, 0 = none
75 let subscriptionActive
= status
.toLowerCase() === 'active';
76 let subStatus
= status
.toLowerCase() === 'active' ? 2 : 0;
77 me
.lookup('subscription').setSubStatus(subStatus
);
78 view
.down('#repositoryStatus').setSubscriptionStatus(subscriptionActive
);
81 updateTasks: function(store
, records
, success
) {
84 let viewModel
= me
.getViewModel();
86 records
.sort((a
, b
) => a
.data
.duration
- b
.data
.duration
);
87 let top10
= records
.slice(-10);
88 me
.lookup('longesttasks').updateTasks(top10
);
91 backup
: { error
: 0, warning
: 0, ok
: 0 },
92 prune
: { error
: 0, warning
: 0, ok
: 0 },
93 garbage_collection
: { error
: 0, warning
: 0, ok
: 0 },
94 sync
: { error
: 0, warning
: 0, ok
: 0 },
95 verify
: { error
: 0, warning
: 0, ok
: 0 },
96 'tape-backup': { error
: 0, warning
: 0, ok
: 0 },
97 'tape-restore': { error
: 0, warning
: 0, ok
: 0 },
100 records
.forEach(record
=> {
101 let task
= record
.data
;
102 let type
= task
.worker_type
;
103 if (type
=== 'syncjob') {
107 if (type
.startsWith('verif')) {
111 if (type
.startsWith('prune')) {
115 if (type
.startsWith('tape-backup')) {
116 type
= 'tape-backup';
119 if (data
[type
] && task
.status
) {
120 let parsed
= Proxmox
.Utils
.parse_task_status(task
.status
);
121 data
[type
][parsed
]++;
125 me
.lookup('tasksummary').updateTasks(data
, viewModel
.get('sinceEpoch'));
128 init: function(view
) {
130 var sp
= Ext
.state
.Manager
.getProvider();
131 var days
= sp
.get('dashboard-days') || 30;
132 me
.setDays(days
, false);
134 view
.mon(sp
, 'statechange', function(provider
, key
, value
) {
135 if (key
!== 'summarycolumns') {
138 Proxmox
.Utils
.updateColumns(view
);
149 sinceEpoch
: (get) => (Date
.now()/1000 - get('days') * 24*3600).toFixed(0),
154 storeid
: 'dash-repositories',
162 url
: '/api2/json/nodes/localhost/apt/repositories',
165 load
: 'updateRepositoryStatus',
169 storeid
: 'dash-subscription',
177 url
: '/api2/json/nodes/localhost/subscription',
180 load
: 'updateSubscription',
184 storeid
: 'dash-tasks',
190 model
: 'proxmox-tasks',
193 url
: '/api2/json/nodes/localhost/tasks',
196 since
: '{sinceEpoch}',
207 resize: function(panel
) {
208 Proxmox
.Utils
.updateColumns(panel
);
212 title
: gettext('Dashboard'),
218 bodyPadding
: '20 0 0 20',
231 tooltip
: gettext('Edit dashboard settings'),
232 handler
: 'openDashboardOptions',
240 xtype
: 'pbsNodeInfoPanel',
241 reference
: 'nodeInfo',
245 xtype
: 'pbsDatastoresStatistics',
249 xtype
: 'pbsLongestTasks',
251 title
: gettext('Longest Tasks') + ' (' +
252 Ext
.String
.format(gettext('{0} days'), '{days}') + ')',
254 reference
: 'longesttasks',
258 xtype
: 'pbsRunningTasks',
263 title
: gettext('Task Summary') + ' (' +
264 Ext
.String
.format(gettext('{0} days'), '{days}') + ')',
266 xtype
: 'pbsTaskSummary',
268 reference
: 'tasksummary',
271 iconCls
: 'fa fa-ticket',
272 title
: 'Subscription',
274 reference
: 'subscription',
275 xtype
: 'pbsSubscriptionInfo',
280 Ext
.define('PBS.dashboard.SubscriptionInfo', {
281 extend
: 'Ext.panel.Panel',
282 xtype
: 'pbsSubscriptionInfo',
298 icon
: 'question-circle',
301 tpl
: '<center><i class="fa fa-3x fa-{icon}"></i></center>',
307 message
: gettext('Unknown'),
310 tpl
: '<center>{message}</center>',
314 setSubStatus: function(status
) {
322 message
= gettext('Your subscription status is valid.');
325 icon
= 'exclamation-triangle warning';
326 message
= gettext('Warning: Your subscription levels are not the same.');
329 icon
= 'times-circle critical';
330 message
= `<h1>${gettext('No valid subscription')}</h1>${PBS.Utils.noSubKeyHtml}`;
333 throw 'invalid subscription status';
335 me
.getComponent('icon').update({ icon
});
336 me
.getComponent('message').update({ message
});
343 var mainview
= this.component
.up('mainview');
344 mainview
.getController().redirectTo('pbsSubscription');