]>
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 | ||
39 | updateValue: function(text, usage) { | |
40 | var me = this; | |
41 | var label = me.getComponent('label'); | |
42 | label.update(Ext.apply(label.data, {title: me.title, usage:text})); | |
43 | ||
44 | if (usage !== undefined && | |
45 | me.printBar && | |
46 | Ext.isNumeric(usage) && | |
47 | usage >= 0) { | |
48 | var progressBar = me.getComponent('progress'); | |
49 | progressBar.updateProgress(usage, ''); | |
50 | if (usage > me.criticalThreshold) { | |
51 | progressBar.removeCls('warning'); | |
52 | progressBar.addCls('critical'); | |
53 | } else if (usage > me.warningThreshold) { | |
54 | progressBar.removeCls('critical'); | |
55 | progressBar.addCls('warning'); | |
56 | } else { | |
57 | progressBar.removeCls('warning'); | |
58 | progressBar.removeCls('critical'); | |
59 | } | |
60 | } | |
61 | }, | |
62 | ||
63 | initComponent: function() { | |
64 | var me = this; | |
65 | ||
66 | if (!me.title) { | |
67 | throw "no title defined"; | |
68 | } | |
69 | ||
70 | me.callParent(); | |
71 | ||
72 | me.getComponent('progress').setVisible(me.printBar); | |
73 | ||
74 | me.updateValue(me.text, me.value); | |
75 | } | |
76 | ||
77 | }); |