From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id C01C37863C for ; Fri, 30 Apr 2021 09:55:56 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AED9D252D4 for ; Fri, 30 Apr 2021 09:55:56 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id EB639252CB for ; Fri, 30 Apr 2021 09:55:55 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C646F428A5 for ; Fri, 30 Apr 2021 09:55:55 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Fri, 30 Apr 2021 09:55:54 +0200 Message-Id: <20210430075554.27099-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.048 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment PROLO_LEO1 0.1 Meta Catches all Leo drug variations so far SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [record.data, rec.data] Subject: [pbs-devel] [PATCH proxmox-backup] ui: tape: handle tapes in changers without barcode X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Apr 2021 07:55:56 -0000 by checking for definedness of the label (tapes without barcode have the empty string as label-text) and falling back to the source slot for the load action Signed-off-by: Dominik Csapak --- www/tape/ChangerStatus.js | 62 ++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/www/tape/ChangerStatus.js b/www/tape/ChangerStatus.js index ff8a436c..c996aaeb 100644 --- a/www/tape/ChangerStatus.js +++ b/www/tape/ChangerStatus.js @@ -7,6 +7,12 @@ Ext.define('pbs-slot-model', { return data.state !== undefined; }, }, + { + name: 'is-empty', + calculate: function(data) { + return data['label-text'] === undefined; + }, + }, ], idProperty: 'entry-id', }); @@ -179,17 +185,19 @@ Ext.define('PBS.TapeManagement.ChangerStatus', { let me = this; let view = me.getView(); let label = record.data['label-text']; + let slot = record.data['entry-id']; let changer = encodeURIComponent(view.changer); let singleDrive = me.drives.length === 1 ? me.drives[0] : undefined; + let apiCall = label !== undefined ? 'load-media' : 'load-slot'; + let params = label !== undefined ? { 'label-text': label } : { 'source-slot': slot }; + if (singleDrive !== undefined) { Proxmox.Utils.API2Request({ method: 'POST', - params: { - 'label-text': label, - }, - url: `/api2/extjs/tape/drive/${singleDrive}/load-media`, + params, + url: `/api2/extjs/tape/drive/${singleDrive}/${apiCall}`, success: function(response, opt) { Ext.create('Proxmox.window.TaskProgress', { upid: response.result.data, @@ -213,15 +221,21 @@ Ext.define('PBS.TapeManagement.ChangerStatus', { submitUrl: function(url, values) { let drive = values.drive; delete values.drive; - return `${url}/${encodeURIComponent(drive)}/load-media`; + return `${url}/${encodeURIComponent(drive)}/${apiCall}`; }, items: [ - { + label !== undefined ? { xtype: 'displayfield', name: 'label-text', value: label, submitValue: true, fieldLabel: gettext('Media'), + } : { + xtype: 'displayfield', + name: 'source-slot', + value: slot, + submitValue: true, + fieldLabel: gettext('Source Slot'), }, { xtype: 'pbsDriveSelector', @@ -589,6 +603,14 @@ Ext.define('PBS.TapeManagement.ChangerStatus', { me.scheduleReload(5000); }, + renderLabel: function(value) { + if (value !== undefined) { + return value; + } + + return Ext.htmlEncode(""); + }, + renderIsLabeled: function(value, mD, record) { if (!record.data['label-text']) { return ""; @@ -704,7 +726,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', { text: gettext("Content"), dataIndex: 'label-text', flex: 1, - renderer: (value) => value || '', + renderer: 'renderLabel', }, { text: gettext('Inventory'), @@ -721,19 +743,19 @@ Ext.define('PBS.TapeManagement.ChangerStatus', { iconCls: 'fa fa-rotate-90 fa-exchange', handler: 'slotTransfer', tooltip: gettext('Transfer'), - isDisabled: (v, r, c, i, rec) => !rec.data['label-text'], + isDisabled: (v, r, c, i, rec) => rec.data['is-empty'], }, { iconCls: 'fa fa-trash-o', handler: 'format', tooltip: gettext('Format'), - isDisabled: (v, r, c, i, rec) => !rec.data['label-text'], + isDisabled: (v, r, c, i, rec) => rec.data['is-empty'], }, { iconCls: 'fa fa-rotate-90 fa-upload', handler: 'load', tooltip: gettext('Load'), - isDisabled: (v, r, c, i, rec) => !rec.data['label-text'], + isDisabled: (v, r, c, i, rec) => rec.data['is-empty'], }, ], }, @@ -765,7 +787,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', { handler: 'labelMedia', iconCls: 'fa fa-barcode', disabled: true, - enableFn: (rec) => rec.data["label-text"] !== undefined, + enableFn: (rec) => !rec.data["is-empty"], }, { text: gettext('Catalog'), @@ -773,7 +795,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', { handler: 'catalog', iconCls: 'fa fa-book', disabled: true, - enableFn: (rec) => rec.data["label-text"] !== undefined, + enableFn: (rec) => !rec.data["is-empty"], }, { text: gettext('Format'), @@ -781,7 +803,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', { handler: 'format-inserted', iconCls: 'fa fa-trash-o', disabled: true, - enableFn: (rec) => rec.data["label-text"] !== undefined, + enableFn: (rec) => !rec.data["is-empty"], dangerous: true, confirmMsg: gettext('Are you sure you want to format the inserted tape?'), }, @@ -805,7 +827,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', { text: gettext("Content"), dataIndex: 'label-text', flex: 1, - renderer: (value) => value || '', + renderer: 'renderLabel', }, { text: gettext('Inventory'), @@ -859,25 +881,25 @@ Ext.define('PBS.TapeManagement.ChangerStatus', { iconCls: 'fa fa-rotate-270 fa-upload', handler: 'unload', tooltip: gettext('Unload'), - isDisabled: (v, r, c, i, rec) => !rec.data['label-text'] || rec.data['is-blocked'], + isDisabled: (v, r, c, i, rec) => rec.data['is-empty'] || rec.data['is-blocked'], }, { iconCls: 'fa fa-hdd-o', handler: 'cartridgeMemory', tooltip: gettext('Cartridge Memory'), - isDisabled: (v, r, c, i, rec) => !rec.data['label-text'] || rec.data['is-blocked'], + isDisabled: (v, r, c, i, rec) => rec.data['is-empty'] || rec.data['is-blocked'], }, { iconCls: 'fa fa-line-chart', handler: 'volumeStatistics', tooltip: gettext('Volume Statistics'), - isDisabled: (v, r, c, i, rec) => !rec.data['label-text'] || rec.data['is-blocked'], + isDisabled: (v, r, c, i, rec) => rec.data['is-empty'] || rec.data['is-blocked'], }, { iconCls: 'fa fa-tag', handler: 'readLabel', tooltip: gettext('Read Label'), - isDisabled: (v, r, c, i, rec) => !rec.data['label-text'] || rec.data['is-blocked'], + isDisabled: (v, r, c, i, rec) => rec.data['is-empty'] || rec.data['is-blocked'], }, { iconCls: 'fa fa-info-circle', @@ -910,7 +932,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', { { text: gettext("Content"), dataIndex: 'label-text', - renderer: (value) => value || '', + renderer: 'renderLabel', flex: 1, }, { @@ -927,7 +949,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', { iconCls: 'fa fa-rotate-270 fa-upload', handler: 'importTape', tooltip: gettext('Import'), - isDisabled: (v, r, c, i, rec) => !rec.data['label-text'], + isDisabled: (v, r, c, i, rec) => rec.data['is-empty'], }, ], width: 80, -- 2.20.1