[pbs-devel] [PATCH proxmox-backup v2 8/8] ui: tape: add single snapshot restore
Dominik Csapak
d.csapak at proxmox.com
Wed May 5 12:09:18 CEST 2021
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
www/tape/BackupOverview.js | 41 ++++++++++++++++++++++++++++++++++
www/tape/window/TapeRestore.js | 26 +++++++++++++++++++++
2 files changed, 67 insertions(+)
diff --git a/www/tape/BackupOverview.js b/www/tape/BackupOverview.js
index 0cc0e18e..c028d58d 100644
--- a/www/tape/BackupOverview.js
+++ b/www/tape/BackupOverview.js
@@ -16,6 +16,38 @@ Ext.define('PBS.TapeManagement.BackupOverview', {
}).show();
},
+ restoreSingle: function(button, record) {
+ let me = this;
+ let view = me.getView();
+ let selection = view.getSelection();
+ if (!selection || selection.length < 1) {
+ return;
+ }
+
+ let node = selection[0];
+ if (node.data.restoreid === undefined) {
+ return;
+ }
+ let restoreid = node.data.restoreid;
+ let mediaset = node.data.text;
+ let uuid = node.data['media-set-uuid'];
+ let datastores = [node.data.store];
+
+ Ext.create('PBS.TapeManagement.TapeRestoreWindow', {
+ mediaset,
+ uuid,
+ list: [
+ restoreid,
+ ],
+ datastores,
+ listeners: {
+ destroy: function() {
+ me.reload();
+ },
+ },
+ }).show();
+ },
+
restore: function(button, record) {
let me = this;
let view = me.getView();
@@ -149,6 +181,7 @@ Ext.define('PBS.TapeManagement.BackupOverview', {
entry.text = entry.snapshot;
entry.leaf = true;
entry.children = [];
+ entry.restoreid = `${entry.store}:${entry.snapshot}`;
let iconCls = PBS.Utils.get_type_icon_cls(entry.snapshot);
if (iconCls !== '') {
entry.iconCls = `fa ${iconCls}`;
@@ -262,6 +295,14 @@ Ext.define('PBS.TapeManagement.BackupOverview', {
parentXType: 'treepanel',
enableFn: (rec) => !!rec.data['media-set-uuid'],
},
+ {
+ xtype: 'proxmoxButton',
+ disabled: true,
+ text: gettext('Restore Snapshot'),
+ handler: 'restoreSingle',
+ parentXType: 'treepanel',
+ enableFn: (rec) => !!rec.data.restoreid,
+ },
],
columns: [
diff --git a/www/tape/window/TapeRestore.js b/www/tape/window/TapeRestore.js
index 85011cba..fcd93f9c 100644
--- a/www/tape/window/TapeRestore.js
+++ b/www/tape/window/TapeRestore.js
@@ -10,6 +10,19 @@ Ext.define('PBS.TapeManagement.TapeRestoreWindow', {
showTaskViewer: true,
isCreate: true,
+ cbindData: function(config) {
+ let me = this;
+ me.isSingle = false;
+ me.listText = "";
+ if (me.list !== undefined) {
+ me.url = '/api2/extjs/tape/restore-single';
+ me.isSingle = true;
+ me.listText = me.list.join('<br>');
+ me.title = gettext('Restore Snapshot');
+ }
+ return {};
+ },
+
defaults: {
labelWidth: 120,
},
@@ -33,6 +46,10 @@ Ext.define('PBS.TapeManagement.TapeRestoreWindow', {
}
delete values.mapping;
+ if (me.up('window').list !== undefined) {
+ values.snapshots = me.up('window').list;
+ }
+
values.store = datastores.join(',');
return values;
@@ -55,6 +72,15 @@ Ext.define('PBS.TapeManagement.TapeRestoreWindow', {
value: '{uuid}',
},
},
+ {
+ xtype: 'displayfield',
+ fieldLabel: gettext('Snapshot(s)'),
+ submitValue: false,
+ cbind: {
+ hidden: '{!isSingle}',
+ value: '{listText}',
+ },
+ },
{
xtype: 'pbsDriveSelector',
fieldLabel: gettext('Drive'),
--
2.20.1
More information about the pbs-devel
mailing list