Commit ebafe59efade84aa7e247e2b284dbf010042b214
1 parent
0323cf9d
Exists in
master
and in
108 other branches
Add the possibility to save an instant plot (#5642)
Showing
2 changed files
with
55 additions
and
6 deletions
Show diff stats
js/app/views/PlotComponents/PlotPreviewUI.js
... | ... | @@ -25,6 +25,8 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { |
25 | 25 | panelImage : null, |
26 | 26 | crtContext : null, |
27 | 27 | sliderPage : null, |
28 | + contextualMenu : null, | |
29 | + hiddenForm: null, | |
28 | 30 | |
29 | 31 | constructor: function(config) { |
30 | 32 | this.init(config); |
... | ... | @@ -54,7 +56,10 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { |
54 | 56 | this.panelImage = Ext.create('amdaPlotComp.PlotResultImage', { |
55 | 57 | src : this.getImageUrl(resultFolder, plotFile), |
56 | 58 | width : size.width, |
57 | - height : size.height | |
59 | + height : size.height, | |
60 | + onContextMenu : function(absoluteX, absoluteY, imageX, imageY) { | |
61 | + me.contextualMenu.showAt(absoluteX, absoluteY); | |
62 | + } | |
58 | 63 | }); |
59 | 64 | |
60 | 65 | return this.panelImage; |
... | ... | @@ -72,6 +77,8 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { |
72 | 77 | }, |
73 | 78 | |
74 | 79 | init: function(configResult){ |
80 | + var me = this; | |
81 | + | |
75 | 82 | this.crtContext = configResult.context; |
76 | 83 | this.tabId = configResult.tabId; |
77 | 84 | |
... | ... | @@ -104,6 +111,41 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { |
104 | 111 | this.sliderPage |
105 | 112 | ] |
106 | 113 | }; |
114 | + | |
115 | + this.contextualMenu = Ext.create('Ext.menu.Menu', { | |
116 | + width: 200, | |
117 | + plain: true, | |
118 | + items: [ | |
119 | + { | |
120 | + text: 'Save Plot', | |
121 | + handler : function () | |
122 | + { | |
123 | + if (me.hiddenForm == null) | |
124 | + me.hiddenForm = Ext.create('Ext.form.Panel', { | |
125 | + title:'hiddenForm', | |
126 | + renderTo: Ext.getBody(), | |
127 | + standardSubmit: true, | |
128 | + url: 'php/downloadPlot.php', | |
129 | + timeout: 120000, | |
130 | + height:100, | |
131 | + width: 100, | |
132 | + hidden:true, | |
133 | + items:[] | |
134 | + }); | |
135 | + | |
136 | + me.hiddenForm.getForm().submit({ | |
137 | + params: { | |
138 | + sessionId: sessionID, | |
139 | + tabId : me.tabId, | |
140 | + preview: true | |
141 | + }, | |
142 | + success: function(form, action) {}, | |
143 | + failure: function(form, action) {} | |
144 | + }); | |
145 | + } | |
146 | + } | |
147 | + ] | |
148 | + }); | |
107 | 149 | |
108 | 150 | var plotPreviewPanelConfig = { |
109 | 151 | preventHeader : true, |
... | ... | @@ -116,4 +158,4 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { |
116 | 158 | |
117 | 159 | Ext.apply(this , plotPreviewPanelConfig); |
118 | 160 | } |
119 | -}); | |
120 | 161 | \ No newline at end of file |
162 | +}); | ... | ... |
php/downloadPlot.php
... | ... | @@ -18,9 +18,11 @@ if (!isset($_POST['tabId'])) |
18 | 18 | } |
19 | 19 | $tabId = $_POST['tabId']; |
20 | 20 | |
21 | -download_plot($sessionId, $tabId); | |
21 | +$preview = empty($_POST['preview']) ? FALSE : $_POST['preview']; | |
22 | 22 | |
23 | -function download_plot($sessionId, $tabId) | |
23 | +download_plot($sessionId, $tabId, $preview); | |
24 | + | |
25 | +function download_plot($sessionId, $tabId, $preview) | |
24 | 26 | { |
25 | 27 | // Must be fresh start |
26 | 28 | if( headers_sent() ) |
... | ... | @@ -35,7 +37,12 @@ function download_plot($sessionId, $tabId) |
35 | 37 | ini_set('zlib.output_compression', 'Off'); |
36 | 38 | |
37 | 39 | //Build file path |
38 | - $fullPath = USERPATH."/".$sessionId."/RES/Plot_/".$tabId.".png"; | |
40 | + if (!$preview) { | |
41 | + $fullPath = USERPATH."/".$sessionId."/RES/Plot_/".$tabId.".png"; | |
42 | + } | |
43 | + else { | |
44 | + $fullPath = USERPATH."/".$sessionId."/RES/Plot_/".str_replace('plot_','instant',$tabId).".png"; | |
45 | + } | |
39 | 46 | // File Exists? |
40 | 47 | if( file_exists($fullPath) ){ |
41 | 48 | |
... | ... | @@ -64,4 +71,4 @@ function download_plot($sessionId, $tabId) |
64 | 71 | } |
65 | 72 | } |
66 | 73 | |
67 | -?> | |
68 | 74 | \ No newline at end of file |
75 | +?> | ... | ... |