[pbs-devel] [PATCH v2 widget-toolkit 1/7] task status: create helper for formatting

Fabian Ebner f.ebner at proxmox.com
Fri Apr 9 10:44:30 CEST 2021


Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---

New in v2.

 src/Utils.js      | 12 ++++++++++++
 src/node/Tasks.js | 10 +---------
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/Utils.js b/src/Utils.js
index 3fd8f91..21bdbe3 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -736,6 +736,18 @@ utilities: {
 	return 'error';
     },
 
+    format_task_status: function(value) {
+	let parsed = Proxmox.Utils.parse_task_status(value);
+	switch (parsed) {
+	    case 'unknown': return Proxmox.Utils.unknownText;
+	    case 'error': return Proxmox.Utils.errorText + ': ' + value;
+	    case 'warning': return Proxmox.Utils.warningsText +
+		value.replace('WARNINGS', '');
+	    case 'ok': // fall-through
+	    default: return value;
+	}
+    },
+
     render_duration: function(value) {
 	if (value === undefined) {
 	    return '-';
diff --git a/src/node/Tasks.js b/src/node/Tasks.js
index b01f65e..7f20a8a 100644
--- a/src/node/Tasks.js
+++ b/src/node/Tasks.js
@@ -198,15 +198,7 @@ Ext.define('Proxmox.node.Tasks', {
 			    return '';
 			}
 
-			let parsed = Proxmox.Utils.parse_task_status(value);
-			switch (parsed) {
-			    case 'unknown': return Proxmox.Utils.unknownText;
-			    case 'error': return Proxmox.Utils.errorText + ': ' + value;
-			    case 'warning': return Proxmox.Utils.warningsText +
-				value.replace('WARNINGS', '');
-			    case 'ok': // fall-through
-			    default: return value;
-			}
+			return Proxmox.Utils.format_task_status(value);
 		    },
 		},
 	    ],
-- 
2.20.1






More information about the pbs-devel mailing list