From 464c409aa36e5ee35dfb923578993c2b3d85f2ba Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 26 Feb 2021 11:06:11 +0100 Subject: [PATCH] ui: tape inventory - allow to set/clear media status --- www/tape/TapeInventory.js | 63 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/www/tape/TapeInventory.js b/www/tape/TapeInventory.js index 508f4a4f..28909754 100644 --- a/www/tape/TapeInventory.js +++ b/www/tape/TapeInventory.js @@ -74,7 +74,7 @@ Ext.define('PBS.TapeManagement.TapeInventory', { vault = selection[0].data.location.slice("vault-".length); } Ext.create('Proxmox.window.Edit', { - title: gettext('Set Tape Location'), + title: gettext('Set Media Location'), url: `/api2/extjs/tape/media/move`, method: 'POST', items: [ @@ -102,6 +102,53 @@ Ext.define('PBS.TapeManagement.TapeInventory', { }).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() { this.getView().getStore().load({ params: { 'update-status': false }, @@ -138,11 +185,17 @@ Ext.define('PBS.TapeManagement.TapeInventory', { }, { xtype: 'proxmoxButton', - text: gettext('Set Tape Location'), + text: gettext('Set Location'), disabled: true, handler: 'moveToVault', enableFn: (rec) => !rec.data.location.startsWith('online-'), }, + { + xtype: 'proxmoxButton', + text: gettext('Set Status'), + disabled: true, + handler: 'setStatus', + }, { xtype: 'proxmoxButton', text: gettext('Erase'), @@ -173,8 +226,12 @@ Ext.define('PBS.TapeManagement.TapeInventory', { stripeRows: false, // does not work with getRowClass() getRowClass: function(record, index) { + let status = record.get('status'); + if (status === 'damaged') { + return "proxmox-invalid-row"; + } let catalog = record.get('catalog'); - return catalog ? '' : "proxmox-invalid-row"; + return catalog ? '' : "proxmox-warning-row"; }, },