ui: storage backup view: Update remove button on protection change

Currently this works in the backup view for containers/VMs, but not in
the storage backup view. Implement that for the latter part too.

Uses the callback functionality of the load() method of the store to
properly update the UI as soon as the loading has finished.
While at it, refactor the same thing in the grid backup view as well,
removing the current hack in the process.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
This commit is contained in:
Christoph Heiss 2023-01-19 10:56:22 +01:00 committed by Thomas Lamprecht
parent 92df2742f5
commit 73e1cfa94c
2 changed files with 12 additions and 10 deletions

View File

@ -79,9 +79,9 @@ Ext.define('PVE.grid.BackupView', {
]); ]);
}; };
var reload = Ext.Function.createBuffered(function() { const reload = Ext.Function.createBuffered((options) => {
if (me.store) { if (me.store) {
me.store.load(); me.store.load(options);
} }
}, 100); }, 100);
@ -300,20 +300,18 @@ Ext.define('PVE.grid.BackupView', {
handler: function(button, event, record) { handler: function(button, event, record) {
let volid = record.data.volid, storage = storagesel.getValue(); let volid = record.data.volid, storage = storagesel.getValue();
let url = `/api2/extjs/nodes/${nodename}/storage/${storage}/content/${volid}`; let url = `/api2/extjs/nodes/${nodename}/storage/${storage}/content/${volid}`;
let newProtection = record.data.protected ? 0 : 1;
Proxmox.Utils.API2Request({ Proxmox.Utils.API2Request({
url: url, url: url,
method: 'PUT', method: 'PUT',
waitMsgTarget: me, waitMsgTarget: me,
params: { params: {
'protected': newProtection, 'protected': record.data.protected ? 0 : 1,
}, },
failure: (response) => Ext.Msg.alert('Error', response.htmlStatus), failure: (response) => Ext.Msg.alert('Error', response.htmlStatus),
success: (response) => { success: () => {
reload(); reload({
// propagate to remove button, fake for event as reload is to slow callback: () => sm.fireEvent('selectionchange', sm, [record]),
record.data.protected = newProtection; // TODO: check if writing is OK! });
sm.fireEvent('selectionchange', sm, [record]);
}, },
}); });
}, },

View File

@ -183,7 +183,11 @@ Ext.define('PVE.storage.BackupView', {
waitMsgTarget: me, waitMsgTarget: me,
params: { 'protected': record.data.protected ? 0 : 1 }, params: { 'protected': record.data.protected ? 0 : 1 },
failure: response => Ext.Msg.alert('Error', response.htmlStatus), failure: response => Ext.Msg.alert('Error', response.htmlStatus),
success: () => me.store.load(), success: () => {
me.store.load({
callback: () => sm.fireEvent('selectionchange', sm, [record]),
});
},
}); });
}, },
}, },