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 C5A4669F03
 for <pbs-devel@lists.proxmox.com>; Fri, 12 Mar 2021 16:00:25 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id B742A344C4
 for <pbs-devel@lists.proxmox.com>; Fri, 12 Mar 2021 16:00:25 +0100 (CET)
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 840FD344B9
 for <pbs-devel@lists.proxmox.com>; Fri, 12 Mar 2021 16:00:24 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 49CC3463E4
 for <pbs-devel@lists.proxmox.com>; Fri, 12 Mar 2021 16:00:24 +0100 (CET)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Fri, 12 Mar 2021 16:00:23 +0100
Message-Id: <20210312150023.11376-1-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.188 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] ui: tape: convert slot selection
 on transfer to combogrid
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: Fri, 12 Mar 2021 15:00:25 -0000

this is much handier than number field, and the user can instantly
see which one is an import/export slot

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

diff --git a/www/tape/ChangerStatus.js b/www/tape/ChangerStatus.js
index 599e6320..13c42ada 100644
--- a/www/tape/ChangerStatus.js
+++ b/www/tape/ChangerStatus.js
@@ -40,9 +40,31 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 			fieldLabel: gettext('From Slot'),
 		    },
 		    {
-			xtype: 'proxmoxintegerfield',
+			xtype: 'proxmoxComboGrid',
 			name: 'to',
 			fieldLabel: gettext('To Slot'),
+
+			store: {
+			    data: me.free_slots,
+			},
+
+			valueField: 'id',
+			displayField: 'id',
+
+			listConfig: {
+			    columns: [
+				{
+				    dataIndex: 'id',
+				    text: gettext('ID'),
+				    flex: 1,
+				},
+				{
+				    dataIndex: 'type',
+				    text: gettext('Type'),
+				    flex: 1,
+				},
+			    ],
+			},
 		    },
 		],
 		listeners: {
@@ -73,9 +95,31 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 			fieldLabel: gettext('From Slot'),
 		    },
 		    {
-			xtype: 'proxmoxintegerfield',
+			xtype: 'proxmoxComboGrid',
 			name: 'to',
 			fieldLabel: gettext('To Slot'),
+
+			store: {
+			    data: me.free_slots.concat(me.free_ie_slots),
+			},
+
+			valueField: 'id',
+			displayField: 'id',
+
+			listConfig: {
+			    columns: [
+				{
+				    dataIndex: 'id',
+				    text: gettext('ID'),
+				    flex: 1,
+				},
+				{
+				    dataIndex: 'type',
+				    text: gettext('Type'),
+				    flex: 1,
+				},
+			    ],
+			},
 		    },
 		],
 		listeners: {
@@ -340,6 +384,14 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 	    me.reload_full(false);
 	},
 
+	free_slots: [],
+
+	updateFreeSlots: function(free_slots, free_ie_slots) {
+	    let me = this;
+	    me.free_slots = free_slots;
+	    me.free_ie_slots = free_ie_slots;
+	},
+
 	reload_full: async function(use_cache) {
 	    let me = this;
 	    let view = me.getView();
@@ -399,6 +451,9 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 		    drive_entries[entry['changer-drivenum'] || 0] = entry;
 		}
 
+		let free_slots = [];
+		let free_ie_slots = [];
+
 		for (let entry of status.result.data) {
 		    let type = entry['entry-kind'];
 
@@ -414,6 +469,19 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 			entry['is-labeled'] = false;
 		    }
 
+		    if (!entry['label-text'] && type !== 'drive') {
+			if (type === 'slot') {
+			    free_slots.push({
+				id: entry['entry-id'],
+				type,
+			    });
+			} else {
+			    free_ie_slots.push({
+				id: entry['entry-id'],
+				type,
+			    });
+			}
+		    }
 		    data[type].push(entry);
 		}
 
@@ -433,6 +501,8 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 		// manually fire selectionchange to update button status
 		me.lookup('drives').getSelectionModel().fireEvent('selectionchange', me);
 
+		me.updateFreeSlots(free_slots, free_ie_slots);
+
 		if (!use_cache) {
 		    Proxmox.Utils.setErrorMask(view);
 		}
-- 
2.20.1