ui: tape/ChangerStatus: shortcut 'load-media' for single drive

if a changer only has a single drive, there is no point in showing
a window with a DriveSelector, just do want the user wanted.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-04-08 13:39:17 +02:00 committed by Dietmar Maurer
parent 88e1f7997c
commit dff8ea92aa
1 changed files with 52 additions and 30 deletions

View File

@ -163,7 +163,28 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
let label = record.data['label-text']; let label = record.data['label-text'];
let changer = encodeURIComponent(view.changer); let changer = encodeURIComponent(view.changer);
let singleDrive = me.drives.length === 1 ? me.drives[0] : undefined;
if (singleDrive !== undefined) {
Proxmox.Utils.API2Request({
method: 'POST',
params: {
'label-text': label,
},
url: `/api2/extjs/tape/drive/${singleDrive}/load-media`,
success: function(response, opt) {
Ext.create('Proxmox.window.TaskProgress', {
upid: response.result.data,
taskDone: function(success) {
me.reload();
},
}).show();
},
failure: function(response, opt) {
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
},
});
} else {
Ext.create('Proxmox.window.Edit', { Ext.create('Proxmox.window.Edit', {
isCreate: true, isCreate: true,
autoShow: true, autoShow: true,
@ -197,6 +218,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
}, },
}, },
}); });
}
}, },
unload: async function(v, rI, cI, button, el, record) { unload: async function(v, rI, cI, button, el, record) {