]>
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.6,
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 &&
68 Ext
.isNumeric(usage
) &&
70 var progressBar
= me
.getComponent('progress');
71 progressBar
.updateProgress(usage
, '');
72 if (usage
> me
.criticalThreshold
) {
73 progressBar
.removeCls('warning');
74 progressBar
.addCls('critical');
75 } else if (usage
> me
.warningThreshold
) {
76 progressBar
.removeCls('critical');
77 progressBar
.addCls('warning');
79 progressBar
.removeCls('warning');
80 progressBar
.removeCls('critical');
85 initComponent: function() {
89 throw "no title defined";
94 me
.getComponent('progress').setVisible(me
.printBar
);
96 me
.updateValue(me
.text
, me
.value
);
97 me
.setIconCls(me
.iconCls
);