[pbs-devel] [PATCH proxmox-backup 4/4] ui: tape/ChangerStatus: add 'is labeled' column for tapes

Dominik Csapak d.csapak at proxmox.com
Thu Feb 4 13:56:32 CET 2021


so that a user can see if a tape in a library is not yet labeled

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/tape/ChangerStatus.js | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/www/tape/ChangerStatus.js b/www/tape/ChangerStatus.js
index f7e1b1f4..97294b72 100644
--- a/www/tape/ChangerStatus.js
+++ b/www/tape/ChangerStatus.js
@@ -377,19 +377,31 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 	    try {
 		Proxmox.Utils.setErrorMask(view, true);
 		Proxmox.Utils.setErrorMask(me.lookup('content'));
-		let status = await PBS.Async.api2({
+		let status_fut = PBS.Async.api2({
 		    url: `/api2/extjs/tape/changer/${encodeURIComponent(changer)}/status`,
 		});
-		let drives = await PBS.Async.api2({
+		let drives_fut = PBS.Async.api2({
 		    url: `/api2/extjs/tape/drive?changer=${encodeURIComponent(changer)}`,
 		});
 
+		let tapes_fut = PBS.Async.api2({
+		    url: '/api2/extjs/tape/media/list',
+		});
+
+		let [status, drives, tapes_list] = await Promise.all([status_fut, drives_fut, tapes_fut]);
+
 		let data = {
 		    slot: [],
 		    'import-export': [],
 		    drive: [],
 		};
 
+		let tapes = {};
+
+		for (const tape of tapes_list.result.data) {
+		    tapes[tape['label-text']] = true;
+		}
+
 		let drive_entries = {};
 
 		for (const entry of drives.result.data) {
@@ -403,6 +415,8 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 			entry = Ext.applyIf(entry, drive_entries[entry['entry-id']]);
 		    }
 
+		    entry['is-labeled'] = !!tapes[entry['label-text']];
+
 		    data[type].push(entry);
 		}
 
@@ -520,6 +534,22 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 			    flex: 1,
 			    renderer: (value) => value || '',
 			},
+			{
+			    text: gettext('Labeled'),
+			    dataIndex: 'is-labeled',
+			    width: 80,
+			    renderer: function(value, mD, record) {
+				if (!record.data['label-text']) {
+				    return "";
+				}
+
+				if (record.data['label-text'].startsWith("CLN")) {
+				    return "";
+				}
+
+				return Proxmox.Utils.format_boolean(value);
+			    },
+			},
 			{
 			    text: gettext('Actions'),
 			    xtype: 'actioncolumn',
-- 
2.20.1






More information about the pbs-devel mailing list