gui: add prune dialog

This commit is contained in:
Dietmar Maurer 2020-03-26 13:23:28 +01:00
parent 4299ca727c
commit b1127fd0d0
3 changed files with 131 additions and 0 deletions

View File

@ -74,6 +74,8 @@ Ext.define('PBS.DataStoreContent', {
leaf: false,
iconCls: "fa " + cls,
expanded: false,
backup_type: item.data["backup-type"],
backup_id: item.data["backup-id"],
children: []
};
});
@ -117,7 +119,40 @@ Ext.define('PBS.DataStoreContent', {
initComponent: function() {
var me = this;
var sm = Ext.create('Ext.selection.RowModel', {});
var prune_btn = new Proxmox.button.Button({
text: gettext('Prune'),
disabled: true,
selModel: sm,
enableFn: function(record) {
return !record.data.leaf;
},
handler: function() {
let rec = sm.getSelection()[0];
if (!(rec && rec.data)) return;
let data = rec.data;
if (data.leaf) return;
console.log(data);
console.log("PRUNE GROUP: " + me.datastore);
if (!me.datastore) return;
let win = Ext.create('PBS.DataStorePrune', {
datastore: me.datastore,
backup_type: data.backup_type,
backup_id: data.backup_id,
});
win.on('destroy', me.getController().reload, me.getController());
win.show();
}
});
Ext.apply(me, {
selModel: sm,
columns: [
{
xtype: 'treecolumn',
@ -160,6 +195,7 @@ Ext.define('PBS.DataStoreContent', {
iconCls: 'fa fa-refresh',
handler: 'reload',
},
prune_btn
],
});

94
www/DataStorePrune.js Normal file
View File

@ -0,0 +1,94 @@
Ext.define('PBS.DataStorePruneInputPanel', {
extend: 'Proxmox.panel.InputPanel',
alias: 'widget.pbsDataStorePruneInputPanel',
items: [
{
xtype: 'proxmoxintegerfield',
name: 'keep-last',
allowBlank: true,
fieldLabel: gettext('keep-last'),
minValue: 1,
},
{
xtype: 'proxmoxintegerfield',
name: 'keep-hourly',
allowBlank: true,
fieldLabel: gettext('keep-hourly'),
minValue: 1,
},
{
xtype: 'proxmoxintegerfield',
name: 'keep-daily',
allowBlank: true,
fieldLabel: gettext('keep-daily'),
minValue: 1,
},
{
xtype: 'proxmoxintegerfield',
name: 'keep-weekly',
allowBlank: true,
fieldLabel: gettext('keep-weekly'),
minValue: 1,
},
{
xtype: 'proxmoxintegerfield',
name: 'keep-montly',
allowBlank: true,
fieldLabel: gettext('keep-monthly'),
minValue: 1,
},
{
xtype: 'proxmoxintegerfield',
name: 'keep-yearly',
allowBlank: true,
fieldLabel: gettext('keep-yearly'),
minValue: 1,
}
// fixme: howto handle dry-run?
//{
// xtype: 'proxmoxcheckbox',
// name: 'dry-run',
// fieldLabel: gettext('dry-run'),
//}
],
});
Ext.define('PBS.DataStorePrune', {
extend: 'Proxmox.window.Edit',
method: 'POST',
submitText: "Prune",
isCreate: true,
initComponent : function() {
var me = this;
if (!me.datastore) {
throw "no datastore specified";
}
if (!me.backup_type) {
throw "no backup_type specified";
}
if (!me.backup_id) {
throw "no backup_id specified";
}
Ext.apply(me, {
url: '/api2/extjs/admin/datastore/' + me.datastore + "/prune",
title: "Prune Datastore '" + me.datastore + "'",
items: [{
xtype: 'pbsDataStorePruneInputPanel',
onGetValues: function(values) {
values["backup-type"] = me.backup_type;
values["backup-id"] = me.backup_id;
return values;
}
}]
});
me.callParent();
}
});

View File

@ -11,6 +11,7 @@ JSSRC= \
VersionInfo.js \
SystemConfiguration.js \
Subscription.js \
DataStorePrune.js \
DataStoreConfig.js \
DataStoreContent.js \
ServerAdministration.js \