]>
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
) {
64 if (me
.lastText
=== text
&& me
.lastUsage
=== usage
) {
70 var label
= me
.getComponent('label');
71 label
.update(Ext
.apply(label
.data
, { title
: me
.title
, usage
: text
}));
73 if (usage
!== undefined && me
.printBar
&& Ext
.isNumeric(usage
) && usage
>= 0) {
74 let progressBar
= me
.getComponent('progress');
75 progressBar
.updateProgress(usage
, '');
76 if (usage
> me
.criticalThreshold
) {
77 progressBar
.removeCls('warning');
78 progressBar
.addCls('critical');
79 } else if (usage
> me
.warningThreshold
) {
80 progressBar
.removeCls('critical');
81 progressBar
.addCls('warning');
83 progressBar
.removeCls('warning');
84 progressBar
.removeCls('critical');
89 initComponent: function() {
93 throw "no title defined";
98 me
.getComponent('progress').setVisible(me
.printBar
);
100 me
.updateValue(me
.text
, me
.value
);
101 me
.setIconCls(me
.iconCls
);