From 90d7425afe0bea508756f603f1b6130c6b3631c3 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Mon, 5 Oct 2020 15:43:14 +0200 Subject: [PATCH] ui: refactor render_icon code we will reuse this later Signed-off-by: Dominik Csapak --- 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 5e2a4b13..fcf32ab1 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 ` ${value}`; + return ``; + }, + + render_count: function(value, md, record, rowindex, colindex) { + let me = this; + let icon = me.render_icon(me.states[colindex], value); + return `${icon} ${value}`; }, },