diff --git a/www/DataStoreContent.js b/www/DataStoreContent.js index f16d2db7..82beeb23 100644 --- a/www/DataStoreContent.js +++ b/www/DataStoreContent.js @@ -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 ], }); diff --git a/www/DataStorePrune.js b/www/DataStorePrune.js new file mode 100644 index 00000000..f3ebd4e6 --- /dev/null +++ b/www/DataStorePrune.js @@ -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(); + } +}); diff --git a/www/Makefile b/www/Makefile index 15e605ea..506e9b67 100644 --- a/www/Makefile +++ b/www/Makefile @@ -11,6 +11,7 @@ JSSRC= \ VersionInfo.js \ SystemConfiguration.js \ Subscription.js \ + DataStorePrune.js \ DataStoreConfig.js \ DataStoreContent.js \ ServerAdministration.js \