[pbs-devel] [PATCH proxmox-backup 5/7] ui: tape/ChangerStatus: shortcut Inventory for single drives

Dominik Csapak d.csapak at proxmox.com
Thu Apr 8 13:39:18 CEST 2021


like 'load-media'

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/tape/ChangerStatus.js | 56 ++++++++++++++++++++++++++-------------
 1 file changed, 38 insertions(+), 18 deletions(-)

diff --git a/www/tape/ChangerStatus.js b/www/tape/ChangerStatus.js
index 22330d3b..9b1d8c47 100644
--- a/www/tape/ChangerStatus.js
+++ b/www/tape/ChangerStatus.js
@@ -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) {
-- 
2.20.1






More information about the pbs-devel mailing list