public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 5/7] ui: tape/ChangerStatus: shortcut Inventory for single drives
Date: Thu,  8 Apr 2021 13:39:18 +0200	[thread overview]
Message-ID: <20210408113920.24416-5-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210408113920.24416-1-d.csapak@proxmox.com>

like 'load-media'

Signed-off-by: Dominik Csapak <d.csapak@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





  parent reply	other threads:[~2021-04-08 11:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-08 11:39 [pbs-devel] [PATCH proxmox-backup 1/7] ui: tape/ChangerStatus: add missing property Dominik Csapak
2021-04-08 11:39 ` [pbs-devel] [PATCH proxmox-backup 2/7] ui: tape/ChangerStatus: save assigned drives Dominik Csapak
2021-04-08 11:39 ` [pbs-devel] [PATCH proxmox-backup 3/7] ui: tape/ChangerStatus: rework EraseWindow Dominik Csapak
2021-04-08 11:39 ` [pbs-devel] [PATCH proxmox-backup 4/7] ui: tape/ChangerStatus: shortcut 'load-media' for single drive Dominik Csapak
2021-04-08 11:39 ` Dominik Csapak [this message]
2021-04-08 11:39 ` [pbs-devel] [PATCH proxmox-backup 6/7] ui: tape/ChangerStatus: hide selector for single drives in barcode-label Dominik Csapak
2021-04-08 11:39 ` [pbs-devel] [PATCH proxmox-backup 7/7] ui: tape/DriveStatus: improve status grid a bit Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210408113920.24416-5-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal