ui: tape/ChangerStatus: shortcut Inventory for single drives

like 'load-media'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-04-08 13:39:18 +02:00 committed by Dietmar Maurer
parent dff8ea92aa
commit a316178768

View File

@ -339,26 +339,46 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
return;
}
Ext.create('Proxmox.window.Edit', {
title: gettext('Inventory'),
showTaskViewer: true,
method: 'PUT',
url: '/api2/extjs/tape/drive',
submitUrl: function(url, values) {
let drive = values.drive;
delete values.drive;
return `${url}/${encodeURIComponent(drive)}/inventory`;
},
let singleDrive = me.drives.length === 1 ? me.drives[0] : undefined;
items: [
{
xtype: 'pbsDriveSelector',
fieldLabel: gettext('Drive'),
name: 'drive',
changer: changer,
if (singleDrive !== undefined) {
Proxmox.Utils.API2Request({
method: 'PUT',
url: `/api2/extjs/tape/drive/${singleDrive}/inventory`,
success: function(response, opt) {
Ext.create('Proxmox.window.TaskViewer', {
upid: response.result.data,
taskDone: function(success) {
me.reload();
},
}).show();
},
],
}).show();
failure: function(response, opt) {
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
},
});
} else {
Ext.create('Proxmox.window.Edit', {
title: gettext('Inventory'),
showTaskViewer: true,
method: 'PUT',
url: '/api2/extjs/tape/drive',
submitUrl: function(url, values) {
let drive = values.drive;
delete values.drive;
return `${url}/${encodeURIComponent(drive)}/inventory`;
},
items: [
{
xtype: 'pbsDriveSelector',
fieldLabel: gettext('Drive'),
name: 'drive',
changer: changer,
},
],
}).show();
}
},
scheduleReload: function(time) {