From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 60E94716F9
 for <pbs-devel@lists.proxmox.com>; Thu,  8 Apr 2021 13:39:53 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 3C4151A99B
 for <pbs-devel@lists.proxmox.com>; Thu,  8 Apr 2021 13:39:23 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 878AE1A965
 for <pbs-devel@lists.proxmox.com>; Thu,  8 Apr 2021 13:39:21 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 4C0CE45A14
 for <pbs-devel@lists.proxmox.com>; Thu,  8 Apr 2021 13:39:21 +0200 (CEST)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Thu,  8 Apr 2021 13:39:15 +0200
Message-Id: <20210408113920.24416-2-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20210408113920.24416-1-d.csapak@proxmox.com>
References: <20210408113920.24416-1-d.csapak@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.168 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_DNSWL_MED        -2.3 Sender listed at https://www.dnswl.org/,
 medium trust
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pbs-devel] [PATCH proxmox-backup 2/7] ui: tape/ChangerStatus: save
 assigned drives
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Thu, 08 Apr 2021 11:39:53 -0000

so that we can shortcut later if we only have one

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/tape/ChangerStatus.js | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/www/tape/ChangerStatus.js b/www/tape/ChangerStatus.js
index f8bff531..fb4ad1e3 100644
--- a/www/tape/ChangerStatus.js
+++ b/www/tape/ChangerStatus.js
@@ -369,6 +369,13 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 	    me.reload_full(false);
 	},
 
+	drives: [],
+
+	updateDrives: function(drives) {
+	    let me = this;
+	    me.drives = drives;
+	},
+
 	free_slots: [],
 	free_ie_slots: [],
 
@@ -440,11 +447,15 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 		let free_slots = [];
 		let free_ie_slots = [];
 
+		let valid_drives = [];
+
 		for (let entry of status.result.data) {
 		    let type = entry['entry-kind'];
+		    let id = entry['entry-id'];
 
-		    if (type === 'drive' && drive_entries[entry['entry-id']] !== undefined) {
-			entry = Ext.applyIf(entry, drive_entries[entry['entry-id']]);
+		    if (type === 'drive' && drive_entries[id] !== undefined) {
+			entry = Ext.applyIf(entry, drive_entries[id]);
+			valid_drives.push(drive_entries[id].name);
 		    }
 
 		    if (tapes[entry['label-text']] !== undefined) {
@@ -458,12 +469,12 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 		    if (!entry['label-text'] && type !== 'drive') {
 			if (type === 'slot') {
 			    free_slots.push({
-				id: entry['entry-id'],
+				id,
 				type,
 			    });
 			} else {
 			    free_ie_slots.push({
-				id: entry['entry-id'],
+				id,
 				type,
 			    });
 			}
@@ -488,6 +499,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 		me.lookup('drives').getSelectionModel().fireEvent('selectionchange', me);
 
 		me.updateFreeSlots(free_slots, free_ie_slots);
+		me.updateDrives(valid_drives);
 
 		if (!use_cache) {
 		    Proxmox.Utils.setErrorMask(view);
-- 
2.20.1