[pbs-devel] [PATCH proxmox-backup 2/5] ui: tape: refactor renderDriveState to Utils

Dominik Csapak d.csapak at proxmox.com
Tue Mar 2 12:19:37 CET 2021


we will use this later again

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/Utils.js              | 16 ++++++++++++++++
 www/tape/ChangerStatus.js | 18 +-----------------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/www/Utils.js b/www/Utils.js
index c531edbb..778dad24 100644
--- a/www/Utils.js
+++ b/www/Utils.js
@@ -603,6 +603,22 @@ Ext.define('PBS.Utils', {
 	}).show();
     },
 
+    renderDriveState: function(value, md) {
+	if (!value) {
+	    return gettext('Idle');
+	}
+
+	let icon = '<i class="fa fa-spinner fa-pulse fa-fw"></i>';
+
+	if (value.startsWith("UPID")) {
+	    let upid = Proxmox.Utils.parse_task_upid(value);
+	    md.tdCls = "pointer";
+	    return `${icon} ${upid.desc}`;
+	}
+
+	return `${icon} ${value}`;
+    },
+
 });
 
 Ext.define('PBS.Async', {
diff --git a/www/tape/ChangerStatus.js b/www/tape/ChangerStatus.js
index 2f9c41f8..42306007 100644
--- a/www/tape/ChangerStatus.js
+++ b/www/tape/ChangerStatus.js
@@ -463,22 +463,6 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 	    return status;
 	},
 
-	renderState: function(value, md, record) {
-	    if (!value) {
-		return gettext('Idle');
-	    }
-
-	    let icon = '<i class="fa fa-spinner fa-pulse fa-fw"></i>';
-
-	    if (value.startsWith("UPID")) {
-		let upid = Proxmox.Utils.parse_task_upid(value);
-		md.tdCls = "pointer";
-		return `${icon} ${upid.desc}`;
-	    }
-
-	    return `${icon} ${value}`;
-	},
-
 	control: {
 	    'grid[reference=drives]': {
 		cellclick: function(table, td, ci, rec, tr, ri, e) {
@@ -683,7 +667,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 				    text: gettext('State'),
 				    dataIndex: 'state',
 				    flex: 3,
-				    renderer: 'renderState',
+				    renderer: PBS.Utils.renderDriveState,
 				},
 				{
 				    text: gettext("Vendor"),
-- 
2.20.1






More information about the pbs-devel mailing list