Commit 6e1e1bf4babb1bbcfd6d990010a6c8503fe06b8a

Authored by Benjamin Renard
1 parent 34d92f66

Fix some bugs with plot preview

js/app/views/PlotComponents/PlotPreviewUI.js
... ... @@ -30,6 +30,10 @@ Ext.define('amdaPlotComp.PlotPreviewUI', {
30 30 contextualMenu: null,
31 31 hiddenForm: null,
32 32 panelResultInstance: null,
  33 + gotoDateGroup: null,
  34 + downloadDataBtn: null,
  35 + folder: null,
  36 + plotFile: null,
33 37  
34 38 setPanelResultInstance: function (panelResultInstance_) {
35 39 this.panelResultInstance = panelResultInstance_;
... ... @@ -72,6 +76,8 @@ Ext.define('amdaPlotComp.PlotPreviewUI', {
72 76 createPlotImage: function (resultFolder, plotFile) {
73 77 var me = this;
74 78 var size = this.getImageSize();
  79 + this.folder = resultFolder;
  80 + this.plotFile = plotFile;
75 81 this.panelImage = Ext.create('amdaPlotComp.PlotResultImage', {
76 82 src: this.getImageUrl(resultFolder, plotFile),
77 83 width: size.width,
... ... @@ -142,15 +148,23 @@ Ext.define('amdaPlotComp.PlotPreviewUI', {
142 148  
143 149 updatePlotImage: function (configResult, newPlot) {
144 150 this.crtContext = configResult.context;
  151 + this.isPlotFunction = configResult.plotFile.includes("plotFunction");
  152 + this.interactiveId = configResult.interactiveId;
  153 + this.panelId = configResult.panelId;
  154 + this.folder = configResult.folder;
  155 + this.plotFile = configResult.plotFile;
145 156  
146   - this.panelImage.setSrc(this.getImageUrl(configResult.folder, configResult.plotFile));
147   - var newTime = new Date(configResult.time);
148   - newTime = Ext.Date.add(newTime, Ext.Date.MINUTE, newTime.getTimezoneOffset());
  157 +
  158 + this.panelImage.setSrc(this.getImageUrl(this.folder, configResult.plotFile));
  159 + this.time = new Date(configResult.time);
  160 + this.time = Ext.Date.add(this.time, Ext.Date.MINUTE, this.time.getTimezoneOffset());
149 161 if (!this.isPlotFunction)
150   - Ext.getCmp('plotPreview-goto-Date' + configResult.interactiveId).setValue(newTime);
  162 + Ext.getCmp('plotPreview-goto-Date').setValue(this.time);
151 163 var size = this.getImageSize();
152 164 this.panelImage.setSize(size.width, size.height);
153 165  
  166 + this.gotoDateGroup.setVisible(!this.isPlotFunction);
  167 +
154 168 this.panelImage.refreshMe();
155 169 },
156 170  
... ... @@ -163,6 +177,7 @@ Ext.define('amdaPlotComp.PlotPreviewUI', {
163 177 this.time = Ext.Date.add(this.time, Ext.Date.MINUTE, this.time.getTimezoneOffset());
164 178 this.panelId = configResult.panelId;
165 179 this.isPlotFunction = configResult.plotFile.includes("plotFunction");
  180 + this.plotFile = configResult.plotFile;
166 181  
167 182 this.coordinatesField = new Ext.toolbar.TextItem({
168 183 width: 300,
... ... @@ -188,15 +203,15 @@ Ext.define('amdaPlotComp.PlotPreviewUI', {
188 203 }
189 204 });
190 205  
191   - var childrenOfTopToolBar = [];
192   -
193   - if (!me.isPlotFunction) {
194   - childrenOfTopToolBar = [
  206 + this.gotoDateGroup = new Ext.container.ButtonGroup({
  207 + columns: 4,
  208 + hidden: this.isPlotFunction,
  209 + items: [
195 210 {
196 211 xtype: 'datefield',
197 212 allowBlank: true,
198 213 format: 'Y-m-d\\TH:i:s.u',
199   - id: 'plotPreview-goto-Date' + this.interactiveId,
  214 + id: 'plotPreview-goto-Date',
200 215 value: this.time,
201 216 width: 175,
202 217 renderer: function (value) {
... ... @@ -210,18 +225,17 @@ Ext.define('amdaPlotComp.PlotPreviewUI', {
210 225 return value;
211 226 }
212 227 }
213   -
214   - }, '-',
  228 + },
215 229 {
  230 + xtype: 'button',
216 231 text: 'Change cut time',
217 232 scope: this,
218 233 handler: function (bt) {
219   - var newTime = Ext.getCmp('plotPreview-goto-Date' + me.interactiveId).getValue();
  234 + var newTime = Ext.getCmp('plotPreview-goto-Date').getValue();
220 235 newTime = Ext.Date.add(newTime, Ext.Date.MINUTE, -newTime.getTimezoneOffset());
221 236 me.panelResultInstance.callInteractivePlot({ 'action': 'instant', 'interactiveId': me.panelResultInstance.interactiveId, 'panelId': me.panelId, 'time': newTime.toISOString() });
222 237 }
223 238 },
224   - '-',
225 239 {
226 240 xtype: 'button',
227 241 text: 'Previous',
... ... @@ -238,16 +252,27 @@ Ext.define('amdaPlotComp.PlotPreviewUI', {
238 252 me.panelResultInstance.callInteractivePlot({ 'action': 'instant', 'interactiveId': me.panelResultInstance.interactiveId, 'panelId': me.panelId, 'time': newTime.toISOString() });
239 253 }
240 254 }
241   - ];
242   - };
  255 + ],
  256 + });
243 257  
244   - childrenOfTopToolBar.push(me.createDownloadButton(configResult)); // #10936 - Not fully tested
  258 + this.downloadDataBtn = new Ext.button.Button({
  259 + xtype: 'button',
  260 + text: 'Download Data',
  261 + handler: function () {
  262 + var path = me.getImageUrl(me.folder, me.plotFile.replace(".png", ""));
  263 + path += "_data.txt";
  264 + window.open(path, "_blank");
  265 + }
  266 + });
245 267  
246 268 var topToolbar =
247 269 {
248 270 xtype: 'toolbar',
249 271 dock: 'top',
250   - items: childrenOfTopToolBar
  272 + items: [
  273 + this.gotoDateGroup,
  274 + this.downloadDataBtn,
  275 + ]
251 276 }
252 277 var mouseToolbar = {
253 278 xtype: 'toolbar',
... ... @@ -284,7 +309,8 @@ Ext.define('amdaPlotComp.PlotPreviewUI', {
284 309 params: {
285 310 sessionId: sessionID,
286 311 interactiveId: me.interactiveId,
287   - preview: true
  312 + preview: true,
  313 + function: me.isPlotFunction
288 314 },
289 315 success: function (form, action) { },
290 316 failure: function (form, action) { }
... ... @@ -305,18 +331,4 @@ Ext.define('amdaPlotComp.PlotPreviewUI', {
305 331  
306 332 Ext.apply(this, plotPreviewPanelConfig);
307 333 },
308   -
309   -
310   - createDownloadButton: function (configResult) {
311   - const me = this;
312   - return {
313   - xtype: 'button',
314   - text: 'Download Data',
315   - handler: function () {
316   - var path = me.getImageUrl(configResult.folder, configResult.plotFile.replace(".png", ""));
317   - path += "_data.txt";
318   - window.open(path, "_blank");
319   - }
320   - };
321   - }
322 334 });
... ...
js/app/views/PlotComponents/PlotZoomPlug.js
... ... @@ -20,7 +20,7 @@ Ext.define('amdaPlotComp.PlotZoomPlug', {
20 20 requires: [
21 21 'amdaPlotComp.plotFunction.ParamField', 'amdaPlotComp.plotFunction.FunctionType', 'amdaPlotComp.plotFunction.CreatePlot'],
22 22  
23   - id: 'plot-zoom-plug',
  23 + //id: 'plot-zoom-plug',
24 24  
25 25 ttModuleId: 'timetab-win',
26 26 catModuleId: 'catalog-win',
... ... @@ -58,11 +58,11 @@ Ext.define('amdaPlotComp.PlotZoomPlug', {
58 58 * Set different parameters displayed on the current panel
59 59 * @param {*} listParams_ parameters displayed on the current panel
60 60 */
61   - setParameters: function (listParams_) {
  61 + /*setParameters: function (listParams_) {
62 62 this.listParams = listParams_;
63 63 //this.plotFunctionParamField = new amdaPlotComp.plotFunction.ParamField({ params: this.listParams });
64 64 this.plotFunctionType = new amdaPlotComp.plotFunction.FunctionType({});
65   - },
  65 + },*/
66 66  
67 67  
68 68 setMinValue: function (min) {
... ... @@ -149,7 +149,6 @@ Ext.define('amdaPlotComp.PlotZoomPlug', {
149 149 beforeclose: function () {
150 150 this.hostCmp.panelImage.hidePanelMarker();
151 151 this.hostCmp.panelImage.stopZoom();
152   - Ext.PluginManager.unregister(this);
153 152 },
154 153 show: function(win, eOpts) {
155 154 this.hostCmp.panelImage.showPanelMarker(panelId);
... ... @@ -166,8 +165,6 @@ Ext.define('amdaPlotComp.PlotZoomPlug', {
166 165  
167 166 this.win.on('destroy', this.onDestroy, this);
168 167  
169   - Ext.PluginManager.register(this);
170   -
171 168 this.interactiveId = interactiveId;
172 169 this.updateWinByType(zoomType, panelId);
173 170 this.win.show();
... ... @@ -297,7 +294,7 @@ Ext.define('amdaPlotComp.PlotZoomPlug', {
297 294 });
298 295  
299 296 var me = this;
300   - var insertTTFieldSet = {
  297 + this.insertTTFieldSet = {
301 298 xtype: 'fieldset',
302 299 title: 'Add in Time Table or Catalog',
303 300 name: 'tt-insertion-fieldset',
... ... @@ -422,6 +419,8 @@ Ext.define('amdaPlotComp.PlotZoomPlug', {
422 419 ]
423 420 };
424 421  
  422 + this.plotFunctionType = new amdaPlotComp.plotFunction.FunctionType({});
  423 +
425 424 this.form = new Ext.form.FormPanel({
426 425 frame: true,
427 426 width: 255,
... ... @@ -435,9 +434,7 @@ Ext.define('amdaPlotComp.PlotZoomPlug', {
435 434 },
436 435 items: [
437 436 intervalFieldSet,
438   - //Ici on rajoute les composants associรฉs ร  la fonctionnalitรฉ 'PlotFunction'
439   - me.isPlotFunction ? this.plotFunctionType : insertTTFieldSet,
440   - // me.isPlotFunction ? this.plotFunctionParamField : null,
  437 + this.isPlotFunction ? this.plotFunctionType : this.insertTTFieldSet
441 438 ],
442 439 fbar: [
443 440 {
... ... @@ -462,12 +459,6 @@ Ext.define('amdaPlotComp.PlotZoomPlug', {
462 459 if (me.isPlotFunction) {
463 460 let request_to_send = {};
464 461  
465   - if (!me.plotFunctionType || !me.plotFunctionType.parent) {
466   - console.log("The component of Function Type is undefined");
467   - myDesktopApp.warningMsg('Error, please tryto reopen the plot function window');
468   - me.win.close();
469   - return;
470   - }
471 462 request_to_send = Object.assign({}, me.plotFunctionType.getValues()/*, me.plotFunctionParamField.getValues()*/);
472 463 request_to_send = Object.assign({}, request_to_send, {
473 464 'action': 'plotFunction',
... ... @@ -510,8 +501,6 @@ Ext.define('amdaPlotComp.PlotZoomPlug', {
510 501 ]
511 502 });
512 503  
513   - this.plotFunctionType.setParent(this.form.getForm());
514   - // this.plotFunctionParamField.setParent(this.form.getForm());
515 504 return this.form;
516 505 },
517 506  
... ...
js/app/views/PlotComponents/plotFunction/FunctionType.js
... ... @@ -3,10 +3,7 @@
3 3 */
4 4 Ext.define('amdaPlotComp.plotFunction.FunctionType', {
5 5 extend: 'Ext.form.Panel',
6   - /**
7   - * Le parent composant qui hรฉbรฉrge celui-ci
8   - */
9   - parent: null,
  6 +
10 7 plotFunctionItems: {
11 8 type: {
12 9 name: "type",
... ... @@ -119,7 +116,7 @@ Ext.define('amdaPlotComp.plotFunction.FunctionType', {
119 116  
120 117 const me = this;
121 118  
122   - const tabParams = Ext.create('Ext.form.FieldSet', {
  119 + var tabParams = Ext.create('Ext.form.FieldSet', {
123 120 collapsible: false,
124 121 layout: {
125 122 type: 'vbox',
... ... @@ -141,10 +138,10 @@ Ext.define('amdaPlotComp.plotFunction.FunctionType', {
141 138 listeners: {
142 139 change: function (combo, value) {
143 140 if (value === me.plotFunctionItems.type.values.fft || value === me.plotFunctionItems.type.values.dft) {
144   - me.parent.findField(me.plotFunctionItems.abscisse.name).setVisible(true);
  141 + me.getForm().findField(me.plotFunctionItems.abscisse.name).setVisible(true);
145 142 }
146 143 else {
147   - me.parent.findField(me.plotFunctionItems.abscisse.name).setVisible(false);
  144 + me.getForm().findField(me.plotFunctionItems.abscisse.name).setVisible(false);
148 145 }
149 146 }
150 147 }
... ... @@ -198,22 +195,14 @@ Ext.define('amdaPlotComp.plotFunction.FunctionType', {
198 195 },
199 196  
200 197 /**
201   - * Mettre ร  jour le parent
202   - * @param {*} parent_ le parent qui va hรฉbรฉrger
203   - */
204   - setParent: function (parent_) {
205   - this.parent = parent_;
206   - },
207   -
208   - /**
209 198 * Retournes les valeurs des comboboxes associรฉes ร  ce composant
210 199 * @returns les valeurs des comboboxes se forme d'un dictionnaire
211 200 */
212 201 getValues: function () {
213   - const value_scale = this.parent.findField(this.plotFunctionItems.scale.name).getValue();
214   - const value_abscisse = this.parent.findField(this.plotFunctionItems.abscisse.name).getValue();
215   - const value_scale_ordonnee = this.parent.findField(this.plotFunctionItems.scale_ordonnee.name).getValue();
216   - const type_function = this.parent.findField(this.plotFunctionItems.type.name).getValue();
  202 + const value_scale = this.getForm().findField(this.plotFunctionItems.scale.name).getValue();
  203 + const value_abscisse = this.getForm().findField(this.plotFunctionItems.abscisse.name).getValue();
  204 + const value_scale_ordonnee = this.getForm().findField(this.plotFunctionItems.scale_ordonnee.name).getValue();
  205 + const type_function = this.getForm().findField(this.plotFunctionItems.type.name).getValue();
217 206  
218 207 let out = {};
219 208 out[this.plotFunctionItems.type.name] = type_function;
... ...
js/app/views/PlotTabResultUI.js
... ... @@ -29,7 +29,7 @@ Ext.define('amdaUI.PlotTabResultUI', {
29 29 disableSynchronize: false,
30 30 multiplot: false,
31 31 plotName: '',
32   - listParams: [],
  32 + //listParams: [],
33 33  
34 34 hiddenForm: null,
35 35  
... ... @@ -72,15 +72,15 @@ Ext.define('amdaUI.PlotTabResultUI', {
72 72 },
73 73  
74 74 createZoomItemsForPanel: function (panelId) {
75   - var zoomPlugin = this.getPlugin('plot-zoom-plugin-id');
  75 + var zoomPlugin = this.getPlugin('plot-zoom-plugin-id-'+this.interactiveId);
76 76 if (zoomPlugin == null)
77 77 return;
78 78  
79 79 var panelContext = amdaPlotComp.PlotContextManager.getPanelById(this.crtContext, panelId);
80 80 var size = this.getImageSize();
81 81 // We need a list of parameters to compute the number of points needed to apply FFT
82   - this.listParams = panelContext["parameters"];
83   - zoomPlugin.setParameters(this.listParams);
  82 + //this.listParams = panelContext["parameters"];
  83 + //zoomPlugin.setParameters(this.listParams);
84 84  
85 85  
86 86 var me = this;
... ... @@ -369,7 +369,7 @@ Ext.define('amdaUI.PlotTabResultUI', {
369 369 text: 'Extend/Shift Time interval',
370 370 disabled: me.isTTNavBar,
371 371 handler: function () {
372   - var extendShiftPlugin = this.getPlugin('plot-extendshift-plugin-id');
  372 + var extendShiftPlugin = this.getPlugin('plot-extendshift-plugin-id-'+this.interactiveId);
373 373 extendShiftPlugin.show(me.interactiveId);
374 374 },
375 375 scope: me
... ... @@ -724,7 +724,7 @@ Ext.define('amdaUI.PlotTabResultUI', {
724 724 listeners: {
725 725 scope: this,
726 726 changecomplete: function (s, v) {
727   - var zoomPlugin = this.getPlugin('plot-zoom-plugin-id');
  727 + var zoomPlugin = this.getPlugin('plot-zoom-plugin-id-'+this.interactiveId);
728 728 zoomPlugin.close();
729 729 var size = this.getImageSize();
730 730 this.panelImage.width = size.width;
... ... @@ -764,19 +764,19 @@ Ext.define('amdaUI.PlotTabResultUI', {
764 764 plugins: [
765 765 {
766 766 ptype: 'plotZoomPlugin',
767   - pluginId: 'plot-zoom-plugin-id'
  767 + pluginId: 'plot-zoom-plugin-id-' + this.interactiveId
768 768 },
769 769 {
770 770 ptype: 'plotExtendShiftPlugin',
771   - pluginId: 'plot-extendshift-plugin-id'
  771 + pluginId: 'plot-extendshift-plugin-id-' + this.interactiveId
772 772 }],
773 773 listeners: {
774 774 scope: this,
775 775 destroy: function () {
776   - var zoomPlugin = this.getPlugin('plot-zoom-plugin-id');
  776 + var zoomPlugin = this.getPlugin('plot-zoom-plugin-id-'+this.interactiveId);
777 777 if (zoomPlugin)
778 778 zoomPlugin.close();
779   - var exttendShiftPlugin = this.getPlugin('plot-extendshift-plugin-id');
  779 + var exttendShiftPlugin = this.getPlugin('plot-extendshift-plugin-id-'+this.interactiveId);
780 780 if (exttendShiftPlugin)
781 781 exttendShiftPlugin.close();
782 782 }
... ...
php/downloadPlot.php
... ... @@ -18,11 +18,13 @@ if (!isset($_POST['interactiveId']))
18 18 }
19 19 $interactiveId = $_POST['interactiveId'];
20 20  
21   -$preview = empty($_POST['preview']) ? FALSE : $_POST['preview'];
  21 +$preview = empty($_POST['preview']) ? FALSE : ($_POST['preview'] == "true");
22 22  
23   -download_plot($sessionId, $interactiveId, $preview);
  23 +$preview_function = empty($_POST['function']) ? FALSE : ($_POST['function'] == "true");
24 24  
25   -function download_plot($sessionId, $interactiveId, $preview)
  25 +download_plot($sessionId, $interactiveId, $preview, $preview_function);
  26 +
  27 +function download_plot($sessionId, $interactiveId, $preview, $preview_function)
26 28 {
27 29 // Must be fresh start
28 30 if( headers_sent() )
... ... @@ -40,9 +42,13 @@ function download_plot($sessionId, $interactiveId, $preview)
40 42 if (!$preview) {
41 43 $fullPath = USERPATH."/".$sessionId."/RES/Plot_/".$interactiveId.".png";
42 44 }
43   - else {
  45 + else if (!$preview_function) {
44 46 $fullPath = USERPATH."/".$sessionId."/RES/Plot_/".str_replace('plot_','instant',$interactiveId).".png";
45 47 }
  48 + else {
  49 + $fullPath = USERPATH."/".$sessionId."/RES/Plot_/".str_replace('plot_','plotFunction',$interactiveId).".png";
  50 + }
  51 +
46 52 // File Exists?
47 53 if( file_exists($fullPath) ){
48 54  
... ...