[pbs-devel] [PATCH proxmox-backup 4/7] ui: refactor render_icon code

Dominik Csapak d.csapak at proxmox.com
Mon Oct 5 15:43:14 CEST 2020


we will reuse this later

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/dashboard/TaskSummary.js | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/www/dashboard/TaskSummary.js b/www/dashboard/TaskSummary.js
index 6f2e1d99..0cf049cd 100644
--- a/www/dashboard/TaskSummary.js
+++ b/www/dashboard/TaskSummary.js
@@ -7,30 +7,36 @@ Ext.define('PBS.TaskSummary', {
     controller: {
 	xclass: 'Ext.app.ViewController',
 
-	render_count: function(value, md, record, rowindex, colindex) {
+	render_icon: function(state, count) {
 	    let cls = 'question';
 	    let color = 'faded';
-	    switch (colindex) {
-		case 1:
+	    switch (state) {
+		case "error":
 		    cls = "times-circle";
 		    color = "critical";
 		    break;
-		case 2:
+		case "warning":
 		    cls = "exclamation-circle";
 		    color = "warning";
 		    break;
-		case 3:
+		case "ok":
 		    cls = "check-circle";
 		    color = "good";
 		    break;
 		default: break;
 	    }
 
-	    if (value < 1) {
+	    if (count < 1) {
 		color = "faded";
 	    }
 	    cls += " " + color;
-	    return `<i class="fa fa-${cls}"></i> ${value}`;
+	    return `<i class="fa fa-${cls}"></i>`;
+	},
+
+	render_count: function(value, md, record, rowindex, colindex) {
+	    let me = this;
+	    let icon = me.render_icon(me.states[colindex], value);
+	    return `${icon} ${value}`;
 	},
     },
 
-- 
2.20.1






More information about the pbs-devel mailing list