add RRDTypeSelector class

Mostly copied from pve-manager.

- added gettext translations
- changed class and state name
This commit is contained in:
Dietmar Maurer 2017-08-29 06:25:25 +02:00
parent a7dcbdebb9
commit a0ba293c12
2 changed files with 59 additions and 0 deletions

View File

@ -26,6 +26,7 @@ JSSRC= \
form/Checkbox.js \ form/Checkbox.js \
form/KVComboBox.js \ form/KVComboBox.js \
form/ComboGrid.js \ form/ComboGrid.js \
form/RRDTypeSelector.js \
button/Button.js \ button/Button.js \
grid/ObjectGrid.js \ grid/ObjectGrid.js \
grid/PendingObjectGrid.js \ grid/PendingObjectGrid.js \

58
form/RRDTypeSelector.js Normal file
View File

@ -0,0 +1,58 @@
Ext.define('Proxmox.form.RRDTypeSelector', {
extend: 'Ext.form.field.ComboBox',
alias: ['widget.proxmoxRRDTypeSelector'],
displayField: 'text',
valueField: 'id',
editable: false,
queryMode: 'local',
value: 'hour',
stateEvents: [ 'select' ],
stateful: true,
stateId: 'proxmoxRRDTypeSelection',
store: {
type: 'array',
fields: [ 'id', 'timeframe', 'cf', 'text' ],
data : [
[ 'hour', 'hour', 'AVERAGE',
gettext('Hour') + ' (' + gettext('average') +')' ],
[ 'hourmax', 'hour', 'MAX',
gettext('Hour') + ' (' + gettext('maximum') + ')' ],
[ 'day', 'day', 'AVERAGE',
gettext('Day') + ' (' + gettext('average') + ')' ],
[ 'daymax', 'day', 'MAX',
gettext('Day') + ' (' + gettext('maximum') + ')' ],
[ 'week', 'week', 'AVERAGE',
gettext('Week') + ' (' + gettext('average') + ')' ],
[ 'weekmax', 'week', 'MAX',
gettext('Week') + ' (' + gettext('maximum') + ')' ],
[ 'month', 'month', 'AVERAGE',
gettext('Month') + ' (' + gettext('average') + ')' ],
[ 'monthmax', 'month', 'MAX',
gettext('Month') + ' (' + gettext('maximum') + ')' ],
[ 'year', 'year', 'AVERAGE',
gettext('Year') + ' (' + gettext('average') + ')' ],
[ 'yearmax', 'year', 'MAX',
gettext('Year') + ' (' + gettext('maximum') + ')' ]
]
},
// save current selection in the state Provider so RRDView can read it
getState: function() {
var ind = this.getStore().findExact('id', this.getValue());
var rec = this.getStore().getAt(ind);
if (!rec) {
return;
}
return {
id: rec.data.id,
timeframe: rec.data.timeframe,
cf: rec.data.cf
};
},
// set selection based on last saved state
applyState : function(state) {
if (state && state.id) {
this.setValue(state.id);
}
}
});