]>
Commit | Line | Data |
---|---|---|
23fd6c53 DC |
1 | Ext.define('PVE.widget.Info',{ |
2 | extend: 'Ext.container.Container', | |
3 | alias: 'widget.pveInfoWidget', | |
4 | ||
5 | layout: { | |
6 | type: 'vbox', | |
7 | align: 'stretch' | |
8 | }, | |
9 | ||
10 | value: 0, | |
11 | maximum: 1, | |
12 | printBar: true, | |
13 | items: [ | |
14 | { | |
15 | xtype: 'component', | |
16 | itemId: 'label', | |
17 | data: { | |
18 | title: '', | |
19 | usage: '' | |
20 | }, | |
21 | tpl: '<div class="left-aligned">{title}</div><div class="right-aligned">{usage}</div>' | |
22 | }, | |
23 | { | |
24 | height: 2, | |
25 | border: 0 | |
26 | }, | |
27 | { | |
28 | xtype: 'progressbar', | |
29 | itemId: 'progress', | |
30 | height: 5, | |
31 | value: 0, | |
32 | animate: true | |
33 | } | |
34 | ], | |
35 | ||
36 | warningThreshold: 0.6, | |
37 | criticalThreshold: 0.9, | |
38 | ||
4926300a DC |
39 | setPrintBar: function(enable) { |
40 | var me = this; | |
41 | me.printBar = enable; | |
42 | me.getComponent('progress').setVisible(enable); | |
43 | }, | |
44 | ||
23fd6c53 DC |
45 | updateValue: function(text, usage) { |
46 | var me = this; | |
47 | var label = me.getComponent('label'); | |
48 | label.update(Ext.apply(label.data, {title: me.title, usage:text})); | |
49 | ||
50 | if (usage !== undefined && | |
51 | me.printBar && | |
52 | Ext.isNumeric(usage) && | |
53 | usage >= 0) { | |
54 | var progressBar = me.getComponent('progress'); | |
55 | progressBar.updateProgress(usage, ''); | |
56 | if (usage > me.criticalThreshold) { | |
57 | progressBar.removeCls('warning'); | |
58 | progressBar.addCls('critical'); | |
59 | } else if (usage > me.warningThreshold) { | |
60 | progressBar.removeCls('critical'); | |
61 | progressBar.addCls('warning'); | |
62 | } else { | |
63 | progressBar.removeCls('warning'); | |
64 | progressBar.removeCls('critical'); | |
65 | } | |
66 | } | |
67 | }, | |
68 | ||
69 | initComponent: function() { | |
70 | var me = this; | |
71 | ||
72 | if (!me.title) { | |
73 | throw "no title defined"; | |
74 | } | |
75 | ||
76 | me.callParent(); | |
77 | ||
78 | me.getComponent('progress').setVisible(me.printBar); | |
79 | ||
80 | me.updateValue(me.text, me.value); | |
81 | } | |
82 | ||
83 | }); |