]>
git.proxmox.com Git - proxmox-widget-toolkit.git/blob - src/panel/InfoWidget.js
1 Ext
.define('Proxmox.widget.Info', {
2 extend
: 'Ext.container.Container',
3 alias
: 'widget.pmxInfoWidget',
23 '<div class="left-aligned">',
25 '<i class="{iconCls}"></i> ',
27 '{title}</div> <div class="right-aligned">{usage}</div>',
43 warningThreshold
: 0.75,
44 criticalThreshold
: 0.9,
46 setPrintBar: function(enable
) {
49 me
.getComponent('progress').setVisible(enable
);
52 setIconCls: function(iconCls
) {
54 me
.getComponent('label').data
.iconCls
= iconCls
;
57 setData: function(data
) {
58 this.updateValue(data
.text
, data
.usage
);
61 updateValue: function(text
, usage
) {
63 var label
= me
.getComponent('label');
64 label
.update(Ext
.apply(label
.data
, { title
: me
.title
, usage
: text
}));
66 if (usage
!== undefined && me
.printBar
&& Ext
.isNumeric(usage
) && usage
>= 0) {
67 let progressBar
= me
.getComponent('progress');
68 progressBar
.updateProgress(usage
, '');
69 if (usage
> me
.criticalThreshold
) {
70 progressBar
.removeCls('warning');
71 progressBar
.addCls('critical');
72 } else if (usage
> me
.warningThreshold
) {
73 progressBar
.removeCls('critical');
74 progressBar
.addCls('warning');
76 progressBar
.removeCls('warning');
77 progressBar
.removeCls('critical');
82 initComponent: function() {
86 throw "no title defined";
91 me
.getComponent('progress').setVisible(me
.printBar
);
93 me
.updateValue(me
.text
, me
.value
);
94 me
.setIconCls(me
.iconCls
);