ui: datastore: more NS awareness

verify is actually not yet ready in the backend

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-05-10 15:16:28 +02:00
parent e8112eb37b
commit 93b0659ff2
3 changed files with 68 additions and 24 deletions

View File

@ -327,6 +327,7 @@ Ext.define('PBS.DataStoreContent', {
let win = Ext.create('PBS.BackupGroupChangeOwner', { let win = Ext.create('PBS.BackupGroupChangeOwner', {
datastore: view.datastore, datastore: view.datastore,
ns: view.namespace,
backup_type: data.backup_type, backup_type: data.backup_type,
backup_id: data.backup_id, backup_id: data.backup_id,
owner: data.owner, owner: data.owner,
@ -336,7 +337,8 @@ Ext.define('PBS.DataStoreContent', {
}, },
onPrune: function(view, rI, cI, item, e, rec) { onPrune: function(view, rI, cI, item, e, rec) {
view = this.getView(); let me = this;
view = me.getView();
if (!(rec && rec.data)) return; if (!(rec && rec.data)) return;
let data = rec.data; let data = rec.data;
@ -344,28 +346,38 @@ Ext.define('PBS.DataStoreContent', {
if (!view.datastore) return; if (!view.datastore) return;
let win = Ext.create('PBS.DataStorePrune', { Ext.create('PBS.DataStorePrune', {
autoShow: true,
datastore: view.datastore, datastore: view.datastore,
ns: view.namespace,
backup_type: data.backup_type, backup_type: data.backup_type,
backup_id: data.backup_id, backup_id: data.backup_id,
listeners: {
destroy: () => me.reload(),
},
}); });
win.on('destroy', this.reload, this);
win.show();
}, },
verifyAll: function() { verifyAll: function() {
var view = this.getView(); var view = this.getView();
let params = {};
if (view.namespace && view.namespace !== '') {
params['backup-ns'] = view.namespace; // TODO backend?!
}
Proxmox.Utils.API2Request({ Proxmox.Utils.API2Request({
url: `/admin/datastore/${view.datastore}/verify`, url: `/admin/datastore/${view.datastore}/verify`,
params,
method: 'POST', method: 'POST',
failure: function(response) { failure: function(response) {
Ext.Msg.alert(gettext('Error'), response.htmlStatus); Ext.Msg.alert(gettext('Error'), response.htmlStatus);
}, },
success: function(response, options) { success: function(response, options) {
Ext.create('Proxmox.window.TaskViewer', { Ext.create('Proxmox.window.TaskViewer', {
autoShow: true,
upid: response.result.data, 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 "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({ Proxmox.Utils.API2Request({
params: params, params: params,
@ -476,6 +491,9 @@ Ext.define('PBS.DataStoreContent', {
"backup-time": (data['backup-time'].getTime()/1000).toFixed(0), "backup-time": (data['backup-time'].getTime()/1000).toFixed(0),
}; };
} }
if (view.namespace && view.namespace !== '') {
params['backup-ns'] = view.namespace;
}
Ext.create('PBS.window.NotesEdit', { Ext.create('PBS.window.NotesEdit', {
url: url, url: url,
@ -489,12 +507,17 @@ Ext.define('PBS.DataStoreContent', {
let me = this; let me = this;
let view = me.getView(); 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', { Ext.create('Proxmox.window.SafeDestroy', {
url: `/admin/datastore/${view.datastore}/groups`, url: `/admin/datastore/${view.datastore}/groups`,
params: { params,
"backup-type": data.backup_type,
"backup-id": data.backup_id,
},
item: { item: {
id: data.text, id: data.text,
}, },
@ -520,14 +543,18 @@ Ext.define('PBS.DataStoreContent', {
if (btn !== 'yes') { if (btn !== 'yes') {
return; 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({ Proxmox.Utils.API2Request({
url: `/admin/datastore/${view.datastore}/snapshots`, url: `/admin/datastore/${view.datastore}/snapshots`,
params: { params,
"backup-type": data["backup-type"],
"backup-id": data["backup-id"],
"backup-time": (data['backup-time'].getTime()/1000).toFixed(0),
},
method: 'DELETE', method: 'DELETE',
waitMsgTarget: view, waitMsgTarget: view,
failure: function(response, opts) { failure: function(response, opts) {
@ -556,6 +583,9 @@ Ext.define('PBS.DataStoreContent', {
'backup-id': id, 'backup-id': id,
'backup-time': time, 'backup-time': time,
}; };
if (view.namespace && view.namespace !== '') {
params['backup-ns'] = view.namespace;
}
let url = `/api2/extjs/admin/datastore/${view.datastore}/protected`; 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), 'backup-time': (data['backup-time'].getTime()/1000).toFixed(0),
'file-name': file, 'file-name': file,
}; };
if (view.namespace && view.namespace !== '') {
params['backup-ns'] = view.namespace;
}
let idx = file.lastIndexOf('.'); let idx = file.lastIndexOf('.');
let filename = file.slice(0, idx); let filename = file.slice(0, idx);
@ -656,17 +689,20 @@ Ext.define('PBS.DataStoreContent', {
let time = data['backup-time']; let time = data['backup-time'];
let type = data['backup-type']; let type = data['backup-type'];
let timetext = PBS.Utils.render_datetime_utc(data["backup-time"]); 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', { Ext.create('Proxmox.window.FileBrowser', {
title: `${type}/${id}/${timetext}`, title: `${type}/${id}/${timetext}`,
listURL: `/api2/json/admin/datastore/${view.datastore}/catalog`, listURL: `/api2/json/admin/datastore/${view.datastore}/catalog`,
downloadURL: `/api2/json/admin/datastore/${view.datastore}/pxar-file-download`, downloadURL: `/api2/json/admin/datastore/${view.datastore}/pxar-file-download`,
enableTar: true, enableTar: true,
extraParams: { extraParams,
'backup-id': id,
'backup-time': (time.getTime()/1000).toFixed(0),
'backup-type': type,
},
archive: rec.data.filename, archive: rec.data.filename,
}).show(); }).show();
}, },

View File

@ -49,6 +49,9 @@ Ext.define('PBS.Datastore.PruneInputPanel', {
values["backup-type"] = me.backup_type; values["backup-type"] = me.backup_type;
values["backup-id"] = me.backup_id; values["backup-id"] = me.backup_id;
if (me.ns && me.ns !== '') {
values['backup-ns'] = me.ns;
}
return values; return values;
}, },
@ -122,6 +125,9 @@ Ext.define('PBS.Datastore.PruneInputPanel', {
let params = view.getValues(); let params = view.getValues();
params["dry-run"] = true; params["dry-run"] = true;
if (view.ns && view.ns !== '') {
params['backup-ns'] = view.ns;
}
Proxmox.Utils.API2Request({ Proxmox.Utils.API2Request({
url: view.url, url: view.url,
@ -130,11 +136,9 @@ Ext.define('PBS.Datastore.PruneInputPanel', {
callback: function() { callback: function() {
// for easy breakpoint setting // for easy breakpoint setting
}, },
failure: function(response, opts) { failure: response => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
},
success: function(response, options) { success: function(response, options) {
var data = response.result.data; let data = response.result.data;
addKeepReasons(data, params); addKeepReasons(data, params);
view.prune_store.setData(data); view.prune_store.setData(data);
}, },
@ -259,6 +263,7 @@ Ext.define('PBS.DataStorePrune', {
items: [{ items: [{
xtype: 'pbsDataStorePruneInputPanel', xtype: 'pbsDataStorePruneInputPanel',
url: '/api2/extjs/admin/datastore/' + me.datastore + "/prune", url: '/api2/extjs/admin/datastore/' + me.datastore + "/prune",
ns: me.ns,
backup_type: me.backup_type, backup_type: me.backup_type,
backup_id: me.backup_id, backup_id: me.backup_id,
}], }],

View File

@ -29,6 +29,9 @@ Ext.define('PBS.BackupGroupChangeOwner', {
onGetValues: function(values) { onGetValues: function(values) {
values["backup-type"] = me.backup_type; values["backup-type"] = me.backup_type;
values["backup-id"] = me.backup_id; values["backup-id"] = me.backup_id;
if (me.ns && me.ns !== '') {
values['backup-ns'] = me.ns;
}
return values; return values;
}, },