]>
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
;
79 viewmodel
.set('fingerprint', res
.info
.fingerprint
|| Proxmox
.Utils
.unknownText
);
85 var cpuPanel
= me
.lookup('cpu');
86 cpuPanel
.updateValue(cpu
);
88 var memPanel
= me
.lookup('mem');
89 memPanel
.updateValue(mem
.used
/ mem
.total
);
91 var hdPanel
= me
.lookup('root');
92 hdPanel
.updateValue(root
.used
/ root
.total
);
95 showFingerPrint: function() {
97 let vm
= me
.getViewModel();
98 let fingerprint
= vm
.get('fingerprint');
99 Ext
.create('Ext.window.Window', {
102 title
: gettext('Fingerprint'),
108 inputId
: 'fingerprintField',
116 iconCls
: 'fa fa-clipboard',
117 handler: function(b
) {
118 var el
= document
.getElementById('fingerprintField');
120 document
.execCommand("copy");
122 text
: gettext('Copy'),
126 handler: function() {
127 this.up('window').close();
134 updateTasks: function(store
, records
, success
) {
135 if (!success
) return;
138 records
.sort((a
, b
) => a
.data
.duration
- b
.data
.duration
);
139 let top10
= records
.slice(-10);
140 me
.lookup('longesttasks').updateTasks(top10
);
143 backup
: { error
: 0, warning
: 0, ok
: 0 },
144 prune
: { error
: 0, warning
: 0, ok
: 0 },
145 garbage_collection
: { error
: 0, warning
: 0, ok
: 0 },
146 sync
: { error
: 0, warning
: 0, ok
: 0 },
149 records
.forEach(record
=> {
150 let type
= record
.data
.worker_type
;
151 if (type
=== 'syncjob') {
155 if (data
[type
] && record
.data
.status
) {
156 let parsed
= Proxmox
.Utils
.parse_task_status(record
.data
.status
);
157 data
[type
][parsed
]++;
161 me
.lookup('tasksummary').updateTasks(data
);
164 init: function(view
) {
166 var sp
= Ext
.state
.Manager
.getProvider();
167 var hours
= sp
.get('dashboard-hours') || 12;
168 me
.setHours(hours
, false);
174 timespan
: 300, // in seconds
175 hours
: 12, // in hours
184 disableFPButton
: (get) => get('fingerprint') === "",
189 storeid
: 'dash-usage',
197 url
: '/api2/json/nodes/localhost/status',
200 load
: 'updateUsageStats',
204 storeid
: 'dash-subscription',
212 url
: '/api2/json/nodes/localhost/subscription',
215 load
: 'updateSubscription',
219 storeid
: 'dash-tasks',
225 model
: 'proxmox-tasks',
228 url
: '/api2/json/status/tasks',
237 title
: gettext('Dashboard') + ' - WIP',
243 bodyPadding
: '20 0 0 20',
256 iconCls
: 'fa fa-tasks',
257 title
: gettext('Server Resources'),
258 bodyPadding
: '0 20 0 20',
262 text
: gettext('Show Fingerprint'),
263 handler
: 'showFingerPrint',
265 disabled
: '{disableFPButton}',
274 xtype
: 'proxmoxGauge',
275 spriteFontSize
: '20px',
280 title
: gettext('CPU'),
284 title
: gettext('Memory'),
288 title
: gettext('Root Disk'),
294 xtype
: 'pbsDatastoresStatistics',
298 xtype
: 'pbsLongestTasks',
299 reference
: 'longesttasks',
303 xtype
: 'pbsRunningTasks',
307 xtype
: 'pbsTaskSummary',
308 reference
: 'tasksummary',
311 iconCls
: 'fa fa-ticket',
312 title
: 'Subscription',
314 reference
: 'subscription',
315 xtype
: 'pbsSubscriptionInfo',
320 Ext
.define('PBS.dashboard.SubscriptionInfo', {
321 extend
: 'Ext.panel.Panel',
322 xtype
: 'pbsSubscriptionInfo',
338 icon
: 'question-circle',
341 tpl
: '<center><i class="fa fa-3x fa-{icon}"></i></center>',
347 message
: gettext('Unknown'),
350 tpl
: '<center>{message}</center>',
354 setSubStatus: function(status
) {
362 message
= gettext('Your subscription status is valid.');
365 icon
= 'exclamation-triangle warning';
366 message
= gettext('Warning: Your subscription levels are not the same.');
369 icon
= 'times-circle critical';
370 message
= gettext('This node does not have a subscription.');
373 throw 'invalid subscription status';
375 me
.getComponent('icon').update({ icon
});
376 me
.getComponent('message').update({ message
});
383 var mainview
= this.component
.up('mainview');
384 mainview
.getController().redirectTo('pbsSubscription');