Commit d80af8968f360309f70ee20aef44971bf8813ddd

Authored by Elena.Budnik
1 parent c218ac10

args for Statistics

js/app/controllers/StatisticsModule.js
... ... @@ -39,7 +39,19 @@ Ext.define('amdaDesktop.StatisticsModule', {
39 39 this.setLinkedNode(amdaModel.StatisticsNode);
40 40 }
41 41 this.callParent(arguments);
42   - },
43   -
  42 + },
  43 +
  44 + saveState: function() {
  45 + var uiContent = this.getUiContent();
  46 + var form = uiContent.down('form').getForm();
  47 + var values = form.getValues();
  48 + // Ext.state.Manager.set(this.id + '_form', values);
  49 + Ext.state.Manager.set('timeinterval', {'startDate' : values.startDate,'stopDate' : values.stopDate });
  50 + },
  51 +
  52 + getState : function() {
  53 + // return Ext.state.Manager.get(this.id + '_form');
  54 + return Ext.state.Manager.get('timeinterval');
  55 + }
44 56  
45 57 });
... ...
js/app/views/StatisticsUI.js
... ... @@ -12,26 +12,77 @@ Ext.define('amdaUI.StatisticsUI', {
12 12 alias: 'widget.panelStatistics',
13 13  
14 14 requires : [
15   -// 'amdaModel.Function'
16   - 'amdaUI.TimeSelectorUI'
  15 + // 'amdaModel.Function'
  16 + 'amdaUI.TimeSelectorUI',
  17 + 'amdaUI.ParamArgumentsPlug',
  18 + 'amdaModel.DownloadParam'
17 19 ],
18 20  
19 21 statics : {
20   -// functionStore : null
  22 + // functionStore : null
21 23 },
22 24  
23 25 constructor: function(config) {
24   - this.init(config);
  26 + this.init(config);
25 27 this.callParent(arguments);
26 28 // if (this.object) this.loadObject();
  29 + //
  30 + var paramArgsPlug = this.getPlugin('statistics-param-arguments-plugin');
  31 + if (paramArgsPlug)
  32 + paramArgsPlug.onApply = this.onApplyParameterArgs;
27 33 },
  34 +
  35 + onApplyParameterArgs : function(parentUI, paramObject) {
  36 + parentUI.paramGrid.getView().refresh();
  37 + },
28 38  
29   - addParam : function(ParamName,isLeaf)
30   - {
31   - var r = Ext.create('amdaModel.AmdaObject', { name: ParamName });
32   - this.paramGrid.getStore().add(r);
33   - this.paramGrid.getSelectionModel().select(this.paramGrid.getStore().getCount()-1);
34   - },
  39 + addParam : function(paramId, isLeaf, needArgs, components)
  40 + {
  41 + // adding the parameter to the paramGrid
  42 + var paramObj = {
  43 + paramid: paramId,
  44 + type: 0,
  45 + 'dim1-is-range': false,
  46 + 'dim1-min-range': 0.,
  47 + 'dim1-max-range': 0.,
  48 + 'dim1-index': '*',
  49 + 'dim2-is-range': false,
  50 + 'dim2-min-range': 0.,
  51 + 'dim2-max-range': 0.,
  52 + 'dim2-index': '*',
  53 + template_args: {}
  54 + };
  55 +
  56 +// if (components) {
  57 +// if (components['index1']) {
  58 +// paramObj['dim1-index'] = components['index1'];
  59 +// ++paramObj['type'];
  60 +// }
  61 +//
  62 +// if (components['index2']) {
  63 +// paramObj['dim2-index'] = components['index2'];
  64 +// ++paramObj['type'];
  65 +// }
  66 +// }
  67 +
  68 + var r = Ext.create('amdaModel.DownloadParam', paramObj);
  69 +
  70 + this.paramGrid.getStore().add(r);
  71 + this.paramGrid.getSelectionModel().select(this.paramGrid.getStore().getCount()-1);
  72 + // var pos = this.paramGrid.store.getCount();
  73 + // this.paramGrid.store.insert(pos,r);
  74 + this.paramGrid.getView().refresh();
  75 +
  76 + if (needArgs)
  77 + this.editParameterArgs(r);
  78 + },
  79 +
  80 + editParameterArgs: function(record) {
  81 + var paramArgsPlug = this.getPlugin('statistics-param-arguments-plugin');
  82 +
  83 + if (paramArgsPlug)
  84 + paramArgsPlug.show('statistics-param-arguments-plugin', record);
  85 + },
35 86  
36 87 addTT : function(TTname,TTid)
37 88 {
... ... @@ -51,48 +102,50 @@ Ext.define('amdaUI.StatisticsUI', {
51 102  
52 103 updateObject : function(){
53 104 // get the basic form of the left
54   - var basicForm = this.formPanel.items.items[0].getForm();
55   - var updateStatus = true;
56   -
57   - var formValues = basicForm.getValues();
58   - // this.object.set('name',formValues.name);
59   - // this.object.set('description',formValues.description);
  105 + var basicForm = this.formPanel.items.items[0].getForm();
  106 + var updateStatus = true;
  107 +
  108 + var formValues = basicForm.getValues();
  109 +// this.object.set('name',formValues.name);
  110 +// this.object.set('description',formValues.description);
60 111  
61   - var recs = this.paramGrid.getStore().getNewRecords();
62   - var paramArr = new Array();
63   -
64   - Ext.Array.each(recs, function(rec, index,allItems)
65   - {
66   - var obj = new Object();
67   - obj.param = rec.get('name');
68   - obj.function = rec.get('function');
69   - if (obj.function == null) {
70   - myDesktopApp.warningMsg('Please select function : `click to select`');
71   - updateStatus = false;
72   - return;
73   - }
74   - paramArr.push(obj);
75   - });
  112 + var recs = this.paramGrid.getStore().getNewRecords();
  113 + var paramArr = new Array();
  114 +
  115 + Ext.Array.each(recs, function(rec, index,allItems)
  116 + {
  117 + var obj = new Object();
  118 + obj.param = rec.get('name');
  119 + obj.function = rec.get('function');
  120 + if (obj.function == null)
  121 + {
  122 + myDesktopApp.warningMsg('Please select function : `click to select`');
  123 + updateStatus = false;
  124 + return;
  125 + }
  126 + paramArr.push(obj);
  127 + });
76 128  
77   - this.object.set('parameter', paramArr);
  129 + this.object.set('parameter', paramArr);
78 130  
79   - var timeSource = this.timeSelector.getActiveTimeSource();
  131 + var timeSource = this.timeSelector.getActiveTimeSource();
80 132  
81   - if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0] // timeSource 'TimeTable'
82   - && this.timeSelector.TTGrid.getStore().count() == 0) {
83   - myDesktopApp.warningMsg('You\'ve chosen Time Selection `by TimeTable` but no timeTable was added!'
84   - +'<br>You must add one or choose Time Selection `by Interval`');
85   - return false;
86   - }
  133 + if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0] // timeSource 'TimeTable'
  134 + && this.timeSelector.TTGrid.getStore().count() == 0)
  135 + {
  136 + myDesktopApp.warningMsg('You\'ve chosen Time Selection `by TimeTable` but no timeTable was added!'
  137 + +'<br>You must add one or choose Time Selection `by Interval`');
  138 + return false;
  139 + }
87 140  
88   - basicForm.updateRecord(this.object);
  141 + basicForm.updateRecord(this.object);
89 142  
90   - this.object.set('timesrc', timeSource);
91   - // set valid intervals into TimeTable object
92   - if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
93   - this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items);
  143 + this.object.set('timesrc', timeSource);
  144 + // set valid intervals into TimeTable object
  145 + if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
  146 + this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items);
