DataStoreContent.js: show backup groups (instead of snapshots).

This commit is contained in:
Dietmar Maurer 2019-12-22 10:43:57 +01:00
parent 5b32852266
commit 507c39c595
1 changed files with 73 additions and 42 deletions

View File

@ -1,11 +1,21 @@
Ext.define('pbs-data-store-content', {
extend: 'Ext.data.Model',
fields: [
'backup-id',
'backup-time',
'backup-type',
'backup-id',
{
name: 'last-backup',
type: 'date',
dateFormat: 'timestamp'
},
'files',
{ name: 'size', type: 'int', defaultValue: 0 },
{ name: 'backup-count', type: 'int' },
{
name: 'backup-group',
calculate: function (data) {
return data["backup-type"] + '/' + data["backup-id"];
}
},
],
});
@ -13,6 +23,11 @@ Ext.define('PBS.DataStoreContent', {
extend: 'Ext.grid.GridPanel',
alias: 'widget.pbsDataStoreContent',
store: {
model: 'pbs-data-store-content',
sorters: 'backup-group',
},
controller: {
xclass: 'Ext.app.ViewController',
@ -30,7 +45,7 @@ Ext.define('PBS.DataStoreContent', {
reload: function() {
var view = this.getView();
let url = `/api2/json/admin/datastore/${view.datastore}/snapshots`;
let url = `/api2/json/admin/datastore/${view.datastore}/groups`;
view.store.setProxy({
type: 'proxmox',
url: url
@ -39,31 +54,48 @@ Ext.define('PBS.DataStoreContent', {
},
},
initComponent: function() {
var me = this;
var render_backup_type = function(value, metaData, record) {
var btype = record.data["backup-type"];
var cls = '';
if (btype === 'vm') {
cls = 'fa-desktop';
} else if (btype === 'ct') {
cls = 'fa-cube';
} else if (btype === 'host') {
cls = 'fa-building';
} else {
return value;
}
var fa = '<i class="fa fa-fw x-grid-icon-custom ' + cls + '"></i> ';
return fa + value;
};
Ext.apply(me, {
columns: [
{
header: gettext('Type'),
sortable: true,
dataIndex: 'backup-type',
flex: 1
},
{
header: gettext('ID'),
header: gettext('Backup'),
sortable: true,
renderer: render_backup_type,
dataIndex: 'backup-id',
flex: 1
},
{
header: gettext('Time'),
xtype: 'datecolumn',
header: gettext('Last Backup'),
sortable: true,
dataIndex: 'backup-time',
renderer: Proxmox.Utils.render_timestamp,
dataIndex: 'last-backup',
format: 'Y-m-d H:i:s',
flex: 1
},
{
header: gettext('Size'),
xtype: 'numbercolumn',
format: '0',
header: gettext('Nuber of backups'),
sortable: true,
dataIndex: 'size',
renderer: Proxmox.Utils.format_size,
dataIndex: 'backup-count',
flex: 1
},
],
@ -75,9 +107,8 @@ Ext.define('PBS.DataStoreContent', {
handler: 'reload',
},
],
});
store: {
model: 'pbs-data-store-content',
sorters: 'name',
me.callParent();
},
});