2019-12-20 11:46:09 +00:00
|
|
|
Ext.define('pbs-data-store-content', {
|
|
|
|
extend: 'Ext.data.Model',
|
2019-12-20 16:04:45 +00:00
|
|
|
fields: [
|
|
|
|
'backup-type',
|
2019-12-22 09:43:57 +00:00
|
|
|
'backup-id',
|
|
|
|
{
|
|
|
|
name: 'last-backup',
|
|
|
|
type: 'date',
|
|
|
|
dateFormat: 'timestamp'
|
|
|
|
},
|
2019-12-20 16:04:45 +00:00
|
|
|
'files',
|
2019-12-22 09:43:57 +00:00
|
|
|
{ name: 'backup-count', type: 'int' },
|
|
|
|
{
|
|
|
|
name: 'backup-group',
|
|
|
|
calculate: function (data) {
|
|
|
|
return data["backup-type"] + '/' + data["backup-id"];
|
|
|
|
}
|
|
|
|
},
|
2019-12-20 16:04:45 +00:00
|
|
|
],
|
2019-12-20 11:46:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
Ext.define('PBS.DataStoreContent', {
|
|
|
|
extend: 'Ext.grid.GridPanel',
|
|
|
|
alias: 'widget.pbsDataStoreContent',
|
|
|
|
|
2019-12-22 09:43:57 +00:00
|
|
|
store: {
|
|
|
|
model: 'pbs-data-store-content',
|
|
|
|
sorters: 'backup-group',
|
|
|
|
},
|
|
|
|
|
2019-12-20 16:17:44 +00:00
|
|
|
controller: {
|
|
|
|
xclass: 'Ext.app.ViewController',
|
|
|
|
|
|
|
|
init: function(view) {
|
|
|
|
if (!view.datastore) {
|
|
|
|
throw "no datastore specified";
|
|
|
|
}
|
|
|
|
|
|
|
|
view.title = gettext('Data Store Content: ') + view.datastore;
|
|
|
|
|
|
|
|
Proxmox.Utils.monStoreErrors(view, view.store, true);
|
|
|
|
this.reload(); // initial load
|
|
|
|
},
|
|
|
|
|
|
|
|
reload: function() {
|
|
|
|
var view = this.getView();
|
|
|
|
|
2019-12-22 09:43:57 +00:00
|
|
|
let url = `/api2/json/admin/datastore/${view.datastore}/groups`;
|
2019-12-20 16:17:44 +00:00
|
|
|
view.store.setProxy({
|
|
|
|
type: 'proxmox',
|
|
|
|
url: url
|
|
|
|
});
|
|
|
|
view.store.load();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2019-12-22 09:43:57 +00:00
|
|
|
initComponent: function() {
|
|
|
|
var me = this;
|
2019-12-20 16:03:28 +00:00
|
|
|
|
2019-12-22 09:43:57 +00:00
|
|
|
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 {
|
2019-12-22 10:09:30 +00:00
|
|
|
return btype + '/' + value;
|
2019-12-22 09:43:57 +00:00
|
|
|
}
|
|
|
|
var fa = '<i class="fa fa-fw x-grid-icon-custom ' + cls + '"></i> ';
|
|
|
|
return fa + value;
|
|
|
|
};
|
2019-12-20 16:17:44 +00:00
|
|
|
|
2019-12-22 09:43:57 +00:00
|
|
|
Ext.apply(me, {
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
header: gettext('Backup'),
|
|
|
|
sortable: true,
|
|
|
|
renderer: render_backup_type,
|
|
|
|
dataIndex: 'backup-id',
|
|
|
|
flex: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'datecolumn',
|
|
|
|
header: gettext('Last Backup'),
|
|
|
|
sortable: true,
|
|
|
|
dataIndex: 'last-backup',
|
|
|
|
format: 'Y-m-d H:i:s',
|
|
|
|
flex: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'numbercolumn',
|
|
|
|
format: '0',
|
2020-03-17 14:54:02 +00:00
|
|
|
header: gettext('Number of Backups'),
|
2019-12-22 09:43:57 +00:00
|
|
|
sortable: true,
|
|
|
|
dataIndex: 'backup-count',
|
|
|
|
flex: 1
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
2019-12-22 10:06:03 +00:00
|
|
|
plugins: [{
|
|
|
|
ptype: 'rowexpander',
|
|
|
|
rowBodyTpl: new Ext.XTemplate(
|
|
|
|
'<tpl for="files">',
|
|
|
|
'<p>{.}</p>',
|
|
|
|
'</tpl>'
|
|
|
|
),
|
|
|
|
}],
|
|
|
|
|
2019-12-22 09:43:57 +00:00
|
|
|
tbar: [
|
|
|
|
{
|
|
|
|
text: gettext('Reload'),
|
|
|
|
iconCls: 'fa fa-refresh',
|
|
|
|
handler: 'reload',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
me.callParent();
|
2019-12-20 16:03:28 +00:00
|
|
|
},
|
2019-12-20 11:46:09 +00:00
|
|
|
});
|