94 147  
95   - return updateStatus;
  148 + return updateStatus;
96 149 },
97 150  
98 151 /**
... ... @@ -121,74 +174,80 @@ Ext.define(&#39;amdaUI.StatisticsUI&#39;, {
121 174 // ]
122 175 // });
123 176  
124   - this.fieldName = new Ext.form.field.Text({
125   - fieldLabel: 'Catalog Name',
126   - allowBlank : false,
127   - stripCharsRe: /(^\s+|\s+$)/g,
128   - emptyText: 'Please no spaces!',
129   - name: 'name',
130   -// anchor: '100%',
131   - validateOnChange: false,
132   - validateOnBlur: false,
133   - validFlag: false,
134   - validator : function() {
135   - return this.validFlag;
136   - }
137   - });
138   -
139   - var ttStore = Ext.create('Ext.data.Store',
140   - {
141   - fields: [ 'name', 'hidden_id']
142   - });
  177 + this.fieldName = new Ext.form.field.Text({
  178 + fieldLabel: 'Catalog Name',
  179 + allowBlank : false,
  180 + stripCharsRe: /(^\s+|\s+$)/g,
  181 + emptyText: 'Please no spaces!',
  182 + name: 'name',
  183 + // anchor: '100%',
  184 + validateOnChange: false,
  185 + validateOnBlur: false,
  186 + validFlag: false,
  187 + validator : function() {
  188 + return this.validFlag;
  189 + }
  190 + });
143 191  
144   - this.timeSelector = new amdaUI.TimeSelectorUI({id: 'statisticsTimeSelector', height : 160});
  192 + var ttStore = Ext.create('Ext.data.Store',
  193 + {
  194 + fields: [ 'name', 'hidden_id']
  195 + });
  196 +
  197 + this.timeSelector = new amdaUI.TimeSelectorUI({id: 'statisticsTimeSelector', height : 160});
145 198  
146   - var store = Ext.create('Ext.data.Store',
147   - {
148   - fields: ['name', 'function']
149   - });
  199 + var store = Ext.create('Ext.data.Store',
  200 + {
  201 + fields: ['name', 'function']
  202 + });
150 203  
151   - this.paramGrid = Ext.create('Ext.grid.Panel', {
  204 + this.paramGrid = Ext.create('Ext.grid.Panel', {
152 205 title: 'Select Parameter & Apply Function',
153 206 selType : 'rowmodel',
154 207 // flex: 2,
155 208 height :250,
156 209 store : store,
157 210 columns: [
158   - { xtype: 'rownumberer' },
159   - { header: 'parameter', dataIndex: 'name', menuDisabled : true, sortable : false },
160   - { header: 'function', dataIndex: 'function', menuDisabled : true, sortable : false,
161   - editor: {
162   - xtype: 'combo', queryMode : 'local',
163   -// emptyText : 'please click to select function',
164   - store: [ 'min', 'max', 'mean' ],
165   - triggerAction: 'all',
166   -// lazyInit: false,
167   - listeners: {
168   - focus: function(obj) {
169   - obj.expand();
  211 + { xtype: 'rownumberer' },
  212 + {
  213 + header: "Parameter Name",
  214 + dataIndex: 'name',
  215 + flex:1,
  216 + sortable: false,
  217 + menuDisabled : true ,
  218 + renderer: function (val, meta, rec) {
  219 + return rec.getParamFullName();
  220 + }
  221 + },
  222 + // { header: 'parameter', dataIndex: 'name', menuDisabled : true, sortable : false },
  223 + { header: 'function', dataIndex: 'function', menuDisabled : true, sortable : false,
  224 + editor: {
  225 + xtype: 'combo', queryMode : 'local',
  226 + // emptyText : 'please click to select function',
  227 + store: [ 'min', 'max', 'mean' ],
  228 + triggerAction: 'all',
  229 + // lazyInit: false,
  230 + listeners: {
  231 + focus: function(obj) {
  232 + obj.expand();
  233 + }
  234 + }
  235 + },
  236 + renderer: function(v)
  237 + {
  238 + if(v != null && v.length > 0 )
  239 + return v;
  240 + else
  241 + return 'click to select';
  242 + }
  243 + },
  244 + { menuDisabled : true, width: 30, renderer: function(){
  245 + return '<div class="icon-remover" style="width: 15px; height: 15px;"></div>';
  246 + }
170 247 }
171   - }
172   - },
173   - renderer: function(v)
174   - {
175   - if(v != null && v.length > 0 )
176   - return v;
177   - else
178   - return 'click to select';
179   - }
180   - },
181   - { menuDisabled : true, width: 30, renderer: function(){
182   - return '<div class="icon-remover" style="width: 15px; height: 15px;"></div>';
183   - }
184   - }
185 248 ],
186   - plugins: [
187   - Ext.create('Ext.grid.plugin.CellEditing', {
188   - clicksToEdit: 1
189   - })
190   - ],
191   - listeners :
  249 + plugins: [ Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 })],
  250 + listeners :
192 251 {
193 252 render : function(o,op)
194 253 {
... ... @@ -222,7 +281,8 @@ Ext.define(&#39;amdaUI.StatisticsUI&#39;, {
222 281 {
223 282 if (!this.valid)
224 283 return false;
225   - var nameToSent;
  284 + var nameToSent;
  285 + var components = null;
226 286 switch (data.records[0].data.nodeType)
227 287 {
228 288 case 'localParam' :
... ... @@ -246,13 +306,8 @@ Ext.define(&#39;amdaUI.StatisticsUI&#39;, {
246 306 }
247 307 var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.statistics.id);
248 308 if (module)
249   - {
250   - if (data.records[0].get('needsArgs') && !data.records[0].get('isSpectra')) {
251   - module.getUiContent().fireEvent('openParamEditor',nameToSent);
252   - }
253   - else {
254   - module.addParam(nameToSent,true);
255   - }
  309 + {
  310 + module.addParam(nameToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components);
256 311 }
257 312 return true;
258 313 }
... ... @@ -343,8 +398,9 @@ Ext.define(&#39;amdaUI.StatisticsUI&#39;, {
343 398 url: helpDir+'statisticsHOWTO'
344 399 }
345 400 }
346   - ]
347   - };
  401 + ],
  402 + plugins: [ {ptype: 'paramArgumentsPlugin', pluginId: 'statistics-param-arguments-plugin'}]
  403 + };
348 404  
349 405 Ext.apply (this, Ext.apply(arguments, myConf));
350 406 }
... ...