]> git.proxmox.com Git - proxmox-widget-toolkit.git/blame - form/RRDTypeSelector.js
use eslint and execute as check target
[proxmox-widget-toolkit.git] / form / RRDTypeSelector.js
CommitLineData
a0ba293c
DM
1Ext.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',
01031528 10 stateEvents: ['select'],
a0ba293c
DM
11 stateful: true,
12 stateId: 'proxmoxRRDTypeSelection',
13 store: {
14 type: 'array',
01031528
TL
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 ],
a0ba293c
DM
38 },
39 // save current selection in the state Provider so RRDView can read it
40 getState: function() {
05a977a2
TL
41 let ind = this.getStore().findExact('id', this.getValue());
42 let rec = this.getStore().getAt(ind);
a0ba293c 43 if (!rec) {
05a977a2 44 return undefined;
a0ba293c
DM
45 }
46 return {
47 id: rec.data.id,
48 timeframe: rec.data.timeframe,
01031528 49 cf: rec.data.cf,
a0ba293c
DM
50 };
51 },
52 // set selection based on last saved state
01031528 53 applyState: function(state) {
a0ba293c
DM
54 if (state && state.id) {
55 this.setValue(state.id);
56 }
01031528 57 },
a0ba293c 58});