[pve-devel] [PATCH widget-toolkit 2/4] show Task warnings differently

Dominik Csapak d.csapak at proxmox.com
Fri Jun 12 13:29:25 CEST 2020


tasks can now show also 'WARNINGS: <count>'
filter it out and provide a 'parse_task_status' function for easy reuse

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/Utils.js         | 17 +++++++++++++++++
 src/css/ext6-pmx.css |  4 ++++
 src/node/Tasks.js    | 22 ++++++++++++++++------
 3 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/src/Utils.js b/src/Utils.js
index c3b13f4..2163794 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -711,6 +711,23 @@ utilities: {
 	return task;
     },
 
+    parse_task_status: function(status) {
+	if (status === 'OK') {
+	    return 'ok';
+	}
+
+	if (status === 'unknown') {
+	    return 'unknown';
+	}
+
+	let match = status.match(/^WARNINGS: (.*)$/);
+	if (match) {
+	    return 'warning';
+	}
+
+	return 'error';
+    },
+
     render_duration: function(value) {
 	if (value === undefined) {
 	    return '-';
diff --git a/src/css/ext6-pmx.css b/src/css/ext6-pmx.css
index a7d446b..df5c73d 100644
--- a/src/css/ext6-pmx.css
+++ b/src/css/ext6-pmx.css
@@ -14,6 +14,10 @@
     background-color: #f3d6d7;
 }
 
+.proxmox-warning-row {
+    background-color: #f5e5d8;
+}
+
 /* some icons have to be color manually */
 .black {
     color: #000;
diff --git a/src/node/Tasks.js b/src/node/Tasks.js
index 3d9267e..5aff06d 100644
--- a/src/node/Tasks.js
+++ b/src/node/Tasks.js
@@ -81,8 +81,13 @@ Ext.define('Proxmox.node.Tasks', {
 		getRowClass: function(record, index) {
 		    let status = record.get('status');
 
-		    if (status && status !== 'OK') {
-			return "proxmox-invalid-row";
+		    if (status) {
+			let parsed = Proxmox.Utils.parse_task_status(status);
+			if (parsed === 'error') {
+			    return "proxmox-invalid-row";
+			} else if (parsed === 'warning') {
+			    return "proxmox-warning-row";
+			}
 		    }
 		    return '';
 		},
@@ -162,14 +167,19 @@ Ext.define('Proxmox.node.Tasks', {
 		    dataIndex: 'status',
 		    width: 200,
 		    renderer: function(value, metaData, record) {
-			if (value === 'OK') {
-			    return 'OK';
-			}
 			if (value === undefined && !record.data.endtime) {
 			    metaData.tdCls = "x-grid-row-loading";
 			    return '';
 			}
-			return "ERROR: " + 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 'ok': // fall-through
+			    case 'warning': // fall-through
+			    default: return value;
+			}
 		    },
 		},
 	    ],
-- 
2.20.1





More information about the pve-devel mailing list