ui: refactor render_icon code

we will reuse this later

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2020-10-05 15:43:14 +02:00 committed by Thomas Lamprecht
parent 2d81f7b0c0
commit 90d7425afe
1 changed files with 13 additions and 7 deletions

View File

@ -7,30 +7,36 @@ Ext.define('PBS.TaskSummary', {
controller: { controller: {
xclass: 'Ext.app.ViewController', xclass: 'Ext.app.ViewController',
render_count: function(value, md, record, rowindex, colindex) { render_icon: function(state, count) {
let cls = 'question'; let cls = 'question';
let color = 'faded'; let color = 'faded';
switch (colindex) { switch (state) {
case 1: case "error":
cls = "times-circle"; cls = "times-circle";
color = "critical"; color = "critical";
break; break;
case 2: case "warning":
cls = "exclamation-circle"; cls = "exclamation-circle";
color = "warning"; color = "warning";
break; break;
case 3: case "ok":
cls = "check-circle"; cls = "check-circle";
color = "good"; color = "good";
break; break;
default: break; default: break;
} }
if (value < 1) { if (count < 1) {
color = "faded"; color = "faded";
} }
cls += " " + color; 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}`;
}, },
}, },