]> git.proxmox.com Git - proxmox-widget-toolkit.git/blob - form/RRDTypeSelector.js
override Ext.Components 'validIdRe' to include '@'
[proxmox-widget-toolkit.git] / form / RRDTypeSelector.js
1 Ext.define('Proxmox.form.RRDTypeSelector', {
2 extend: 'Ext.form.field.ComboBox',
3 alias: ['widget.proxmoxRRDTypeSelector'],
4
5 displayField: 'text',
6 valueField: 'id',
7 editable: false,
8 queryMode: 'local',
9 value: 'hour',
10 stateEvents: [ 'select' ],
11 stateful: true,
12 stateId: 'proxmoxRRDTypeSelection',
13 store: {
14 type: 'array',
15 fields: [ 'id', 'timeframe', 'cf', 'text' ],
16 data : [
17 [ 'hour', 'hour', 'AVERAGE',
18 gettext('Hour') + ' (' + gettext('average') +')' ],
19 [ 'hourmax', 'hour', 'MAX',
20 gettext('Hour') + ' (' + gettext('maximum') + ')' ],
21 [ 'day', 'day', 'AVERAGE',
22 gettext('Day') + ' (' + gettext('average') + ')' ],
23 [ 'daymax', 'day', 'MAX',
24 gettext('Day') + ' (' + gettext('maximum') + ')' ],
25 [ 'week', 'week', 'AVERAGE',
26 gettext('Week') + ' (' + gettext('average') + ')' ],
27 [ 'weekmax', 'week', 'MAX',
28 gettext('Week') + ' (' + gettext('maximum') + ')' ],
29 [ 'month', 'month', 'AVERAGE',
30 gettext('Month') + ' (' + gettext('average') + ')' ],
31 [ 'monthmax', 'month', 'MAX',
32 gettext('Month') + ' (' + gettext('maximum') + ')' ],
33 [ 'year', 'year', 'AVERAGE',
34 gettext('Year') + ' (' + gettext('average') + ')' ],
35 [ 'yearmax', 'year', 'MAX',
36 gettext('Year') + ' (' + gettext('maximum') + ')' ]
37 ]
38 },
39 // save current selection in the state Provider so RRDView can read it
40 getState: function() {
41 var ind = this.getStore().findExact('id', this.getValue());
42 var rec = this.getStore().getAt(ind);
43 if (!rec) {
44 return;
45 }
46 return {
47 id: rec.data.id,
48 timeframe: rec.data.timeframe,
49 cf: rec.data.cf
50 };
51 },
52 // set selection based on last saved state
53 applyState : function(state) {
54 if (state && state.id) {
55 this.setValue(state.id);
56 }
57 }
58 });