Commit f1405d82fc233d65817c6fda8f23443f2c887aa5
1 parent
2843351a
Exists in
master
and in
32 other branches
Add Button Download for data in the plot preview
Showing
2 changed files
with
82 additions
and
49 deletions
Show diff stats
js/app/views/PlotComponents/PlotPreviewUI.js
... | ... | @@ -187,57 +187,67 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { |
187 | 187 | } |
188 | 188 | } |
189 | 189 | }); |
190 | - var topToolbar = | |
191 | - { | |
192 | - xtype: 'toolbar', | |
193 | - dock: 'top', | |
194 | - items: [{ | |
195 | - xtype: 'datefield', | |
196 | - allowBlank: true, | |
197 | - format: 'Y-m-d\\TH:i:s.u', | |
198 | - id: 'plotPreview-goto-Date' + this.interactiveId, | |
199 | - value: this.time, | |
200 | - width: 175, | |
201 | - renderer: function (value) { | |
202 | - if (value != null) { | |
203 | - if (Ext.isDate(value)) { | |
204 | - return Ext.Date.format(value, 'Y-m-d\\TH:i:s.u'); | |
190 | + | |
191 | + var childrenOfTopToolBar = []; | |
192 | + | |
193 | + if (!me.isPlotFunction) { | |
194 | + childrenOfTopToolBar = [ | |
195 | + { | |
196 | + xtype: 'datefield', | |
197 | + allowBlank: true, | |
198 | + format: 'Y-m-d\\TH:i:s.u', | |
199 | + id: 'plotPreview-goto-Date' + this.interactiveId, | |
200 | + value: this.time, | |
201 | + width: 175, | |
202 | + renderer: function (value) { | |
203 | + if (value != null) { | |
204 | + if (Ext.isDate(value)) { | |
205 | + return Ext.Date.format(value, 'Y-m-d\\TH:i:s.u'); | |
206 | + } else { | |
207 | + return Ext.Date.format(new Date(value), 'Y-m-d\\TH:i:s.u'); | |
208 | + } | |
205 | 209 | } else { |
206 | - return Ext.Date.format(new Date(value), 'Y-m-d\\TH:i:s.u'); | |
210 | + return value; | |
207 | 211 | } |
208 | - } else { | |
209 | - return value; | |
210 | 212 | } |
211 | - } | |
212 | - | |
213 | - }, '-', | |
214 | - { | |
215 | - text: 'Change cut time', | |
216 | - scope: this, | |
217 | - handler: function (bt) { | |
218 | - var newTime = Ext.getCmp('plotPreview-goto-Date' + me.interactiveId).getValue(); | |
219 | - newTime = Ext.Date.add(newTime, Ext.Date.MINUTE, -newTime.getTimezoneOffset()); | |
220 | - me.panelResultInstance.callInteractivePlot({ 'action': 'instant', 'interactiveId': me.panelResultInstance.interactiveId, 'panelId': me.panelId, 'time': newTime.toISOString() }); | |
221 | - } | |
222 | - }, | |
213 | + | |
214 | + }, '-', | |
215 | + { | |
216 | + text: 'Change cut time', | |
217 | + scope: this, | |
218 | + handler: function (bt) { | |
219 | + var newTime = Ext.getCmp('plotPreview-goto-Date' + me.interactiveId).getValue(); | |
220 | + newTime = Ext.Date.add(newTime, Ext.Date.MINUTE, -newTime.getTimezoneOffset()); | |
221 | + me.panelResultInstance.callInteractivePlot({ 'action': 'instant', 'interactiveId': me.panelResultInstance.interactiveId, 'panelId': me.panelId, 'time': newTime.toISOString() }); | |
222 | + } | |
223 | + }, | |
223 | 224 | '-', |
224 | - { | |
225 | - xtype: 'button', | |
226 | - text: 'Previous', | |
227 | - handler: function () { | |
228 | - var newTime = new Date(amdaPlotComp.PlotContextManager.getInstantTimePrev(me.crtContext) * 1000); | |
229 | - me.panelResultInstance.callInteractivePlot({ 'action': 'instant', 'interactiveId': me.panelResultInstance.interactiveId, 'panelId': me.panelId, 'time': newTime.toISOString() }); | |
230 | - } | |
231 | - }, | |
232 | - { | |
233 | - xtype: 'button', | |
234 | - text: 'Next', | |
235 | - handler: function () { | |
236 | - var newTime = new Date(amdaPlotComp.PlotContextManager.getInstantTimeNext(me.crtContext) * 1000); | |
237 | - me.panelResultInstance.callInteractivePlot({ 'action': 'instant', 'interactiveId': me.panelResultInstance.interactiveId, 'panelId': me.panelId, 'time': newTime.toISOString() }); | |
225 | + { | |
226 | + xtype: 'button', | |
227 | + text: 'Previous', | |
228 | + handler: function () { | |
229 | + var newTime = new Date(amdaPlotComp.PlotContextManager.getInstantTimePrev(me.crtContext) * 1000); | |
230 | + me.panelResultInstance.callInteractivePlot({ 'action': 'instant', 'interactiveId': me.panelResultInstance.interactiveId, 'panelId': me.panelId, 'time': newTime.toISOString() }); | |
231 | + } | |
232 | + }, | |
233 | + { | |
234 | + xtype: 'button', | |
235 | + text: 'Next', | |
236 | + handler: function () { | |
237 | + var newTime = new Date(amdaPlotComp.PlotContextManager.getInstantTimeNext(me.crtContext) * 1000); | |
238 | + me.panelResultInstance.callInteractivePlot({ 'action': 'instant', 'interactiveId': me.panelResultInstance.interactiveId, 'panelId': me.panelId, 'time': newTime.toISOString() }); | |
239 | + } | |
238 | 240 | } |
239 | - } | |
240 | - ] | |
241 | + ]; | |
242 | + }; | |
243 | + | |
244 | + childrenOfTopToolBar.push(me.createDownloadButton(configResult)); | |
245 | + | |
246 | + var topToolbar = | |
247 | + { | |
248 | + xtype: 'toolbar', | |
249 | + dock: 'top', | |
250 | + items: childrenOfTopToolBar | |
241 | 251 | } |
242 | 252 | var mouseToolbar = { |
243 | 253 | xtype: 'toolbar', |
... | ... | @@ -290,9 +300,25 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { |
290 | 300 | items: [ |
291 | 301 | this.createPlotImage(configResult.folder, configResult.plotFile) |
292 | 302 | ], |
293 | - dockedItems: me.isPlotFunction ? [mouseToolbar] : [topToolbar, mouseToolbar] | |
303 | + dockedItems:[topToolbar, mouseToolbar] | |
294 | 304 | }; |
295 | 305 | |
296 | 306 | Ext.apply(this, plotPreviewPanelConfig); |
307 | + }, | |
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 | + console.log(configResult); | |
318 | + path +="_data.txt" | |
319 | + console.log(path); | |
320 | + window.open(path, "_blank") | |
321 | + } | |
322 | + }; | |
297 | 323 | } |
298 | 324 | }); | ... | ... |
js/app/views/PlotComponents/PlotZoomPlug.js
... | ... | @@ -437,8 +437,8 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
437 | 437 | ], |
438 | 438 | fbar: [ |
439 | 439 | { |
440 | - text: me.isPlotFunction ? "Apply The Fct" : 'Apply Zoom', | |
441 | - width: 100, | |
440 | + text: me.isPlotFunction ? "Apply The Function" : 'Apply Zoom', | |
441 | + width: me.isPlotFunction ? 200 : 100, | |
442 | 442 | scope: this, |
443 | 443 | handler: function () { |
444 | 444 | if (this.zoomType == 'timeAxis') { |
... | ... | @@ -460,6 +460,12 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
460 | 460 | const stop_time = this.form.getForm().findField('zoom-max-time').getValue(); |
461 | 461 | |
462 | 462 | let request_to_send = {}; |
463 | + | |
464 | + if (!me.plotFunctionType) { | |
465 | + console.log("The component of Function Type is undefined"); | |
466 | + myDesktopApp.warningMsg('Error, try to close the plot function window and reopen it'); | |
467 | + return; | |
468 | + } | |
463 | 469 | request_to_send = Object.assign({}, me.plotFunctionType.getValues()/*, me.plotFunctionParamField.getValues()*/); |
464 | 470 | request_to_send = Object.assign({}, request_to_send, { |
465 | 471 | 'action': 'plotFunction', |
... | ... | @@ -484,6 +490,7 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
484 | 490 | this.hostCmp.panelImage.resetZoom(); |
485 | 491 | } |
486 | 492 | }, |
493 | + me.isPlotFunction ? null : | |
487 | 494 | { |
488 | 495 | text: 'Undo Zoom', |
489 | 496 | width: 100, | ... | ... |