]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/panel/InfoWidget.js
ui: eslint: enforce "no-extra-parens" rule
[pve-manager.git] / www / manager6 / panel / InfoWidget.js
index fe1f87d37509249790598cede3b14fd967ce946a..f3b070382a4847b9722566b551fcc0cf2a49bd51 100644 (file)
@@ -1,10 +1,10 @@
-Ext.define('PVE.widget.Info',{
+Ext.define('PVE.widget.Info', {
     extend: 'Ext.container.Container',
     alias: 'widget.pveInfoWidget',
 
     layout: {
        type: 'vbox',
-       align: 'stretch'
+       align: 'stretch',
     },
 
     value: 0,
@@ -16,21 +16,28 @@ Ext.define('PVE.widget.Info',{
            itemId: 'label',
            data: {
                title: '',
-               usage: ''
+               usage: '',
+               iconCls: undefined,
            },
-           tpl: '<div class="left-aligned">{title}</div><div class="right-aligned">{usage}</div>'
+           tpl: [
+               '<div class="left-aligned">',
+               '<tpl if="iconCls">',
+               '<i class="{iconCls}"></i> ',
+               '</tpl>',
+               '{title}</div>&nbsp;<div class="right-aligned">{usage}</div>',
+           ],
        },
        {
            height: 2,
-           border: 0
+           border: 0,
        },
        {
            xtype: 'progressbar',
            itemId: 'progress',
            height: 5,
            value: 0,
-           animate: true
-       }
+           animate: true,
+       },
     ],
 
     warningThreshold: 0.6,
@@ -42,10 +49,15 @@ Ext.define('PVE.widget.Info',{
        me.getComponent('progress').setVisible(enable);
     },
 
+    setIconCls: function(iconCls) {
+       var me = this;
+       me.getComponent('label').data.iconCls = iconCls;
+    },
+
     updateValue: function(text, usage) {
        var me = this;
        var label = me.getComponent('label');
-       label.update(Ext.apply(label.data, {title: me.title, usage:text}));
+       label.update(Ext.apply(label.data, { title: me.title, usage: text }));
 
        if (usage !== undefined &&
            me.printBar &&
@@ -78,6 +90,7 @@ Ext.define('PVE.widget.Info',{
        me.getComponent('progress').setVisible(me.printBar);
 
        me.updateValue(me.text, me.value);
-    }
+       me.setIconCls(me.iconCls);
+    },
 
 });