ui: use Async tools from widget toolkit

The api2 one passes the whole response (for more flexibility) on
reject, so we need to adapt to that.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht
2021-07-09 16:53:11 +02:00
parent 681e096448
commit 3006d70ebe
7 changed files with 26 additions and 50 deletions

View File

@ -37,7 +37,7 @@ Ext.define('PBS.TapeManagement.BackupOverview', {
loadContent: async function() {
let me = this;
let content_response = await PBS.Async.api2({
let content_response = await Proxmox.Async.api2({
url: '/api2/extjs/tape/media/list?update-status=false',
});
let data = {};
@ -122,7 +122,7 @@ Ext.define('PBS.TapeManagement.BackupOverview', {
const media_set = node.data.text;
try {
let list = await PBS.Async.api2({
let list = await Proxmox.Async.api2({
method: 'GET',
url: `/api2/extjs/tape/media/content`,
params: {
@ -224,9 +224,9 @@ Ext.define('PBS.TapeManagement.BackupOverview', {
node.set('datastores', storeNameList);
Proxmox.Utils.setErrorMask(view, false);
node.expand();
} catch (error) {
} catch (response) {
Proxmox.Utils.setErrorMask(view, false);
Ext.Msg.alert('Error', error.toString());
Ext.Msg.alert('Error', response.result.message.toString());
}
},

View File

@ -257,13 +257,13 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
let me = this;
let drive = record.data.name;
try {
await PBS.Async.api2({
await Proxmox.Async.api2({
method: 'POST',
timeout: 5*60*1000,
url: `/api2/extjs/tape/drive/${encodeURIComponent(drive)}/unload`,
});
} catch (error) {
Ext.Msg.alert(gettext('Error'), error);
} catch (response) {
Ext.Msg.alert(gettext('Error'), response.result.message);
}
me.reload();
},
@ -478,7 +478,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
Proxmox.Utils.setErrorMask(view, true);
Proxmox.Utils.setErrorMask(me.lookup('content'));
}
let status_fut = PBS.Async.api2({
let status_fut = Proxmox.Async.api2({
timeout: 5*60*1000,
method: 'GET',
url: `/api2/extjs/tape/changer/${encodeURIComponent(changer)}/status`,
@ -486,12 +486,12 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
cache: use_cache,
},
});
let drives_fut = PBS.Async.api2({
let drives_fut = Proxmox.Async.api2({
timeout: 5*60*1000,
url: `/api2/extjs/tape/drive?changer=${encodeURIComponent(changer)}`,
});
let tapes_fut = PBS.Async.api2({
let tapes_fut = Proxmox.Async.api2({
timeout: 5*60*1000,
url: '/api2/extjs/tape/media/list',
method: 'GET',
@ -589,7 +589,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
Proxmox.Utils.setErrorMask(view);
}
Proxmox.Utils.setErrorMask(me.lookup('content'));
} catch (err) {
} catch (response) {
if (!view || view.isDestroyed) {
return;
}
@ -597,7 +597,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
if (!use_cache) {
Proxmox.Utils.setErrorMask(view);
}
Proxmox.Utils.setErrorMask(me.lookup('content'), err.toString());
Proxmox.Utils.setErrorMask(me.lookup('content'), response.result.message.toString());
}
me.scheduleReload(5000);