Commit 4ca3eefff9fef252fe7c62d2e38c04f233f7e3d0
1 parent
5f341ae7
Exists in
master
and in
93 other branches
il reste plot et stats coté integration
Showing
2 changed files
with
478 additions
and
446 deletions
Show diff stats
js/app/views/PlotComponents/PlotTree.js
... | ... | @@ -564,8 +564,8 @@ Ext.define('amdaPlotComp.PlotTree', { |
564 | 564 | return record.get('isParameter') ; |
565 | 565 | case 'amdaModel.AliasNode' : |
566 | 566 | case 'amdaModel.MyDataParamNode' : |
567 | - return record.isLeaf(); | |
568 | - | |
567 | + case 'amdaModel.MyDataParamComponentNode': | |
568 | + return record.get('isParameter') ; | |
569 | 569 | case 'amdaPlotObj.PlotParamTreeNode' : |
570 | 570 | var fromPanelObject = null; |
571 | 571 | if (this.tabObject.get('tree-full-view')) |
... | ... | @@ -736,8 +736,24 @@ Ext.define('amdaPlotComp.PlotTree', { |
736 | 736 | } |
737 | 737 | this.dropParamToCreate(targetNode, position,idToSent, {'components': components}); |
738 | 738 | return true; |
739 | + case 'amdaModel.MyDataParamComponentNode': | |
740 | + if (!record.get('isParameter')) | |
741 | + return false; | |
742 | + //targetNode, position, paramId, paramComponents, isVector, plotOnly | |
743 | + paramId=record.get('text'); | |
744 | + var parentId = paramId.substr(0, paramId.length - 3); | |
745 | + idToSent = "wsd_" + parentId; | |
746 | + var regExp = /\(([\d]+)\)/; | |
747 | + var component_index = regExp.exec(paramId); | |
748 | + if (component_index) | |
749 | + { | |
750 | + components = []; | |
751 | + components['index1'] = component_index[1]; | |
752 | + } | |
753 | + this.dropParamToCreate(targetNode, position,idToSent, {'components': components}); | |
754 | + return true; | |
739 | 755 | case 'amdaModel.MyDataParamNode' : |
740 | - if (!record.isLeaf()) | |
756 | + if (!record.get('isParameter')) | |
741 | 757 | return false; |
742 | 758 | this.dropParamToCreate(targetNode, position, "wsd_" + record.get('text')); |
743 | 759 | return true; |
... | ... |
js/app/views/StatisticsUI.js
... | ... | @@ -7,446 +7,462 @@ |
7 | 7 | * @author elena |
8 | 8 | */ |
9 | 9 | |
10 | -Ext.define('amdaUI.StatisticsUI', | |
11 | -{ | |
12 | - extend: 'Ext.container.Container', | |
13 | - alias: 'widget.panelStatistics', | |
14 | - | |
15 | - requires : [ | |
16 | - //'amdaModel.Function' | |
17 | - 'amdaUI.TimeSelectorUI', | |
18 | - 'amdaUI.ParamArgumentsPlug', | |
19 | - 'amdaModel.DownloadParam' | |
20 | - ], | |
21 | - | |
22 | - statics : | |
23 | - { | |
24 | - // functionStore : null | |
25 | - }, | |
26 | - | |
27 | - constructor: function(config) | |
28 | - { | |
29 | - this.init(config); | |
30 | - this.callParent(arguments); | |
31 | - this.loadObject(); | |
32 | - | |
33 | - var paramArgsPlug = this.getPlugin('statistics-param-arguments-plugin'); | |
34 | - if (paramArgsPlug) | |
35 | - paramArgsPlug.onApply = this.onApplyParameterArgs; | |
36 | - }, | |
37 | - | |
38 | - loadObject : function() | |
39 | - { | |
40 | - // load object into form | |
41 | - var basicForm = this.formPanel.items.items[1].getForm(); | |
42 | - basicForm.loadRecord(this.object); | |
43 | - | |
44 | - }, | |
45 | - | |
46 | - onApplyParameterArgs : function(parentUI, paramObject) | |
47 | - { | |
48 | - parentUI.paramGrid.getView().refresh(); | |
49 | - }, | |
50 | - | |
51 | - addParam : function(paramId, isLeaf, needArgs, components) | |
52 | - { | |
53 | - // adding the parameter to the paramGrid | |
54 | - var paramObj = amdaModel.RequestParamObject.getEmptyObj(); | |
55 | - paramObj.paramid = paramId; | |
56 | - | |
57 | - if (components) { | |
58 | - if (components['index1']) { | |
59 | - paramObj['dim1-index'] = components['index1']; | |
60 | - ++paramObj['type']; | |
61 | - } | |
62 | - | |
63 | - if (components['index2']) { | |
64 | - paramObj['dim2-index'] = components['index2']; | |
65 | - ++paramObj['type']; | |
66 | - } | |
67 | - } | |
68 | - | |
69 | - var r = Ext.create('amdaModel.DownloadParam', paramObj); | |
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 | - { | |
82 | - var paramArgsPlug = this.getPlugin('statistics-param-arguments-plugin'); | |
83 | - | |
84 | - if (paramArgsPlug) | |
85 | - paramArgsPlug.show('statistics-param-arguments-plugin', record); | |
86 | - }, | |
87 | - | |
88 | - addTT : function(TTname,TTid) | |
89 | - { | |
90 | - this.timeSelector.addTT(TTname, TTid); ; | |
91 | - }, | |
92 | - | |
93 | - /** | |
94 | - * Set Start-Stop from parameter info (Local & MyData) | |
95 | - */ | |
96 | - setTimeFromData : function(obj) { | |
97 | - if (!obj.start || !obj.stop) | |
98 | - return; | |
99 | - | |
100 | - var dateStart = new Date(obj.start.replace(/[T|Z]/g,' ').replace(/\-/g,'\/')); | |
101 | - var dateStop = new Date(obj.stop.replace(/[T|Z]/g,' ').replace(/\-/g,'\/')); | |
102 | - | |
103 | - this.formPanel.items.items[1].getForm().setValues({ startDate : dateStart, stopDate : dateStop }); | |
104 | - this.timeSelector.intervalSel.updateDuration(); | |
105 | - }, | |
106 | - | |
107 | - generateCatalog : function() | |
108 | - { | |
109 | - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.statistics.id); | |
110 | - if (module) | |
111 | - module.linkedNode.execute(); | |
112 | - }, | |
113 | - | |
114 | -/* | |
115 | -* Update this.object from form | |
116 | -*/ | |
117 | - updateObject : function() | |
118 | - { | |
119 | - // get the basic form of the left | |
120 | - var basicForm = this.formPanel.items.items[1].getForm(); | |
121 | - var updateStatus = true; | |
122 | - var formValues = basicForm.getValues(); | |
123 | - this.object.set('name',this.fieldName.getValue()); | |
124 | - this.object.set('description',formValues.description); | |
125 | - | |
126 | - var recs = this.paramGrid.getStore().getNewRecords(); | |
127 | - var paramArr = new Array(); | |
128 | - | |
129 | - Ext.Array.each(recs, function(rec, index, allItems) | |
130 | - { | |
131 | - var obj = Ext.clone(rec.data); | |
132 | - | |
133 | - if (obj.function == null) | |
134 | - { | |
135 | - myDesktopApp.warningMsg('Please select function : `click to select`'); | |
136 | - updateStatus = false; | |
137 | - return; | |
138 | - } | |
139 | - paramArr.push(obj); | |
140 | - }); | |
141 | - | |
142 | - this.object.set('parameter', paramArr); | |
143 | - | |
144 | - var timeSource = this.timeSelector.getActiveTimeSource(); | |
145 | - | |
146 | - if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0] // timeSource 'TimeTable' | |
147 | - && this.timeSelector.TTGrid.getStore().count() == 0) | |
148 | - { | |
149 | - myDesktopApp.warningMsg('You\'ve chosen Time Selection `by TimeTable` but no timeTable was added!' | |
150 | - +'<br>You must add one or choose Time Selection `by Interval`'); | |
151 | - return false; | |
152 | - } | |
153 | - | |
154 | - basicForm.updateRecord(this.object); | |
155 | - this.object.set('timesrc', timeSource); | |
156 | - // set valid intervals into TimeTable object | |
157 | - if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]) | |
158 | - this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items); | |
159 | - | |
160 | - return updateStatus; | |
161 | - }, | |
162 | - | |
163 | - /** | |
164 | - * Check if changes were made before closing window | |
165 | - * @return true if changes | |
166 | - */ | |
167 | - fclose : function() | |
168 | - { | |
169 | - if (this.status == null) | |
170 | - return false; | |
171 | - | |
172 | - var isDirty = this.formPanel.getForm().isDirty() || (this.status.isModified) || (this.status.nbModified > 0) || (this.status.nbNew > 0); | |
173 | - return isDirty; | |
174 | - }, | |
175 | - | |
176 | - /** | |
177 | - * View configuration | |
178 | - */ | |
179 | - init : function (config) | |
180 | - { | |
181 | - this.fieldName = new Ext.form.field.Text({ | |
182 | - fieldLabel: 'Catalog Name', | |
183 | - allowBlank : false, | |
184 | - stripCharsRe: /(^\s+|\s+$)/g, | |
185 | - emptyText: 'Please no spaces!', | |
186 | - name: 'name', | |
187 | - // anchor: '100%', | |
188 | - validateOnChange: false, | |
189 | - validateOnBlur: false, | |
190 | - validFlag: false, | |
191 | - validator : function() { | |
192 | - return this.validFlag; | |
193 | - } | |
194 | - }); | |
195 | - | |
196 | - var ttStore = Ext.create('Ext.data.Store', | |
197 | - { | |
198 | - fields: [ 'name', 'hidden_id'] | |
199 | - }); | |
200 | - | |
201 | - this.timeSelector = new amdaUI.TimeSelectorUI({id: 'statisticsTimeSelector', flex:1}); | |
202 | - | |
203 | - var store = Ext.create('Ext.data.Store', | |
204 | - { | |
205 | - fields: ['name', 'function'] | |
206 | - }); | |
207 | - | |
208 | - this.paramGrid = Ext.create('Ext.grid.Panel', | |
209 | - { | |
210 | - title: 'Select Parameter & Apply Function', | |
211 | - selType : 'rowmodel', | |
212 | - flex: 2, | |
213 | - // height :250, | |
214 | - store : store, | |
215 | - columns: [ | |
216 | - { xtype: 'rownumberer' }, | |
217 | - { | |
218 | - header: "Parameter Name", | |
219 | - dataIndex: 'name', | |
220 | - flex:1, | |
221 | - sortable: false, | |
222 | - menuDisabled : true , | |
223 | - renderer: function (val, meta, rec) { | |
224 | - return rec.getParamFullName(); | |
225 | - } | |
226 | - }, | |
227 | - // { header: 'parameter', dataIndex: 'name', menuDisabled : true, sortable : false }, | |
228 | - { header: 'function', dataIndex: 'function', menuDisabled : true, sortable : false, | |
229 | - editor: | |
230 | - { | |
231 | - xtype: 'combo', queryMode : 'local', | |
232 | - //emptyText : 'please click to select function', | |
233 | - store: [ 'min', 'max', 'mean' ,'RMS','median','variance','skewness','kurtosis','count','countNotNan','countTrue' ], | |
234 | - triggerAction: 'all', | |
235 | - //lazyInit: false, | |
236 | - listeners: { | |
237 | - focus: function(obj) { | |
238 | - obj.expand(); | |
239 | - } | |
240 | - } | |
241 | - }, | |
242 | - renderer: function(v) | |
243 | - { | |
244 | - if(v != null && v.length > 0 ) | |
245 | - return v; | |
246 | - else | |
247 | - return 'click to select'; | |
248 | - } | |
249 | - }, | |
250 | - { menuDisabled : true, width: 30, renderer: function(){ | |
251 | - return '<div class="icon-remover" style="width: 15px; height: 15px;"></div>'; | |
252 | - } | |
253 | - } | |
254 | - ], | |
255 | - plugins: [ Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 })], | |
256 | - listeners : | |
257 | - { | |
258 | - render : function(o,op) | |
259 | - { | |
260 | - var me = this; | |
261 | - var el = me.body.dom; | |
262 | - var dropTarget = Ext.create('Ext.dd.DropTarget', el, { | |
263 | - ddGroup: 'explorerTree', | |
264 | - notifyOver : function(ddSource, e, data) | |
265 | - { | |
266 | - if (data.records[0].data.nodeType == 'localParam' && data.records[0].get('notyet')) { | |
267 | - this.valid = false; | |
268 | - return this.dropNotAllowed; | |
269 | - } | |
270 | - if (((data.records[0].data.nodeType == 'localParam') || | |
271 | - (data.records[0].data.nodeType == 'remoteParam') || | |
272 | - (data.records[0].data.nodeType == 'remoteSimuParam') || | |
273 | - (data.records[0].data.nodeType == 'derivedParam') || | |
274 | - (data.records[0].data.nodeType == 'myDataParam') || | |
275 | - (data.records[0].data.nodeType == 'alias'))&& | |
276 | - (data.records[0].isLeaf() || data.records[0].data.isParameter) && | |
277 | - !data.records[0].data.disable) | |
278 | - { | |
279 | - this.valid = true; | |
280 | - return this.dropAllowed; | |
281 | - } | |
282 | - | |
283 | - this.valid = false; | |
284 | - return this.dropNotAllowed; | |
285 | - }, | |
286 | - notifyDrop : function(ddSource, e, data) | |
287 | - { | |
288 | - if (!this.valid) | |
289 | - return false; | |
290 | - var nameToSent; | |
291 | - var components = null; | |
292 | - | |
293 | - switch (data.records[0].data.nodeType) | |
294 | - { | |
295 | - case 'localParam' : | |
296 | - case 'remoteParam': | |
297 | - case 'remoteSimuParam': | |
298 | - nameToSent = data.records[0].get('id'); | |
299 | - if (data.records[0].get('alias')!= "" ) | |
300 | - var nameToSent = "#"+data.records[0].get('alias'); | |
301 | - var component_info = data.records[0].get('component_info'); | |
302 | - if (component_info && component_info.parentId) | |
303 | - { | |
304 | - if ( component_info.index1 && component_info.index2 ) | |
305 | - { | |
306 | - nameToSent = component_info.parentId; | |
307 | - components = []; | |
308 | - if (component_info.index1) | |
309 | - components['index1'] = component_info.index1; | |
310 | - if (component_info.index2) | |
311 | - components['index2'] = component_info.index2; | |
312 | - } | |
313 | - if ( data.records[0].get('needsArgs') ) | |
314 | - { | |
315 | - nameToSent = component_info.parentId; | |
316 | - if (component_info.index1) | |
317 | - { | |
318 | - components = []; | |
319 | - components['index1'] = component_info.index1; | |
320 | - } | |
321 | - } | |
322 | - } | |
323 | - break; | |
324 | - case 'alias' : | |
325 | - nameToSent = "#"+data.records[0].get('text'); | |
326 | - break; | |
327 | - case 'derivedParam' : | |
328 | - if(data.records[0].modelName=='amdaModel.DerivedParamComponentNode') | |
329 | - { | |
330 | - paramId=data.records[0].get('text'); | |
331 | - var parentId=paramId.substr(0,paramId.length-3); | |
332 | - nameToSent = "ws_"+parentId; | |
333 | - var regExp = /\(([\d]+)\)/; | |
334 | - var component_index = regExp.exec(paramId); | |
335 | - if(component_index ) | |
336 | - { | |
337 | - components = []; | |
338 | - components['index1'] =component_index[1]; | |
339 | - } | |
340 | - break; | |
341 | - }else | |
342 | - { | |
343 | - nameToSent = "ws_"+data.records[0].get('text'); | |
344 | - } | |
345 | - break; | |
346 | - case 'myDataParam' : | |
347 | - nameToSent = "wsd_"+data.records[0].get('text'); | |
348 | - break; | |
349 | - default : | |
350 | - return false; | |
351 | - } | |
352 | - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.statistics.id); | |
353 | - if (module) | |
354 | - { | |
355 | - module.addParam(nameToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components); | |
356 | - } | |
357 | - return true; | |
358 | - } | |
359 | - }); | |
360 | - }, | |
361 | - cellclick : function(grid, cell, cellIndex, record){ | |
362 | - if (cellIndex == 3) | |
363 | - grid.getStore().remove(record); | |
364 | - } | |
365 | - } | |
366 | - }); | |
367 | - | |
368 | - | |
369 | - this.formPanel = Ext.create('Ext.form.Panel', | |
370 | - { | |
371 | - region: 'center', | |
372 | - layout: { | |
373 | - type: 'hbox', | |
374 | - pack: 'start', | |
375 | - align: 'stretch' | |
376 | - }, | |
377 | - defaults: { bodyStyle: {background : '#dfe8f6'}, padding : '3'}, | |
378 | - fieldDefaults: { labelWidth: 80, labelAlign : 'top' }, | |
379 | - items: [ { | |
380 | - xtype: 'form', | |
381 | - flex : 1, | |
382 | - layout: {type: 'vbox', pack: 'start', align: 'stretch'}, | |
383 | - items : [ this.paramGrid ], | |
384 | - fbar:[ { | |
385 | - type: 'button', | |
386 | - text: 'Generate Catalog', | |
387 | - scope : this, | |
388 | - handler: function() | |
389 | - { | |
390 | - // update object with user's values | |
391 | - // if the return is true (object had been updated) | |
392 | - if (this.updateObject()){ | |
393 | - this.generateCatalog(); | |
394 | - } | |
395 | - } | |
396 | - }, | |
397 | - { | |
398 | - type: 'button', | |
399 | - text: 'Reset', | |
400 | - scope : this, | |
401 | - handler: function() { | |
402 | - this.formPanel.getForm().reset(); | |
403 | - this.paramGrid.store.removeAll(); | |
404 | - this.timeSelector.TTGrid.store.removeAll(); | |
405 | - } | |
406 | - }] | |
407 | - }, | |
408 | - { | |
409 | - xtype: 'form', | |
410 | - title: 'Additional Information', | |
411 | - flex : 1, | |
412 | - trackResetOnLoad: true, | |
413 | - layout: {type: 'vbox', pack: 'start', align: 'stretch', padding : '3'}, | |
414 | - items : [ | |
415 | - this.fieldName, | |
416 | - { | |
417 | - xtype: 'textarea', | |
418 | - name: 'description', | |
419 | - fieldLabel: 'Description', | |
420 | - height: 125 | |
421 | - }, | |
422 | - this.timeSelector | |
423 | - ] | |
424 | - } | |
425 | - ] | |
426 | - }); | |
427 | - | |
428 | - var myConf = { | |
429 | - layout: 'border', | |
430 | - items: [ | |
431 | - this.formPanel, | |
432 | - { | |
433 | - xtype: 'panel', | |
434 | - region: 'south', | |
435 | - title: 'Information', | |
436 | - collapsible: true, | |
437 | - collapseMode: 'header', | |
438 | - height: 160, | |
439 | - autoHide: false, | |
440 | - bodyStyle: 'padding:5px', | |
441 | - iconCls: 'icon-information', | |
442 | - loader: { | |
443 | - autoLoad: true, | |
444 | - url: helpDir+'statisticsHOWTO' | |
445 | - } | |
446 | - }], | |
447 | - plugins: [ {ptype: 'paramArgumentsPlugin', pluginId: 'statistics-param-arguments-plugin'}] | |
448 | - }; | |
449 | - | |
450 | - Ext.apply (this, Ext.apply(arguments, myConf)); | |
451 | - } | |
452 | -}); | |
10 | +Ext.define('amdaUI.StatisticsUI', | |
11 | + { | |
12 | + extend: 'Ext.container.Container', | |
13 | + alias: 'widget.panelStatistics', | |
14 | + | |
15 | + requires: [ | |
16 | + //'amdaModel.Function' | |
17 | + 'amdaUI.TimeSelectorUI', | |
18 | + 'amdaUI.ParamArgumentsPlug', | |
19 | + 'amdaModel.DownloadParam' | |
20 | + ], | |
21 | + | |
22 | + statics: | |
23 | + { | |
24 | + // functionStore : null | |
25 | + }, | |
26 | + | |
27 | + constructor: function (config) | |
28 | + { | |
29 | + this.init(config); | |
30 | + this.callParent(arguments); | |
31 | + this.loadObject(); | |
32 | + | |
33 | + var paramArgsPlug = this.getPlugin('statistics-param-arguments-plugin'); | |
34 | + if (paramArgsPlug) | |
35 | + paramArgsPlug.onApply = this.onApplyParameterArgs; | |
36 | + }, | |
37 | + | |
38 | + loadObject: function () | |
39 | + { | |
40 | + // load object into form | |
41 | + var basicForm = this.formPanel.items.items[1].getForm(); | |
42 | + basicForm.loadRecord(this.object); | |
43 | + | |
44 | + }, | |
45 | + | |
46 | + onApplyParameterArgs: function (parentUI, paramObject) | |
47 | + { | |
48 | + parentUI.paramGrid.getView().refresh(); | |
49 | + }, | |
50 | + | |
51 | + addParam: function (paramId, isLeaf, needArgs, components) | |
52 | + { | |
53 | + // adding the parameter to the paramGrid | |
54 | + var paramObj = amdaModel.RequestParamObject.getEmptyObj(); | |
55 | + paramObj.paramid = paramId; | |
56 | + | |
57 | + if (components) { | |
58 | + if (components['index1']) { | |
59 | + paramObj['dim1-index'] = components['index1']; | |
60 | + ++paramObj['type']; | |
61 | + } | |
62 | + | |
63 | + if (components['index2']) { | |
64 | + paramObj['dim2-index'] = components['index2']; | |
65 | + ++paramObj['type']; | |
66 | + } | |
67 | + } | |
68 | + | |
69 | + var r = Ext.create('amdaModel.DownloadParam', paramObj); | |
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 | + { | |
82 | + var paramArgsPlug = this.getPlugin('statistics-param-arguments-plugin'); | |
83 | + | |
84 | + if (paramArgsPlug) | |
85 | + paramArgsPlug.show('statistics-param-arguments-plugin', record); | |
86 | + }, | |
87 | + | |
88 | + addTT: function (TTname, TTid) | |
89 | + { | |
90 | + this.timeSelector.addTT(TTname, TTid); | |
91 | + ; | |
92 | + }, | |
93 | + | |
94 | + /** | |
95 | + * Set Start-Stop from parameter info (Local & MyData) | |
96 | + */ | |
97 | + setTimeFromData: function (obj) { | |
98 | + if (!obj.start || !obj.stop) | |
99 | + return; | |
100 | + | |
101 | + var dateStart = new Date(obj.start.replace(/[T|Z]/g, ' ').replace(/\-/g, '\/')); | |
102 | + var dateStop = new Date(obj.stop.replace(/[T|Z]/g, ' ').replace(/\-/g, '\/')); | |
103 | + | |
104 | + this.formPanel.items.items[1].getForm().setValues({startDate: dateStart, stopDate: dateStop}); | |
105 | + this.timeSelector.intervalSel.updateDuration(); | |
106 | + }, | |
107 | + | |
108 | + generateCatalog: function () | |
109 | + { | |
110 | + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.statistics.id); | |
111 | + if (module) | |
112 | + module.linkedNode.execute(); | |
113 | + }, | |
114 | + | |
115 | + /* | |
116 | + * Update this.object from form | |
117 | + */ | |
118 | + updateObject: function () | |
119 | + { | |
120 | + // get the basic form of the left | |
121 | + var basicForm = this.formPanel.items.items[1].getForm(); | |
122 | + var updateStatus = true; | |
123 | + var formValues = basicForm.getValues(); | |
124 | + this.object.set('name', this.fieldName.getValue()); | |
125 | + this.object.set('description', formValues.description); | |
126 | + | |
127 | + var recs = this.paramGrid.getStore().getNewRecords(); | |
128 | + var paramArr = new Array(); | |
129 | + | |
130 | + Ext.Array.each(recs, function (rec, index, allItems) | |
131 | + { | |
132 | + var obj = Ext.clone(rec.data); | |
133 | + | |
134 | + if (obj.function == null) | |
135 | + { | |
136 | + myDesktopApp.warningMsg('Please select function : `click to select`'); | |
137 | + updateStatus = false; | |
138 | + return; | |
139 | + } | |
140 | + paramArr.push(obj); | |
141 | + }); | |
142 | + | |
143 | + this.object.set('parameter', paramArr); | |
144 | + | |
145 | + var timeSource = this.timeSelector.getActiveTimeSource(); | |
146 | + | |
147 | + if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0] // timeSource 'TimeTable' | |
148 | + && this.timeSelector.TTGrid.getStore().count() == 0) | |
149 | + { | |
150 | + myDesktopApp.warningMsg('You\'ve chosen Time Selection `by TimeTable` but no timeTable was added!' | |
151 | + + '<br>You must add one or choose Time Selection `by Interval`'); | |
152 | + return false; | |
153 | + } | |
154 | + | |
155 | + basicForm.updateRecord(this.object); | |
156 | + this.object.set('timesrc', timeSource); | |
157 | + // set valid intervals into TimeTable object | |
158 | + if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]) | |
159 | + this.object.set('timeTables', this.timeSelector.TTGrid.getStore().data.items); | |
160 | + | |
161 | + return updateStatus; | |
162 | + }, | |
163 | + | |
164 | + /** | |
165 | + * Check if changes were made before closing window | |
166 | + * @return true if changes | |
167 | + */ | |
168 | + fclose: function () | |
169 | + { | |
170 | + if (this.status == null) | |
171 | + return false; | |
172 | + | |
173 | + var isDirty = this.formPanel.getForm().isDirty() || (this.status.isModified) || (this.status.nbModified > 0) || (this.status.nbNew > 0); | |
174 | + return isDirty; | |
175 | + }, | |
176 | + | |
177 | + /** | |
178 | + * View configuration | |
179 | + */ | |
180 | + init: function (config) | |
181 | + { | |
182 | + this.fieldName = new Ext.form.field.Text({ | |
183 | + fieldLabel: 'Catalog Name', | |
184 | + allowBlank: false, | |
185 | + stripCharsRe: /(^\s+|\s+$)/g, | |
186 | + emptyText: 'Please no spaces!', | |
187 | + name: 'name', | |
188 | + // anchor: '100%', | |
189 | + validateOnChange: false, | |
190 | + validateOnBlur: false, | |
191 | + validFlag: false, | |
192 | + validator: function () { | |
193 | + return this.validFlag; | |
194 | + } | |
195 | + }); | |
196 | + | |
197 | + var ttStore = Ext.create('Ext.data.Store', | |
198 | + { | |
199 | + fields: ['name', 'hidden_id'] | |
200 | + }); | |
201 | + | |
202 | + this.timeSelector = new amdaUI.TimeSelectorUI({id: 'statisticsTimeSelector', flex: 1}); | |
203 | + | |
204 | + var store = Ext.create('Ext.data.Store', | |
205 | + { | |
206 | + fields: ['name', 'function'] | |
207 | + }); | |
208 | + | |
209 | + this.paramGrid = Ext.create('Ext.grid.Panel', | |
210 | + { | |
211 | + title: 'Select Parameter & Apply Function', | |
212 | + selType: 'rowmodel', | |
213 | + flex: 2, | |
214 | + // height :250, | |
215 | + store: store, | |
216 | + columns: [ | |
217 | + {xtype: 'rownumberer'}, | |
218 | + { | |
219 | + header: "Parameter Name", | |
220 | + dataIndex: 'name', | |
221 | + flex: 1, | |
222 | + sortable: false, | |
223 | + menuDisabled: true, | |
224 | + renderer: function (val, meta, rec) { | |
225 | + return rec.getParamFullName(); | |
226 | + } | |
227 | + }, | |
228 | + // { header: 'parameter', dataIndex: 'name', menuDisabled : true, sortable : false }, | |
229 | + {header: 'function', dataIndex: 'function', menuDisabled: true, sortable: false, | |
230 | + editor: | |
231 | + { | |
232 | + xtype: 'combo', queryMode: 'local', | |
233 | + //emptyText : 'please click to select function', | |
234 | + store: ['min', 'max', 'mean', 'RMS', 'median', 'variance', 'skewness', 'kurtosis', 'count', 'countNotNan', 'countTrue'], | |
235 | + triggerAction: 'all', | |
236 | + //lazyInit: false, | |
237 | + listeners: { | |
238 | + focus: function (obj) { | |
239 | + obj.expand(); | |
240 | + } | |
241 | + } | |
242 | + }, | |
243 | + renderer: function (v) | |
244 | + { | |
245 | + if (v != null && v.length > 0) | |
246 | + return v; | |
247 | + else | |
248 | + return 'click to select'; | |
249 | + } | |
250 | + }, | |
251 | + {menuDisabled: true, width: 30, renderer: function () { | |
252 | + return '<div class="icon-remover" style="width: 15px; height: 15px;"></div>'; | |
253 | + } | |
254 | + } | |
255 | + ], | |
256 | + plugins: [Ext.create('Ext.grid.plugin.CellEditing', {clicksToEdit: 1})], | |
257 | + listeners: | |
258 | + { | |
259 | + render: function (o, op) | |
260 | + { | |
261 | + var me = this; | |
262 | + var el = me.body.dom; | |
263 | + var dropTarget = Ext.create('Ext.dd.DropTarget', el, { | |
264 | + ddGroup: 'explorerTree', | |
265 | + notifyOver: function (ddSource, e, data) | |
266 | + { | |
267 | + if (data.records[0].data.nodeType == 'localParam' && data.records[0].get('notyet')) { | |
268 | + this.valid = false; | |
269 | + return this.dropNotAllowed; | |
270 | + } | |
271 | + if (((data.records[0].data.nodeType == 'localParam') || | |
272 | + (data.records[0].data.nodeType == 'remoteParam') || | |
273 | + (data.records[0].data.nodeType == 'remoteSimuParam') || | |
274 | + (data.records[0].data.nodeType == 'derivedParam') || | |
275 | + (data.records[0].data.nodeType == 'myDataParam') || | |
276 | + (data.records[0].data.nodeType == 'alias')) && | |
277 | + (data.records[0].isLeaf() || data.records[0].data.isParameter) && | |
278 | + !data.records[0].data.disable) | |
279 | + { | |
280 | + this.valid = true; | |
281 | + return this.dropAllowed; | |
282 | + } | |
283 | + | |
284 | + this.valid = false; | |
285 | + return this.dropNotAllowed; | |
286 | + }, | |
287 | + notifyDrop: function (ddSource, e, data) | |
288 | + { | |
289 | + if (!this.valid) | |
290 | + return false; | |
291 | + var nameToSent; | |
292 | + var components = null; | |
293 | + | |
294 | + switch (data.records[0].data.nodeType) | |
295 | + { | |
296 | + case 'localParam' : | |
297 | + case 'remoteParam': | |
298 | + case 'remoteSimuParam': | |
299 | + nameToSent = data.records[0].get('id'); | |
300 | + if (data.records[0].get('alias') != "") | |
301 | + var nameToSent = "#" + data.records[0].get('alias'); | |
302 | + var component_info = data.records[0].get('component_info'); | |
303 | + if (component_info && component_info.parentId) | |
304 | + { | |
305 | + if (component_info.index1 && component_info.index2) | |
306 | + { | |
307 | + nameToSent = component_info.parentId; | |
308 | + components = []; | |
309 | + if (component_info.index1) | |
310 | + components['index1'] = component_info.index1; | |
311 | + if (component_info.index2) | |
312 | + components['index2'] = component_info.index2; | |
313 | + } | |
314 | + if (data.records[0].get('needsArgs')) | |
315 | + { | |
316 | + nameToSent = component_info.parentId; | |
317 | + if (component_info.index1) | |
318 | + { | |
319 | + components = []; | |
320 | + components['index1'] = component_info.index1; | |
321 | + } | |
322 | + } | |
323 | + } | |
324 | + break; | |
325 | + case 'alias' : | |
326 | + nameToSent = "#" + data.records[0].get('text'); | |
327 | + break; | |
328 | + case 'derivedParam' : | |
329 | + if (data.records[0].modelName == 'amdaModel.DerivedParamComponentNode') | |
330 | + { | |
331 | + paramId = data.records[0].get('text'); | |
332 | + var parentId = paramId.substr(0, paramId.length - 3); | |
333 | + nameToSent = "ws_" + parentId; | |
334 | + var regExp = /\(([\d]+)\)/; | |
335 | + var component_index = regExp.exec(paramId); | |
336 | + if (component_index) | |
337 | + { | |
338 | + components = []; | |
339 | + components['index1'] = component_index[1]; | |
340 | + } | |
341 | + break; | |
342 | + } else | |
343 | + { | |
344 | + nameToSent = "ws_" + data.records[0].get('text'); | |
345 | + } | |
346 | + break; | |
347 | + case 'myDataParam' : | |
348 | + if (data.records[0].modelName == 'amdaModel.MyDataParamComponentNode') | |
349 | + { | |
350 | + paramId = data.records[0].get('text'); | |
351 | + var parentId = paramId.substr(0, paramId.length - 3); | |
352 | + nameToSent = "wsd_" + parentId; | |
353 | + var regExp = /\(([\d]+)\)/; | |
354 | + var component_index = regExp.exec(paramId); | |
355 | + if (component_index) | |
356 | + { | |
357 | + components = []; | |
358 | + components['index1'] = component_index[1]; | |
359 | + } | |
360 | + break; | |
361 | + } else{ | |
362 | + nameToSent = "wsd_" + data.records[0].get('text'); | |
363 | + } | |
364 | + break; | |
365 | + default : | |
366 | + return false; | |
367 | + } | |
368 | + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.statistics.id); | |
369 | + if (module) | |
370 | + { | |
371 | + module.addParam(nameToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components); | |
372 | + } | |
373 | + return true; | |
374 | + } | |
375 | + }); | |
376 | + }, | |
377 | + cellclick: function (grid, cell, cellIndex, record) { | |
378 | + if (cellIndex == 3) | |
379 | + grid.getStore().remove(record); | |
380 | + } | |
381 | + } | |
382 | + }); | |
383 | + | |
384 | + | |
385 | + this.formPanel = Ext.create('Ext.form.Panel', | |
386 | + { | |
387 | + region: 'center', | |
388 | + layout: { | |
389 | + type: 'hbox', | |
390 | + pack: 'start', | |
391 | + align: 'stretch' | |
392 | + }, | |
393 | + defaults: {bodyStyle: {background: '#dfe8f6'}, padding: '3'}, | |
394 | + fieldDefaults: {labelWidth: 80, labelAlign: 'top'}, | |
395 | + items: [{ | |
396 | + xtype: 'form', | |
397 | + flex: 1, | |
398 | + layout: {type: 'vbox', pack: 'start', align: 'stretch'}, | |
399 | + items: [this.paramGrid], | |
400 | + fbar: [{ | |
401 | + type: 'button', | |
402 | + text: 'Generate Catalog', | |
403 | + scope: this, | |
404 | + handler: function () | |
405 | + { | |
406 | + // update object with user's values | |
407 | + // if the return is true (object had been updated) | |
408 | + if (this.updateObject()) { | |
409 | + this.generateCatalog(); | |
410 | + } | |
411 | + } | |
412 | + }, | |
413 | + { | |
414 | + type: 'button', | |
415 | + text: 'Reset', | |
416 | + scope: this, | |
417 | + handler: function () { | |
418 | + this.formPanel.getForm().reset(); | |
419 | + this.paramGrid.store.removeAll(); | |
420 | + this.timeSelector.TTGrid.store.removeAll(); | |
421 | + } | |
422 | + }] | |
423 | + }, | |
424 | + { | |
425 | + xtype: 'form', | |
426 | + title: 'Additional Information', | |
427 | + flex: 1, | |
428 | + trackResetOnLoad: true, | |
429 | + layout: {type: 'vbox', pack: 'start', align: 'stretch', padding: '3'}, | |
430 | + items: [ | |
431 | + this.fieldName, | |
432 | + { | |
433 | + xtype: 'textarea', | |
434 | + name: 'description', | |
435 | + fieldLabel: 'Description', | |
436 | + height: 125 | |
437 | + }, | |
438 | + this.timeSelector | |
439 | + ] | |
440 | + } | |
441 | + ] | |
442 | + }); | |
443 | + | |
444 | + var myConf = { | |
445 | + layout: 'border', | |
446 | + items: [ | |
447 | + this.formPanel, | |
448 | + { | |
449 | + xtype: 'panel', | |
450 | + region: 'south', | |
451 | + title: 'Information', | |
452 | + collapsible: true, | |
453 | + collapseMode: 'header', | |
454 | + height: 160, | |
455 | + autoHide: false, | |
456 | + bodyStyle: 'padding:5px', | |
457 | + iconCls: 'icon-information', | |
458 | + loader: { | |
459 | + autoLoad: true, | |
460 | + url: helpDir + 'statisticsHOWTO' | |
461 | + } | |
462 | + }], | |
463 | + plugins: [{ptype: 'paramArgumentsPlugin', pluginId: 'statistics-param-arguments-plugin'}] | |
464 | + }; | |
465 | + | |
466 | + Ext.apply(this, Ext.apply(arguments, myConf)); | |
467 | + } | |
468 | + }); | |
... | ... |