2020-06-09 08:01:14 +00:00
|
|
|
Ext.define('pbs-datastore-statistics', {
|
|
|
|
extend: 'Ext.data.Model',
|
|
|
|
|
|
|
|
fields: [
|
2021-05-21 11:21:46 +00:00
|
|
|
'store',
|
|
|
|
'total',
|
|
|
|
'used',
|
|
|
|
'avail',
|
|
|
|
'estimated-full-date',
|
|
|
|
'error',
|
2020-06-25 08:45:51 +00:00
|
|
|
{
|
|
|
|
name: 'history',
|
|
|
|
convert: function(values) {
|
2021-05-21 10:20:39 +00:00
|
|
|
if (!values) {
|
|
|
|
return [];
|
|
|
|
}
|
2020-06-25 08:45:51 +00:00
|
|
|
let last = null;
|
|
|
|
return values.map(v => {
|
|
|
|
if (v !== undefined && v !== null) {
|
|
|
|
last = v;
|
|
|
|
}
|
|
|
|
return last;
|
|
|
|
});
|
2020-09-25 16:40:03 +00:00
|
|
|
},
|
2020-06-25 08:45:51 +00:00
|
|
|
},
|
2020-06-09 08:01:14 +00:00
|
|
|
{
|
|
|
|
name: 'usage',
|
|
|
|
calculate: function(data) {
|
|
|
|
let used = data.used || 0;
|
|
|
|
let total = data.total || 0;
|
|
|
|
if (total > 0) {
|
|
|
|
return used/total;
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
2020-09-25 16:40:03 +00:00
|
|
|
},
|
2020-06-09 08:01:14 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
|
|
|
|
proxy: {
|
|
|
|
type: 'proxmox',
|
2020-09-25 16:40:03 +00:00
|
|
|
url: "/api2/json/status/datastore-usage",
|
2020-06-09 08:01:14 +00:00
|
|
|
},
|
|
|
|
idProperty: 'store',
|
|
|
|
});
|
|
|
|
|
|
|
|
Ext.define('PBS.DatastoreStatistics', {
|
|
|
|
extend: 'Ext.grid.Panel',
|
|
|
|
alias: 'widget.pbsDatastoresStatistics',
|
|
|
|
|
|
|
|
title: gettext('Datastore Usage'),
|
2021-05-27 08:52:17 +00:00
|
|
|
disableSelection: true,
|
2020-06-09 08:01:14 +00:00
|
|
|
|
|
|
|
emptyText: gettext('No Data'),
|
|
|
|
|
|
|
|
controller: {
|
|
|
|
xclass: 'Ext.app.ViewController',
|
|
|
|
|
|
|
|
init: function(view) {
|
|
|
|
Proxmox.Utils.monStoreErrors(view, view.getStore().rstore);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
text: gettext('Name'),
|
|
|
|
dataIndex: 'store',
|
|
|
|
sortable: true,
|
2021-05-21 11:21:46 +00:00
|
|
|
renderer: (value, metaData, record, rowIndex, colIndex, store) => {
|
|
|
|
let err = record.get('error');
|
|
|
|
if (err) {
|
|
|
|
metaData.tdAttr = `data-qtip="${Ext.htmlEncode(err)}"`;
|
|
|
|
metaData.tdCls = 'proxmox-invalid-row';
|
2021-06-30 15:15:59 +00:00
|
|
|
return `${value || ''} <i class="fa fa-fw critical fa-exclamation-circle"></i>`;
|
2021-05-21 11:21:46 +00:00
|
|
|
}
|
|
|
|
return value;
|
|
|
|
},
|
2020-06-09 08:01:14 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: gettext('Size'),
|
|
|
|
dataIndex: 'total',
|
|
|
|
sortable: true,
|
|
|
|
width: 90,
|
2021-05-21 10:20:39 +00:00
|
|
|
renderer: v => v === undefined || v < 0 ? '-' : Proxmox.Utils.format_size(v),
|
2020-06-09 08:01:14 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: gettext('Used'),
|
|
|
|
dataIndex: 'used',
|
|
|
|
sortable: true,
|
|
|
|
width: 90,
|
2021-05-21 10:20:39 +00:00
|
|
|
renderer: v => v === undefined || v < 0 ? '-' : Proxmox.Utils.format_size(v),
|
2020-06-09 08:01:14 +00:00
|
|
|
},
|
2021-03-29 12:07:15 +00:00
|
|
|
{
|
|
|
|
text: gettext('Available'),
|
|
|
|
dataIndex: 'avail',
|
|
|
|
sortable: true,
|
|
|
|
width: 90,
|
2021-05-21 10:20:39 +00:00
|
|
|
renderer: v => v === undefined || v < 0 ? '-' : Proxmox.Utils.format_size(v),
|
2021-03-29 12:07:15 +00:00
|
|
|
},
|
2020-06-09 08:01:14 +00:00
|
|
|
{
|
|
|
|
text: gettext('Usage %'),
|
|
|
|
dataIndex: 'usage',
|
|
|
|
sortable: true,
|
|
|
|
xtype: 'widgetcolumn',
|
|
|
|
widget: {
|
|
|
|
xtype: 'progressbarwidget',
|
|
|
|
bind: '{record.usage}',
|
|
|
|
textTpl: [
|
|
|
|
'<tpl if="value >= 0">',
|
|
|
|
'{value:number("0.00")*100}%',
|
|
|
|
'<tpl else>',
|
|
|
|
Proxmox.Utils.unknownText,
|
|
|
|
'</tpl>',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: gettext('Estimated Full'),
|
|
|
|
dataIndex: 'estimated-full-date',
|
|
|
|
sortable: true,
|
2020-11-09 15:01:22 +00:00
|
|
|
renderer: PBS.Utils.render_estimate,
|
2020-06-09 08:01:14 +00:00
|
|
|
flex: 1,
|
|
|
|
minWidth: 130,
|
|
|
|
maxWidth: 200,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: gettext("History (last Month)"),
|
|
|
|
width: 100,
|
|
|
|
xtype: 'widgetcolumn',
|
|
|
|
dataIndex: 'history',
|
|
|
|
flex: 1,
|
|
|
|
widget: {
|
|
|
|
xtype: 'sparklineline',
|
|
|
|
bind: '{record.history}',
|
|
|
|
spotRadius: 0,
|
|
|
|
fillColor: '#ddd',
|
|
|
|
lineColor: '#555',
|
|
|
|
lineWidth: 0,
|
|
|
|
chartRangeMin: 0,
|
|
|
|
chartRangeMax: 1,
|
2020-09-25 16:40:03 +00:00
|
|
|
tipTpl: '{y:number("0.00")*100}%',
|
|
|
|
},
|
2020-06-09 08:01:14 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
|
|
|
|
store: {
|
|
|
|
type: 'diff',
|
|
|
|
autoDestroy: true,
|
|
|
|
autoDestroyRstore: true,
|
|
|
|
sorters: 'store',
|
|
|
|
rstore: {
|
|
|
|
type: 'update',
|
|
|
|
storeid: 'pbs-datastore-statistics',
|
|
|
|
model: 'pbs-datastore-statistics',
|
|
|
|
autoStart: true,
|
|
|
|
interval: 30000,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-09-25 16:40:03 +00:00
|
|
|
});
|