all lists on 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 v2] ui: tape: convert slot selection on transfer to combogrid
Date: Fri, 12 Mar 2021 16:06:27 +0100	[thread overview]
Message-ID: <20210312150627.24552-1-d.csapak@proxmox.com> (raw)

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>
---
changes from v1:
* combined the two uses into an extra widget, saves some code

 www/tape/ChangerStatus.js | 59 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)

diff --git a/www/tape/ChangerStatus.js b/www/tape/ChangerStatus.js
index 599e6320..68316345 100644
--- a/www/tape/ChangerStatus.js
+++ b/www/tape/ChangerStatus.js
@@ -11,6 +11,29 @@ Ext.define('pbs-slot-model', {
     idProperty: 'entry-id',
 });
 
+Ext.define('PBS.TapeManagement.FreeSlotSelector', {
+    extend: 'Proxmox.form.ComboGrid',
+    alias: 'widget.pbsFreeSlotSelector',
+
+    valueField: 'id',
+    displayField: 'id',
+
+    listConfig: {
+	columns: [
+	    {
+		dataIndex: 'id',
+		text: gettext('ID'),
+		flex: 1,
+	    },
+	    {
+		dataIndex: 'type',
+		text: gettext('Type'),
+		flex: 1,
+	    },
+	],
+    },
+});
+
 Ext.define('PBS.TapeManagement.ChangerStatus', {
     extend: 'Ext.panel.Panel',
     alias: 'widget.pbsChangerStatus',
@@ -40,9 +63,12 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 			fieldLabel: gettext('From Slot'),
 		    },
 		    {
-			xtype: 'proxmoxintegerfield',
+			xtype: 'pbsFreeSlotSelector',
 			name: 'to',
 			fieldLabel: gettext('To Slot'),
+			store: {
+			    data: me.free_slots,
+			},
 		    },
 		],
 		listeners: {
@@ -73,9 +99,12 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 			fieldLabel: gettext('From Slot'),
 		    },
 		    {
-			xtype: 'proxmoxintegerfield',
+			xtype: 'pbsFreeSlotSelector',
 			name: 'to',
 			fieldLabel: gettext('To Slot'),
+			store: {
+			    data: me.free_slots.concat(me.free_ie_slots),
+			},
 		    },
 		],
 		listeners: {
@@ -340,6 +369,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 +436,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 +454,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 +486,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





             reply	other threads:[~2021-03-12 15:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-12 15:06 Dominik Csapak [this message]
2021-03-16  7:58 ` [pbs-devel] applied: " Dietmar Maurer

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=20210312150627.24552-1-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal