]> git.proxmox.com Git - pve-manager.git/commitdiff
refactor health icons
authorDominik Csapak <d.csapak@proxmox.com>
Tue, 22 Nov 2016 11:32:10 +0000 (12:32 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 22 Nov 2016 15:36:46 +0000 (16:36 +0100)
instead of setting them manually every time, factor them out in a
get_health_icon function

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
www/manager6/Utils.js
www/manager6/dc/Health.js
www/manager6/dc/NodeView.js

index c824b97745d3b540e04ef5bc739a543cb47fa783..f86eea81f0dd69d2680e4c19678e8a9e7562eaaf 100644 (file)
@@ -69,6 +69,36 @@ Ext.define('PVE.Utils', { utilities: {
        solaris: 'Solaris Kernel'
     },
 
+    get_health_icon: function(state, circle) {
+       if (circle === undefined) {
+           circle = false;
+       }
+
+       if (state === undefined) {
+           state = 'uknown';
+       }
+
+       var icon = 'faded fa-question';
+       switch(state) {
+           case 'good':
+               icon = 'good fa-check';
+               break;
+           case 'warning':
+               icon = 'warning fa-exclamation';
+               break;
+           case 'critical':
+               icon = 'critical fa-times';
+               break;
+           default: break;
+       }
+
+       if (circle) {
+           icon += '-circle';
+       }
+
+       return icon;
+    },
+
     render_kvm_ostype: function (value) {
        if (!value) {
            return gettext('Other OS types');
index 1215857064b063bb4462df8764d036412a8aa746..f4e78e353faac8cfd84532cb6bdf80a87cd81abf 100644 (file)
@@ -25,7 +25,7 @@ Ext.define('PVE.dc.Health', {
        }
 
        var cluster = {
-           iconCls:'good fa-check-circle',
+           iconCls: PVE.Utils.get_health_icon('good', true),
            text: gettext("Standalone node - no cluster defined")
        };
 
@@ -48,7 +48,7 @@ Ext.define('PVE.dc.Health', {
                cluster.text += gettext("Quorate") + ": ";
                cluster.text += PVE.Utils.format_boolean(item.data.quorate);
                if (item.data.quorate != 1) {
-                   cluster.iconCls = 'critical fa-times-circle';
+                   cluster.iconCls = PVE.Utils.get_health_icon('critical', true);
                }
 
                numNodes = item.data.nodes;
index af5c6e015aeb01d6f72f8e1f3b18b2b0052344f9..e65235e30a904804565f1ce601da17cbeb8ed130 100644 (file)
@@ -25,12 +25,8 @@ Ext.define('PVE.dc.NodeView', {
            sortable: true,
            dataIndex: 'online',
            renderer: function(value) {
-               var icon = '<i class="fa good fa-check"></i>';
-               if (!value) {
-                   icon = '<i class="fa critical fa-times"></i>';
-               }
-
-               return icon;
+               var cls = (value)?'good':'critical';
+               return  '<i class="fa ' + PVE.Utils.get_health_icon(cls) + '"><i/>';
            }
        },
        {