]>
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 me
.lookup('nodeInfo').setRepositoryInfo(records
[0].data
['standard-repos']);
68 updateSubscription: function(store
, records
, success
) {
69 if (!success
) { return; }
71 let status
= records
[0].data
.status
|| 'unknown';
72 // 2 = all good, 1 = different leves, 0 = none
73 let subStatus
= status
.toLowerCase() === 'active' ? 2 : 0;
74 me
.lookup('subscription').setSubStatus(subStatus
);
75 me
.lookup('nodeInfo').setSubscriptionStatus(subStatus
);
78 updateTasks: function(store
, records
, success
) {
81 let viewModel
= me
.getViewModel();
83 records
.sort((a
, b
) => a
.data
.duration
- b
.data
.duration
);
84 let top10
= records
.slice(-10);
85 me
.lookup('longesttasks').updateTasks(top10
);
88 backup
: { error
: 0, warning
: 0, ok
: 0 },
89 prune
: { error
: 0, warning
: 0, ok
: 0 },
90 garbage_collection
: { error
: 0, warning
: 0, ok
: 0 },
91 sync
: { error
: 0, warning
: 0, ok
: 0 },
92 verify
: { error
: 0, warning
: 0, ok
: 0 },
95 records
.forEach(record
=> {
96 let task
= record
.data
;
97 let type
= task
.worker_type
;
98 if (type
=== 'syncjob') {
102 if (type
.startsWith('verif')) {
106 if (data
[type
] && task
.status
) {
107 let parsed
= Proxmox
.Utils
.parse_task_status(task
.status
);
108 data
[type
][parsed
]++;
112 me
.lookup('tasksummary').updateTasks(data
, viewModel
.get('sinceEpoch'));
115 init: function(view
) {
117 var sp
= Ext
.state
.Manager
.getProvider();
118 var days
= sp
.get('dashboard-days') || 30;
119 me
.setDays(days
, false);
121 view
.mon(sp
, 'statechange', function(provider
, key
, value
) {
122 if (key
!== 'summarycolumns') {
125 Proxmox
.Utils
.updateColumns(view
);
136 sinceEpoch
: (get) => (Date
.now()/1000 - get('days') * 24*3600).toFixed(0),
141 storeid
: 'dash-repositories',
149 url
: '/api2/json/nodes/localhost/apt/repositories',
152 load
: 'updateRepositoryStatus',
156 storeid
: 'dash-subscription',
164 url
: '/api2/json/nodes/localhost/subscription',
167 load
: 'updateSubscription',
171 storeid
: 'dash-tasks',
177 model
: 'proxmox-tasks',
180 url
: '/api2/json/nodes/localhost/tasks',
183 since
: '{sinceEpoch}',
194 resize: function(panel
) {
195 Proxmox
.Utils
.updateColumns(panel
);
199 title
: gettext('Dashboard'),
205 bodyPadding
: '20 0 0 20',
218 tooltip
: gettext('Edit dashboard settings'),
219 handler
: 'openDashboardOptions',
227 xtype
: 'pbsNodeInfoPanel',
228 reference
: 'nodeInfo',
232 xtype
: 'pbsDatastoresStatistics',
236 xtype
: 'pbsLongestTasks',
238 title
: gettext('Longest Tasks') + ' (' +
239 Ext
.String
.format(gettext('{0} days'), '{days}') + ')',
241 reference
: 'longesttasks',
245 xtype
: 'pbsRunningTasks',
250 title
: gettext('Task Summary') + ' (' +
251 Ext
.String
.format(gettext('{0} days'), '{days}') + ')',
253 xtype
: 'pbsTaskSummary',
255 reference
: 'tasksummary',
258 iconCls
: 'fa fa-ticket',
259 title
: 'Subscription',
261 reference
: 'subscription',
262 xtype
: 'pbsSubscriptionInfo',
267 Ext
.define('PBS.dashboard.SubscriptionInfo', {
268 extend
: 'Ext.panel.Panel',
269 xtype
: 'pbsSubscriptionInfo',
285 icon
: 'question-circle',
288 tpl
: '<center><i class="fa fa-3x fa-{icon}"></i></center>',
294 message
: gettext('Unknown'),
297 tpl
: '<center>{message}</center>',
301 setSubStatus: function(status
) {
309 message
= gettext('Your subscription status is valid.');
312 icon
= 'exclamation-triangle warning';
313 message
= gettext('Warning: Your subscription levels are not the same.');
316 icon
= 'times-circle critical';
317 message
= `<h1>${gettext('No valid subscription')}</h1>${PBS.Utils.noSubKeyHtml}`;
320 throw 'invalid subscription status';
322 me
.getComponent('icon').update({ icon
});
323 me
.getComponent('message').update({ message
});
330 var mainview
= this.component
.up('mainview');
331 mainview
.getController().redirectTo('pbsSubscription');