ui: tape: convert slot selection on transfer to combogrid
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>
This commit is contained in:
		
				
					committed by
					
						
						Dietmar Maurer
					
				
			
			
				
	
			
			
			
						parent
						
							e36135031d
						
					
				
				
					commit
					70fab5b46e
				
			@ -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);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user