Commit a75892d12afee3866bcd73185e7c9c0b1f9a6ad7
1 parent
2dc9b65a
Exists in
master
and in
16 other branches
Cleaning the PlotZoomPlug.js
Showing
3 changed files
with
24 additions
and
383 deletions
Show diff stats
js/app/views/PlotComponents/PlotZoomPlug.js
... | ... | @@ -13,33 +13,14 @@ |
13 | 13 | * : |
14 | 14 | */ |
15 | 15 | |
16 | - | |
17 | 16 | Ext.define('amdaPlotComp.PlotZoomPlug', { |
18 | 17 | extend: 'Ext.util.Observable', |
19 | 18 | alias: 'plugin.plotZoomPlugin', |
20 | - requires: ['amdaPlotComp.intervalSelection.IntervalSelection', 'amdaPlotComp.plotFunction.FunctionType'], | |
21 | - | |
22 | - //id: 'plot-zoom-plug', | |
23 | - | |
24 | - ttModuleId: 'timetab-win', | |
25 | - catModuleId: 'catalog-win', | |
26 | - | |
19 | + requires: ['amdaPlotComp.intervalSelection.IntervalSelection'], | |
27 | 20 | win: null, |
28 | - form: null, | |
29 | 21 | zoomType: '', |
30 | 22 | interactiveId: '', |
31 | 23 | panelId: -1, |
32 | - myChildWindow: null, | |
33 | - | |
34 | - linkedTTCatNode: null, | |
35 | - /** | |
36 | - * Un composant de 'PlotFunction' qui permet d'afficher le min samplig de chaque paramètre et le nombre de points théoriques entre un start time et stop time | |
37 | - */ | |
38 | - plotFunctionParamField: null, | |
39 | - /** | |
40 | - * Un composant de 'PlotFunction' qui permet à l'utilisateur de séléctionner le type de fonction à appliquer : FFT, SUM, ... | |
41 | - */ | |
42 | - plotFunctionType: null, | |
43 | 24 | |
44 | 25 | constructor: function (config) { |
45 | 26 | Ext.apply(this, config); |
... | ... | @@ -57,7 +38,6 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
57 | 38 | setMinValue: function (min) { |
58 | 39 | if (!this.win) |
59 | 40 | return; |
60 | - console.log(min); | |
61 | 41 | this.win.setField1Value(min); |
62 | 42 | }, |
63 | 43 | |
... | ... | @@ -67,25 +47,6 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
67 | 47 | this.win.setField2Value(max); |
68 | 48 | }, |
69 | 49 | |
70 | - /** | |
71 | - * add Interval to Time table | |
72 | - **/ | |
73 | - insertInterval: function () { | |
74 | - if (this.zoomType != 'timeAxis') | |
75 | - return; | |
76 | - | |
77 | - var start = this.form.getForm().findField('zoom-min-time').getValue(); | |
78 | - var stop = this.form.getForm().findField('zoom-max-time').getValue(); | |
79 | - | |
80 | - var TTCatType = this.form.getForm().findField('ttcat-type').getValue(); | |
81 | - var isCatalog = (TTCatType == 'catalog'); | |
82 | - | |
83 | - myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) { | |
84 | - var targetModuleUI = module.getUiContent(); | |
85 | - if (targetModuleUI) | |
86 | - targetModuleUI.addInterval(start, stop); | |
87 | - }); | |
88 | - }, | |
89 | 50 | |
90 | 51 | /** |
91 | 52 | * creation of the window |
... | ... | @@ -96,7 +57,7 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
96 | 57 | this.interactiveId = interactiveId; |
97 | 58 | |
98 | 59 | let config = { |
99 | - id: 'plot-zoom-win-' + this.hostCmp.ownerCt.getId(), // Plot window ID | |
60 | + id: 'plot-zoom-win-' + this.hostCmp.ownerCt.getId(), | |
100 | 61 | interactiveId: interactiveId, |
101 | 62 | panelId: panelId, |
102 | 63 | hostCmp: this.hostCmp, |
... | ... | @@ -159,332 +120,7 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
159 | 120 | this.win.close(); |
160 | 121 | }, |
161 | 122 | |
162 | - updateWinByType: function (zoomType, panelId) { | |
163 | - if (this.win == null) | |
164 | - return; | |
165 | - | |
166 | - this.zoomType = zoomType; | |
167 | - this.panelId = panelId; | |
168 | - | |
169 | - switch (zoomType) { | |
170 | - case 'timeAxis': | |
171 | - if (this.isPlotFunction) { | |
172 | - const title = "Apply a Fct on Interval"; | |
173 | - this.win.setTitle(title + '-Panel Id: ' + panelId); | |
174 | - } else { | |
175 | - this.win.setTitle('Zoom on time axis & Interval selection - Panel Id : ' + panelId); | |
176 | - } | |
177 | - break; | |
178 | - case 'y-left': | |
179 | - this.win.setTitle('Zoom on Y Left axis - Panel Id : ' + panelId); | |
180 | - break; | |
181 | - case 'y-right': | |
182 | - this.win.setTitle('Zoom on Y Right axis - Panel Id : ' + panelId); | |
183 | - break; | |
184 | - case 'xaxis_id': | |
185 | - this.win.setTitle('Zoom on X axis - Panel Id : ' + panelId); | |
186 | - break; | |
187 | - } | |
188 | - | |
189 | - this.form.getForm().findField('zoom-min-time').setVisible(this.zoomType == 'timeAxis'); | |
190 | - this.form.getForm().findField('zoom-max-time').setVisible(this.zoomType == 'timeAxis'); | |
191 | - | |
192 | - this.form.getForm().findField('zoom-min-float').setVisible(this.zoomType != 'timeAxis'); | |
193 | - this.form.getForm().findField('zoom-max-float').setVisible(this.zoomType != 'timeAxis'); | |
194 | - | |
195 | - var ttCatNameField = this.form.getForm().findField('ttcat-name'); | |
196 | - if (ttCatNameField) | |
197 | - ttCatNameField.findParentByType('fieldset').setVisible(this.zoomType == 'timeAxis'); | |
198 | - }, | |
199 | - | |
200 | 123 | resetMinMaxValue: function () { |
201 | - /* | |
202 | - if (this.zoomType == 'timeAxis') { | |
203 | - this.form.getForm().findField('zoom-min-time').setValue(''); | |
204 | - this.form.getForm().findField('zoom-max-time').setValue(''); | |
205 | - } | |
206 | - else { | |
207 | - this.form.getForm().findField('zoom-min-float').setValue(null); | |
208 | - this.form.getForm().findField('zoom-max-float').setValue(null); | |
209 | - }*/ | |
210 | - | |
211 | - this.hostCmp.panelImage.resetZoom(); | |
212 | - }, | |
213 | - setTimePlot: function () { | |
214 | - var timeObj = new Object(); | |
215 | - timeObj.start = this.form.getForm().findField('zoom-min-time').getValue(); | |
216 | - timeObj.stop = this.form.getForm().findField('zoom-max-time').getValue(); | |
217 | - timeObj.interactiveId = this.interactiveId; | |
218 | - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | |
219 | - plotModule.setTimeInterval(timeObj); | |
220 | - }, | |
221 | - /** | |
222 | - * Main form | |
223 | - */ | |
224 | - getFormConfig: function () { | |
225 | - var intervalFieldSet = { | |
226 | - xtype: 'fieldset', | |
227 | - title: 'Interval Selection', | |
228 | - name: 'interval-selection-fieldset', | |
229 | - collapsible: false, | |
230 | - layout: { | |
231 | - type: 'vbox', | |
232 | - pack: 'start', | |
233 | - align: 'stretch' | |
234 | - }, | |
235 | - items: [ | |
236 | - { | |
237 | - xtype: 'datefield', name: 'zoom-min-time', fieldLabel: 'Start Time', | |
238 | - format: 'Y/m/d H:i:s.u', | |
239 | - }, | |
240 | - { | |
241 | - xtype: 'datefield', name: 'zoom-max-time', fieldLabel: 'Stop Time', | |
242 | - format: 'Y/m/d H:i:s.u' | |
243 | - }, | |
244 | - { | |
245 | - xtype: 'numberfield', name: 'zoom-min-float', fieldLabel: 'Min Value' | |
246 | - }, | |
247 | - { | |
248 | - xtype: 'numberfield', name: 'zoom-max-float', fieldLabel: 'Max Value' | |
249 | - }, | |
250 | - { | |
251 | - xtype: 'button', | |
252 | - width: 100, | |
253 | - text: 'Reset', | |
254 | - scope: this, | |
255 | - handler: function () { | |
256 | - this.resetMinMaxValue(); | |
257 | - } | |
258 | - }, | |
259 | - { | |
260 | - xtype: 'button', | |
261 | - width: 100, | |
262 | - text: 'Use in Time Selection', | |
263 | - scope: this, | |
264 | - handler: function () { | |
265 | - this.setTimePlot(); | |
266 | - } | |
267 | - } | |
268 | - ] | |
269 | - }; | |
270 | - | |
271 | - var insertTypeStore = Ext.create('Ext.data.Store', { | |
272 | - fields: ['key', 'name'], | |
273 | - data: [ | |
274 | - { "key": "timeTable", "name": "TimeTable" }, | |
275 | - { "key": "catalog", "name": "Catalog" } | |
276 | - ] | |
277 | - }); | |
278 | - | |
279 | - var me = this; | |
280 | - this.insertTTFieldSet = { | |
281 | - xtype: 'fieldset', | |
282 | - title: 'Add in Time Table or Catalog', | |
283 | - name: 'tt-insertion-fieldset', | |
284 | - collapsible: false, | |
285 | - layout: { | |
286 | - type: 'vbox', | |
287 | - pack: 'start', | |
288 | - align: 'stretch' | |
289 | - }, | |
290 | - items: [ | |
291 | - { | |
292 | - xtype: 'combo', | |
293 | - fieldLabel: 'Insert In', | |
294 | - store: insertTypeStore, | |
295 | - queryMode: 'local', | |
296 | - displayField: 'name', | |
297 | - valueField: 'key', | |
298 | - editable: false, | |
299 | - value: 'timeTable', | |
300 | - name: 'ttcat-type' | |
301 | - }, | |
302 | - { | |
303 | - xtype: 'textfield', | |
304 | - fieldLabel: 'Name', | |
305 | - name: 'ttcat-name', | |
306 | - listeners: | |
307 | - { | |
308 | - render: function (o, op) { | |
309 | - var field = this; | |
310 | - var el = this.el; | |
311 | - var dropTarget = Ext.create('Ext.dd.DropTarget', el, { | |
312 | - ddGroup: 'explorerTree', | |
313 | - notifyOver: function (ddSource, e, data) { | |
314 | - var TTCatType = me.form.getForm().findField('ttcat-type').getValue(); | |
315 | - if (data.records[0].data.leaf && (data.records[0].data.nodeType == TTCatType)) { | |
316 | - this.valid = true; | |
317 | - return this.dropAllowed; | |
318 | - } | |
319 | - this.valid = false; | |
320 | - return this.dropNotAllowed; | |
321 | - }, | |
322 | - notifyDrop: function (ddSource, e, data) { | |
323 | - if (!this.valid) | |
324 | - return false; | |
325 | - field.setValue(data.records[0].get('text')); | |
326 | - return true; | |
327 | - } | |
328 | - }); | |
329 | - } | |
330 | - } | |
331 | - }, | |
332 | - { | |
333 | - xtype: 'button', | |
334 | - width: 100, | |
335 | - text: 'Insert Interval', | |
336 | - scope: this, | |
337 | - handler: function () { | |
338 | - var me = this; | |
339 | - | |
340 | - var TTCatType = this.form.getForm().findField('ttcat-type').getValue(); | |
341 | - var TTCatName = this.form.getForm().findField('ttcat-name').getValue(); | |
342 | - | |
343 | - var isCatalog = (TTCatType == 'catalog'); | |
344 | - myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) { | |
345 | - var targetModuleUI = module.getUiContent(); | |
346 | - if (me.linkedTTCatNode && (me.linkedTTCatNode.get('text') == TTCatName) && (me.linkedTTCatNode.get('nodeType') == TTCatType)) { | |
347 | - if (targetModuleUI) | |
348 | - me.insertInterval(); | |
349 | - else { | |
350 | - me.linkedTTCatNode.editLeaf(function () { | |
351 | - me.insertInterval(); | |
352 | - }); | |
353 | - } | |
354 | - } | |
355 | - else { | |
356 | - var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
357 | - var ttCatRootNode = explorerTree.getRootNode().findChild('id', isCatalog ? 'catalog-treeRootNode' : 'timeTable-treeRootNode', true); | |
358 | - amdaModel.InteractiveNode.preloadNodes(ttCatRootNode, function () { | |
359 | - var nodeWithSameName = null; | |
360 | - | |
361 | - if (TTCatName != '') | |
362 | - nodeWithSameName = ttCatRootNode.findChild('text', TTCatName, true); | |
363 | - | |
364 | - if (nodeWithSameName !== null) | |
365 | - me.linkedTTCatNode = nodeWithSameName; | |
366 | - else { | |
367 | - module.createLinkedNode(); | |
368 | - module.getLinkedNode().set('text', TTCatName); | |
369 | - me.linkedTTCatNode = module.getLinkedNode(); | |
370 | - var obj = { | |
371 | - name: TTCatName, | |
372 | - fromPlugin: true | |
373 | - }; | |
374 | - if (isCatalog) { | |
375 | - Ext.Msg.prompt('Define Parameters', 'Please enter parameters number for the new catalog:', function (btn, text) { | |
376 | - if (btn == 'ok') { | |
377 | - obj.nbParameters = parseInt(text, 10); | |
378 | - if (isNaN(obj.nbParameters)) { | |
379 | - obj.nbParameters = 1; | |
380 | - } | |
381 | - module.createObject(obj); | |
382 | - me.linkedTTCatNode.editLeaf(function () { | |
383 | - me.insertInterval(); | |
384 | - }); | |
385 | - } | |
386 | - }); | |
387 | - return; | |
388 | - } | |
389 | - else { | |
390 | - module.createObject(obj); | |
391 | - } | |
392 | - } | |
393 | - | |
394 | - me.linkedTTCatNode.editLeaf(function () { | |
395 | - me.insertInterval(); | |
396 | - }); | |
397 | - }); | |
398 | - } | |
399 | - }); | |
400 | - } | |
401 | - } | |
402 | - ] | |
403 | - }; | |
404 | - | |
405 | - this.plotFunctionType = new amdaPlotComp.plotFunction.FunctionType({}); | |
406 | - | |
407 | - this.form = new Ext.form.FormPanel({ | |
408 | - frame: true, | |
409 | - width: 255, | |
410 | - layout: { | |
411 | - type: 'vbox', | |
412 | - pack: 'start', | |
413 | - align: 'stretch' | |
414 | - }, | |
415 | - fieldDefaults: { | |
416 | - labelWidth: 60 | |
417 | - }, | |
418 | - items: [ | |
419 | - intervalFieldSet, | |
420 | - this.isPlotFunction ? this.plotFunctionType : this.insertTTFieldSet | |
421 | - ], | |
422 | - fbar: [ | |
423 | - { | |
424 | - text: me.isPlotFunction ? "Apply The Function" : 'Apply Zoom', | |
425 | - width: me.isPlotFunction ? 200 : 100, | |
426 | - scope: this, | |
427 | - handler: function () { | |
428 | - if (this.zoomType == 'timeAxis') { | |
429 | - var minZoom = Ext.Date.format(this.form.getForm().findField('zoom-min-time').getValue(), 'Y-m-d\\TH:i:s.u'); | |
430 | - var maxZoom = Ext.Date.format(this.form.getForm().findField('zoom-max-time').getValue(), 'Y-m-d\\TH:i:s.u'); | |
431 | - } | |
432 | - else { | |
433 | - var minZoom = this.form.getForm().findField('zoom-min-float').getValue(); | |
434 | - var maxZoom = this.form.getForm().findField('zoom-max-float').getValue(); | |
435 | - } | |
436 | - | |
437 | - if (!maxZoom || !minZoom || !this.form.getForm().isValid()) { | |
438 | - myDesktopApp.warningMsg('Error in values definition'); | |
439 | - return; | |
440 | - } | |
441 | - | |
442 | - if (me.isPlotFunction) { | |
443 | - let request_to_send = {}; | |
444 | - | |
445 | - request_to_send = Object.assign({}, me.plotFunctionType.getValues()/*, me.plotFunctionParamField.getValues()*/); | |
446 | - request_to_send = Object.assign({}, request_to_send, { | |
447 | - 'action': 'plotFunction', | |
448 | - 'interactiveId': this.interactiveId, | |
449 | - 'panelId': this.panelId, | |
450 | - 'starttime': minZoom, | |
451 | - 'stoptime': maxZoom | |
452 | - }); | |
453 | - | |
454 | - this.hostCmp.callInteractivePlot(request_to_send); | |
455 | - } else { | |
456 | - this.hostCmp.callInteractivePlot({ | |
457 | - 'action': 'zoom', | |
458 | - 'interactiveId': this.interactiveId, | |
459 | - 'panelId': this.panelId, | |
460 | - 'axeId': this.zoomType, | |
461 | - 'min': minZoom, | |
462 | - 'max': maxZoom | |
463 | - }); | |
464 | - } | |
465 | - | |
466 | - this.hostCmp.panelImage.resetZoom(); | |
467 | - } | |
468 | - }, | |
469 | - me.isPlotFunction ? null : | |
470 | - { | |
471 | - text: 'Undo Zoom', | |
472 | - width: 100, | |
473 | - scope: this, | |
474 | - handler: function () { | |
475 | - this.hostCmp.callInteractivePlot({ | |
476 | - 'action': 'undozoom', | |
477 | - 'interactiveId': this.interactiveId, | |
478 | - 'panelId': this.panelId, | |
479 | - 'axeId': this.zoomType | |
480 | - }); | |
481 | - this.hostCmp.panelImage.resetZoom(); | |
482 | - } | |
483 | - } | |
484 | - ] | |
485 | - }); | |
486 | - | |
487 | - return this.form; | |
488 | - }, | |
489 | - | |
124 | + this.win.reset(); | |
125 | + } | |
490 | 126 | }); | ... | ... |
js/app/views/PlotComponents/intervalSelection/InsertToTTCatlog.js
js/app/views/PlotComponents/intervalSelection/IntervalSelection.js
... | ... | @@ -86,9 +86,7 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { |
86 | 86 | text: 'Reset', |
87 | 87 | width: width, |
88 | 88 | handler: function () { |
89 | - me._getField1().reset(); | |
90 | - me._getField2().reset(); | |
91 | - me._resetHostCmpSelection(); | |
89 | + me.reset(); | |
92 | 90 | } |
93 | 91 | }, |
94 | 92 | { |
... | ... | @@ -138,6 +136,20 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { |
138 | 136 | return this.parent.down('#' + this.FIELD2_ITEM_ID); |
139 | 137 | }, |
140 | 138 | |
139 | + _setTimeInterval: function () { | |
140 | + const timeObj = new Object(); | |
141 | + timeObj.start = this.getField1Value(); | |
142 | + timeObj.stop = this.getField2Value(); | |
143 | + timeObj.interactiveId = this.interactiveId; | |
144 | + const plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | |
145 | + plotModule.setTimeInterval(timeObj); | |
146 | + }, | |
147 | + | |
148 | + _removeUseTimeButton: function () { | |
149 | + const buttonToHide = this.parent.down('#' + this.buttonUseTime); | |
150 | + buttonToHide.hide(); | |
151 | + }, | |
152 | + | |
141 | 153 | getField1Value: function () { |
142 | 154 | return this._getField1().getValue(); |
143 | 155 | }, |
... | ... | @@ -154,17 +166,9 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { |
154 | 166 | this._getField2().setValue(value); |
155 | 167 | }, |
156 | 168 | |
157 | - _setTimeInterval: function () { | |
158 | - const timeObj = new Object(); | |
159 | - timeObj.start = this.getField1Value(); | |
160 | - timeObj.stop = this.getField2Value(); | |
161 | - timeObj.interactiveId = this.interactiveId; | |
162 | - const plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | |
163 | - plotModule.setTimeInterval(timeObj); | |
164 | - }, | |
165 | - | |
166 | - _removeUseTimeButton: function () { | |
167 | - const buttonToHide = this.parent.down('#' + this.buttonUseTime); | |
168 | - buttonToHide.hide(); | |
169 | + reset: function () { | |
170 | + this._getField1().reset(); | |
171 | + this._getField2().reset(); | |
172 | + this._resetHostCmpSelection(); | |
169 | 173 | } |
170 | 174 | }); | ... | ... |