ui: tape inventory - allow to set/clear media status
This commit is contained in:
		| @ -74,7 +74,7 @@ Ext.define('PBS.TapeManagement.TapeInventory', { | |||||||
| 		vault = selection[0].data.location.slice("vault-".length); | 		vault = selection[0].data.location.slice("vault-".length); | ||||||
| 	    } | 	    } | ||||||
| 	    Ext.create('Proxmox.window.Edit', { | 	    Ext.create('Proxmox.window.Edit', { | ||||||
| 		title: gettext('Set Tape Location'), | 		title: gettext('Set Media Location'), | ||||||
| 		url: `/api2/extjs/tape/media/move`, | 		url: `/api2/extjs/tape/media/move`, | ||||||
| 		method: 'POST', | 		method: 'POST', | ||||||
| 		items: [ | 		items: [ | ||||||
| @ -102,6 +102,53 @@ Ext.define('PBS.TapeManagement.TapeInventory', { | |||||||
| 	    }).show(); | 	    }).show(); | ||||||
| 	}, | 	}, | ||||||
|  |  | ||||||
|  | 	setStatus: function() { | ||||||
|  | 	    let me = this; | ||||||
|  | 	    let view = me.getView(); | ||||||
|  | 	    let selection = view.getSelection(); | ||||||
|  | 	    if (!selection || selection.length < 1) { | ||||||
|  | 		return; | ||||||
|  | 	    } | ||||||
|  | 	    let data = selection[0].data; | ||||||
|  |  | ||||||
|  | 	    let uuid = data.uuid; | ||||||
|  | 	    let label = data['label-text']; | ||||||
|  | 	    let status = data.status; | ||||||
|  |  | ||||||
|  | 	    Ext.create('Proxmox.window.Edit', { | ||||||
|  | 		title: gettext('Set Media Status'), | ||||||
|  | 		url: `/api2/extjs/tape/media/list/${uuid}/status`, | ||||||
|  | 		method: 'POST', | ||||||
|  | 		items: [ | ||||||
|  | 		    { | ||||||
|  | 			xtype: 'displayfield', | ||||||
|  | 			name: 'label-text', | ||||||
|  | 			value: label, | ||||||
|  | 			fieldLabel: gettext('Media'), | ||||||
|  | 		    }, | ||||||
|  | 		    { | ||||||
|  | 			xtype: 'proxmoxKVComboBox', | ||||||
|  | 			fieldLabel: gettext('Status'), | ||||||
|  | 			name: 'status', | ||||||
|  | 			value: status, | ||||||
|  | 			emptyText: gettext('Clear Status'), | ||||||
|  | 			comboItems: [ | ||||||
|  | 			    ['__default__', gettext('Clear Status')], | ||||||
|  | 			    ['full', gettext('Full')], | ||||||
|  | 			    ['damaged', gettext('Damaged')], | ||||||
|  | 			    ['retired', gettext('Retired')], | ||||||
|  | 			], | ||||||
|  | 			deleteEmpty: false, | ||||||
|  | 		    }, | ||||||
|  | 		], | ||||||
|  | 		listeners: { | ||||||
|  | 		    destroy: function() { | ||||||
|  | 			me.reload(); | ||||||
|  | 		    }, | ||||||
|  | 		}, | ||||||
|  | 	    }).show(); | ||||||
|  | 	}, | ||||||
|  |  | ||||||
| 	reload: function() { | 	reload: function() { | ||||||
| 	    this.getView().getStore().load({ | 	    this.getView().getStore().load({ | ||||||
| 		params: { 'update-status': false }, | 		params: { 'update-status': false }, | ||||||
| @ -138,11 +185,17 @@ Ext.define('PBS.TapeManagement.TapeInventory', { | |||||||
| 	}, | 	}, | ||||||
| 	{ | 	{ | ||||||
| 	    xtype: 'proxmoxButton', | 	    xtype: 'proxmoxButton', | ||||||
| 	    text: gettext('Set Tape Location'), | 	    text: gettext('Set Location'), | ||||||
| 	    disabled: true, | 	    disabled: true, | ||||||
| 	    handler: 'moveToVault', | 	    handler: 'moveToVault', | ||||||
| 	    enableFn: (rec) => !rec.data.location.startsWith('online-'), | 	    enableFn: (rec) => !rec.data.location.startsWith('online-'), | ||||||
| 	}, | 	}, | ||||||
|  | 	{ | ||||||
|  | 	    xtype: 'proxmoxButton', | ||||||
|  | 	    text: gettext('Set Status'), | ||||||
|  | 	    disabled: true, | ||||||
|  | 	    handler: 'setStatus', | ||||||
|  | 	}, | ||||||
| 	{ | 	{ | ||||||
| 	    xtype: 'proxmoxButton', | 	    xtype: 'proxmoxButton', | ||||||
| 	    text: gettext('Erase'), | 	    text: gettext('Erase'), | ||||||
| @ -173,8 +226,12 @@ Ext.define('PBS.TapeManagement.TapeInventory', { | |||||||
| 	stripeRows: false, // does not work with getRowClass() | 	stripeRows: false, // does not work with getRowClass() | ||||||
|  |  | ||||||
| 	getRowClass: function(record, index) { | 	getRowClass: function(record, index) { | ||||||
|  | 	    let status = record.get('status'); | ||||||
|  | 	    if (status === 'damaged') { | ||||||
|  | 		return "proxmox-invalid-row"; | ||||||
|  | 	    } | ||||||
| 	    let catalog = record.get('catalog'); | 	    let catalog = record.get('catalog'); | ||||||
| 	    return catalog ? '' : "proxmox-invalid-row"; | 	    return catalog ? '' : "proxmox-warning-row"; | ||||||
| 	}, | 	}, | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user