]>
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 handler: function(b
) {
117 var el
= document
.getElementById('fingerprintField');
119 document
.execCommand("copy");
121 text
: gettext('Copy')
124 text
: gettext("Close"),
125 handler: function() {
126 this.up('window').close();
133 updateTasks: function(store
, records
, success
) {
134 if (!success
) return;
137 records
.sort((a
, b
) => a
.data
.duration
- b
.data
.duration
);
138 let top10
= records
.slice(-10);
139 me
.lookup('longesttasks').updateTasks(top10
);
142 backup
: { error
: 0, warning
: 0, ok
: 0, },
143 prune
: { error
: 0, warning
: 0, ok
: 0, },
144 garbage_collection
: { error
: 0, warning
: 0, ok
: 0, },
145 sync
: { error
: 0, warning
: 0, ok
: 0, },
148 records
.forEach(record
=> {
149 let type
= record
.data
.worker_type
;
150 if (type
=== 'syncjob') {
154 if (data
[type
] && record
.data
.status
) {
155 let parsed
= Proxmox
.Utils
.parse_task_status(record
.data
.status
);
156 data
[type
][parsed
]++;
160 me
.lookup('tasksummary').updateTasks(data
);
163 init: function(view
) {
165 var sp
= Ext
.state
.Manager
.getProvider();
166 var hours
= sp
.get('dashboard-hours') || 12;
167 me
.setHours(hours
, false);
173 timespan
: 300, // in seconds
174 hours
: 12, // in hours
183 disableFPButton
: (get) => get('fingerprint') === "",
188 storeid
: 'dash-usage',
196 url
: '/api2/json/nodes/localhost/status'
199 load
: 'updateUsageStats'
203 storeid
: 'dash-subscription',
211 url
: '/api2/json/subscription'
214 load
: 'updateSubscription'
218 storeid
: 'dash-tasks',
224 model
: 'proxmox-tasks',
227 url
: '/api2/json/status/tasks'
236 title
: gettext('Dashboard') + ' - WIP',
242 bodyPadding
: '20 0 0 20',
255 iconCls
: 'fa fa-tasks',
256 title
: gettext('Server Resources'),
257 bodyPadding
: '0 20 0 20',
261 text
: gettext('Show Fingerprint'),
262 handler
: 'showFingerPrint',
264 disabled
: '{disableFPButton}',
273 xtype
: 'proxmoxGauge',
274 spriteFontSize
: '20px',
279 title
: gettext('CPU'),
283 title
: gettext('Memory'),
287 title
: gettext('Root Disk'),
293 xtype
: 'pbsDatastoresStatistics',
297 xtype
: 'pbsLongestTasks',
298 reference
: 'longesttasks',
302 xtype
: 'pbsRunningTasks',
306 xtype
: 'pbsTaskSummary',
307 reference
: 'tasksummary',
310 iconCls
: 'fa fa-ticket',
311 title
: 'Subscription',
313 reference
: 'subscription',
314 xtype
: 'pbsSubscriptionInfo',
319 Ext
.define('PBS.dashboard.SubscriptionInfo', {
320 extend
: 'Ext.panel.Panel',
321 xtype
: 'pbsSubscriptionInfo',
337 icon
: 'question-circle',
340 tpl
: '<center><i class="fa fa-3x fa-{icon}"></i></center>',
346 message
: gettext('Unknown'),
349 tpl
: '<center>{message}</center>',
353 setSubStatus: function(status
) {
361 message
= gettext('Your subscription status is valid.');
364 icon
= 'exclamation-triangle warning';
365 message
= gettext('Warning: Your subscription levels are not the same.');
368 icon
= 'times-circle critical';
369 message
= gettext('This node does not have a subscription.');
372 throw 'invalid subscription status';
374 me
.getComponent('icon').update({ icon
});
375 me
.getComponent('message').update({ message
});
382 var mainview
= this.component
.up('mainview');
383 mainview
.getController().redirectTo('pbsSubscription');