/**
* Project AMDA-NG
* Name StatisticsUI.js
* @class amdaUI.statisticsUI
* @extends Ext.container.Container
* @brief Statistics Module UI definition (View)
* @author elena
*/
Ext.define('amdaUI.StatisticsUI', {
extend: 'Ext.container.Container',
alias: 'widget.panelStatistics',
requires : [
// 'amdaModel.Function'
'amdaUI.TimeSelectorUI'
],
statics : {
// functionStore : null
},
constructor: function(config) {
this.init(config);
this.callParent(arguments);
// if (this.object) this.loadObject();
},
addParam : function(ParamName,isLeaf)
{
var r = Ext.create('amdaModel.AmdaObject', { name: ParamName });
this.paramGrid.getStore().add(r);
this.paramGrid.getSelectionModel().select(this.paramGrid.getStore().getCount()-1);
},
addTT : function(TTname,TTid)
{
this.timeSelector.addTT(TTname, TTid); ;
},
generateCatalog : function(){
var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.statistics.id);
if (module)
module.linkedNode.execute();
},
/**
* update this.object from form
*/
updateObject : function(){
// get the basic form of the left
var basicForm = this.formPanel.items.items[0].getForm();
var updateStatus = true;
var formValues = basicForm.getValues();
// this.object.set('name',formValues.name);
// this.object.set('description',formValues.description);
var recs = this.paramGrid.getStore().getNewRecords();
var paramArr = new Array();
Ext.Array.each(recs, function(rec, index,allItems){
var obj = new Object();
obj.param = rec.get('name');
obj.function = rec.get('function');
paramArr.push(obj);
});
this.object.set('parameter', paramArr);
var timeSource = this.timeSelector.getActiveTimeSource();
if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0] // timeSource 'TimeTable'
&& this.timeSelector.TTGrid.getStore().count() == 0) {
myDesktopApp.warningMsg('You\'ve chosen Time Selection `by TimeTable` but no timeTable was added!'
+'
You must add one or choose Time Selection `by Interval`');
return false;
}
// basicForm.updateRecord(this.object);
this.object.set('timesrc', timeSource);
// set valid intervals into TimeTable object
if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items);
return updateStatus;
},
/**
* Check if changes were made before closing window
* @return true if changes
*/
fclose : function() {
if (this.status == null)
return false;
var isDirty = this.formPanel.getForm().isDirty() || (this.status.isModified) || (this.status.nbModified > 0) || (this.status.nbNew > 0);
return isDirty;
},
/**
* View configuration
*/
init : function (config) {
// var functions = Ext.create('Ext.data.Store', {
// fields: ['id', 'name'],
// data : [
// {"id":"min", "name":"MIN"},
// {"id":"max", "name":"MAX"},
// {"id":"mean","name":"MEAN"}
// ]
// });
this.fieldName = new Ext.form.field.Text({
fieldLabel: 'Catalog Name',
allowBlank : false,
stripCharsRe: /(^\s+|\s+$)/g,
emptyText: 'Please no spaces!',
name: 'name',
// anchor: '100%',
validateOnChange: false,
validateOnBlur: false,
validFlag: false,
validator : function() {
return this.validFlag;
}
});
var ttStore = Ext.create('Ext.data.Store',
{
fields: [ 'name', 'hidden_id']
});
this.timeSelector = new amdaUI.TimeSelectorUI({id: 'statisticsTimeSelector', height : 160});
var store = Ext.create('Ext.data.Store',
{
fields: ['name', 'function']
});
this.paramGrid = Ext.create('Ext.grid.Panel', {
title: 'Select Parameter & Apply Function',
selType : 'rowmodel',
// flex: 2,
height :250,
store : store,
columns: [
{ xtype: 'rownumberer' },
{ header: 'parameter', dataIndex: 'name', menuDisabled : true, sortable : false },
{ header: 'function', dataIndex: 'function', menuDisabled : true, sortable : false,
editor: {
xtype: 'combo', queryMode : 'local',
// emptyText : 'please click to select function',
store: [ 'min', 'max', 'mean' ],
triggerAction: 'all',
// lazyInit: false,
listeners: {
focus: function(obj) {
obj.expand();
}
}
},
renderer: function(v)
{
if(v != null && v.length > 0 )
return v;
else
return 'click to select';
}
},
{ menuDisabled : true, width: 30, renderer: function(){
return '