From 93b0659ff2035766a293366c4b1eeb886fc31457 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 10 May 2022 15:16:28 +0200 Subject: [PATCH] ui: datastore: more NS awareness verify is actually not yet ready in the backend Signed-off-by: Thomas Lamprecht --- www/datastore/Content.js | 76 ++++++++++++++++++++-------- www/datastore/Prune.js | 13 +++-- www/window/BackupGroupChangeOwner.js | 3 ++ 3 files changed, 68 insertions(+), 24 deletions(-) diff --git a/www/datastore/Content.js b/www/datastore/Content.js index 827b3929..5ea1da49 100644 --- a/www/datastore/Content.js +++ b/www/datastore/Content.js @@ -327,6 +327,7 @@ Ext.define('PBS.DataStoreContent', { let win = Ext.create('PBS.BackupGroupChangeOwner', { datastore: view.datastore, + ns: view.namespace, backup_type: data.backup_type, backup_id: data.backup_id, owner: data.owner, @@ -336,7 +337,8 @@ Ext.define('PBS.DataStoreContent', { }, onPrune: function(view, rI, cI, item, e, rec) { - view = this.getView(); + let me = this; + view = me.getView(); if (!(rec && rec.data)) return; let data = rec.data; @@ -344,28 +346,38 @@ Ext.define('PBS.DataStoreContent', { if (!view.datastore) return; - let win = Ext.create('PBS.DataStorePrune', { + Ext.create('PBS.DataStorePrune', { + autoShow: true, datastore: view.datastore, + ns: view.namespace, backup_type: data.backup_type, backup_id: data.backup_id, + listeners: { + destroy: () => me.reload(), + }, }); - win.on('destroy', this.reload, this); - win.show(); }, verifyAll: function() { var view = this.getView(); + let params = {}; + if (view.namespace && view.namespace !== '') { + params['backup-ns'] = view.namespace; // TODO backend?! + } + Proxmox.Utils.API2Request({ url: `/admin/datastore/${view.datastore}/verify`, + params, method: 'POST', failure: function(response) { Ext.Msg.alert(gettext('Error'), response.htmlStatus); }, success: function(response, options) { Ext.create('Proxmox.window.TaskViewer', { + autoShow: true, upid: response.result.data, - }).show(); + }); }, }); }, @@ -440,6 +452,9 @@ Ext.define('PBS.DataStoreContent', { "outdated-after": 29, // reverify after 29 days so match with the "old" display }; } + if (view.namespace && view.namespace !== '') { + params['backup-ns'] = view.namespace; + } Proxmox.Utils.API2Request({ params: params, @@ -476,6 +491,9 @@ Ext.define('PBS.DataStoreContent', { "backup-time": (data['backup-time'].getTime()/1000).toFixed(0), }; } + if (view.namespace && view.namespace !== '') { + params['backup-ns'] = view.namespace; + } Ext.create('PBS.window.NotesEdit', { url: url, @@ -489,12 +507,17 @@ Ext.define('PBS.DataStoreContent', { let me = this; let view = me.getView(); + let params = { + "backup-type": data.backup_type, + "backup-id": data.backup_id, + }; + if (view.namespace && view.namespace !== '') { + params['backup-ns'] = view.namespace; + } + Ext.create('Proxmox.window.SafeDestroy', { url: `/admin/datastore/${view.datastore}/groups`, - params: { - "backup-type": data.backup_type, - "backup-id": data.backup_id, - }, + params, item: { id: data.text, }, @@ -520,14 +543,18 @@ Ext.define('PBS.DataStoreContent', { if (btn !== 'yes') { return; } + let params = { + "backup-type": data["backup-type"], + "backup-id": data["backup-id"], + "backup-time": (data['backup-time'].getTime()/1000).toFixed(0), + }; + if (view.namespace && view.namespace !== '') { + params['backup-ns'] = view.namespace; + } Proxmox.Utils.API2Request({ url: `/admin/datastore/${view.datastore}/snapshots`, - params: { - "backup-type": data["backup-type"], - "backup-id": data["backup-id"], - "backup-time": (data['backup-time'].getTime()/1000).toFixed(0), - }, + params, method: 'DELETE', waitMsgTarget: view, failure: function(response, opts) { @@ -556,6 +583,9 @@ Ext.define('PBS.DataStoreContent', { 'backup-id': id, 'backup-time': time, }; + if (view.namespace && view.namespace !== '') { + params['backup-ns'] = view.namespace; + } let url = `/api2/extjs/admin/datastore/${view.datastore}/protected`; @@ -630,6 +660,9 @@ Ext.define('PBS.DataStoreContent', { 'backup-time': (data['backup-time'].getTime()/1000).toFixed(0), 'file-name': file, }; + if (view.namespace && view.namespace !== '') { + params['backup-ns'] = view.namespace; + } let idx = file.lastIndexOf('.'); let filename = file.slice(0, idx); @@ -656,17 +689,20 @@ Ext.define('PBS.DataStoreContent', { let time = data['backup-time']; let type = data['backup-type']; let timetext = PBS.Utils.render_datetime_utc(data["backup-time"]); - + let extraParams = { + 'backup-id': id, + 'backup-time': (time.getTime()/1000).toFixed(0), + 'backup-type': type, + }; + if (view.namespace && view.namespace !== '') { + extraParams['backup-ns'] = view.namespace; + } Ext.create('Proxmox.window.FileBrowser', { title: `${type}/${id}/${timetext}`, listURL: `/api2/json/admin/datastore/${view.datastore}/catalog`, downloadURL: `/api2/json/admin/datastore/${view.datastore}/pxar-file-download`, enableTar: true, - extraParams: { - 'backup-id': id, - 'backup-time': (time.getTime()/1000).toFixed(0), - 'backup-type': type, - }, + extraParams, archive: rec.data.filename, }).show(); }, diff --git a/www/datastore/Prune.js b/www/datastore/Prune.js index e4db4b6c..42139c1e 100644 --- a/www/datastore/Prune.js +++ b/www/datastore/Prune.js @@ -49,6 +49,9 @@ Ext.define('PBS.Datastore.PruneInputPanel', { values["backup-type"] = me.backup_type; values["backup-id"] = me.backup_id; + if (me.ns && me.ns !== '') { + values['backup-ns'] = me.ns; + } return values; }, @@ -122,6 +125,9 @@ Ext.define('PBS.Datastore.PruneInputPanel', { let params = view.getValues(); params["dry-run"] = true; + if (view.ns && view.ns !== '') { + params['backup-ns'] = view.ns; + } Proxmox.Utils.API2Request({ url: view.url, @@ -130,11 +136,9 @@ Ext.define('PBS.Datastore.PruneInputPanel', { callback: function() { // for easy breakpoint setting }, - failure: function(response, opts) { - Ext.Msg.alert(gettext('Error'), response.htmlStatus); - }, + failure: response => Ext.Msg.alert(gettext('Error'), response.htmlStatus), success: function(response, options) { - var data = response.result.data; + let data = response.result.data; addKeepReasons(data, params); view.prune_store.setData(data); }, @@ -259,6 +263,7 @@ Ext.define('PBS.DataStorePrune', { items: [{ xtype: 'pbsDataStorePruneInputPanel', url: '/api2/extjs/admin/datastore/' + me.datastore + "/prune", + ns: me.ns, backup_type: me.backup_type, backup_id: me.backup_id, }], diff --git a/www/window/BackupGroupChangeOwner.js b/www/window/BackupGroupChangeOwner.js index 9da34a3b..b47ddfbd 100644 --- a/www/window/BackupGroupChangeOwner.js +++ b/www/window/BackupGroupChangeOwner.js @@ -29,6 +29,9 @@ Ext.define('PBS.BackupGroupChangeOwner', { onGetValues: function(values) { values["backup-type"] = me.backup_type; values["backup-id"] = me.backup_id; + if (me.ns && me.ns !== '') { + values['backup-ns'] = me.ns; + } return values; },