Commit 37e81bff8402c049e9d6e4b5cd6bc5c47b2e28f2
1 parent
e84ed2cf
Exists in
master
and in
111 other branches
Direct save of plots in interactive session
Showing
2 changed files
with
111 additions
and
9 deletions
Show diff stats
js/app/views/PlotTabResultUI.js
@@ -31,6 +31,8 @@ Ext.define('amdaUI.PlotTabResultUI', { | @@ -31,6 +31,8 @@ Ext.define('amdaUI.PlotTabResultUI', { | ||
31 | isTTNavBar : false, | 31 | isTTNavBar : false, |
32 | crtTTFileIndex : 0, | 32 | crtTTFileIndex : 0, |
33 | 33 | ||
34 | + hiddenForm: null, | ||
35 | + | ||
34 | constructor: function(config) { | 36 | constructor: function(config) { |
35 | this.addEvents({'pagesize':true}); | 37 | this.addEvents({'pagesize':true}); |
36 | 38 | ||
@@ -285,15 +287,48 @@ Ext.define('amdaUI.PlotTabResultUI', { | @@ -285,15 +287,48 @@ Ext.define('amdaUI.PlotTabResultUI', { | ||
285 | if (me.contextualMenu.items.getCount() > 0) | 287 | if (me.contextualMenu.items.getCount() > 0) |
286 | me.contextualMenu.add('-'); | 288 | me.contextualMenu.add('-'); |
287 | 289 | ||
288 | - me.contextualMenu.add({ | ||
289 | - text:'Extend/Shift Time request', | ||
290 | - handler : function () | ||
291 | - { | ||
292 | - var extendShiftPlugin = this.getPlugin('plot-extendshift-plugin-id'); | ||
293 | - extendShiftPlugin.show(me.tabId); | ||
294 | - }, | ||
295 | - scope: me | ||
296 | - }); | 290 | + me.contextualMenu.add([ |
291 | + { | ||
292 | + text:'Extend/Shift Time request', | ||
293 | + handler : function () | ||
294 | + { | ||
295 | + var extendShiftPlugin = this.getPlugin('plot-extendshift-plugin-id'); | ||
296 | + extendShiftPlugin.show(me.tabId); | ||
297 | + }, | ||
298 | + scope: me | ||
299 | + }, | ||
300 | + '-', | ||
301 | + { | ||
302 | + text: 'Save Plot', | ||
303 | + handler : function () | ||
304 | + { | ||
305 | + if (me.hiddenForm == null) | ||
306 | + me.hiddenForm = Ext.create('Ext.form.Panel', { | ||
307 | + title:'hiddenForm', | ||
308 | + renderTo: Ext.getBody(), | ||
309 | + standardSubmit: true, | ||
310 | + url: 'php/downloadPlot.php', | ||
311 | + timeout: 120000, | ||
312 | + height:100, | ||
313 | + width: 100, | ||
314 | + hidden:true, | ||
315 | + items:[ | ||
316 | + ] | ||
317 | + }); | ||
318 | + | ||
319 | + me.hiddenForm.getForm().submit({ | ||
320 | + params: { | ||
321 | + sessionId: sessionID, | ||
322 | + tabId : me.tabId | ||
323 | + }, | ||
324 | + success: function(form, action) { | ||
325 | + }, | ||
326 | + failure: function(form, action) { | ||
327 | + } | ||
328 | + }); | ||
329 | + } | ||
330 | + } | ||
331 | + ]); | ||
297 | 332 | ||
298 | me.contextualMenu.showAt(absoluteX, absoluteY); | 333 | me.contextualMenu.showAt(absoluteX, absoluteY); |
299 | } | 334 | } |
@@ -0,0 +1,67 @@ | @@ -0,0 +1,67 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +require_once 'config.php'; | ||
4 | + | ||
5 | +if (!isset($_POST['sessionId'])) | ||
6 | +{ | ||
7 | + header("HTTP/1.0 400 Bad Request"); | ||
8 | + echo json_encode(array("success" => false, "error" => "Unknown session Id")); | ||
9 | + exit; | ||
10 | +} | ||
11 | +$sessionId = $_POST['sessionId']; | ||
12 | + | ||
13 | +if (!isset($_POST['tabId'])) | ||
14 | +{ | ||
15 | + header("HTTP/1.0 400 Bad Request"); | ||
16 | + echo json_encode(array("success" => false, "error" => "Unknown tab Id")); | ||
17 | + exit; | ||
18 | +} | ||
19 | +$tabId = $_POST['tabId']; | ||
20 | + | ||
21 | +download_plot($sessionId, $tabId); | ||
22 | + | ||
23 | +function download_plot($sessionId, $tabId) | ||
24 | +{ | ||
25 | + // Must be fresh start | ||
26 | + if( headers_sent() ) | ||
27 | + { | ||
28 | + header("HTTP/1.0 400 Bad Request"); | ||
29 | + echo json_encode(array("success" => false, "error" => "Headers Sent")); | ||
30 | + return; | ||
31 | + } | ||
32 | + | ||
33 | + // Required for some browsers | ||
34 | + if(ini_get('zlib.output_compression')) | ||
35 | + ini_set('zlib.output_compression', 'Off'); | ||
36 | + | ||
37 | + //Build file path | ||
38 | + $fullPath = USERPATH."/".$sessionId."/RES/Plot_/".$tabId.".png"; | ||
39 | + // File Exists? | ||
40 | + if( file_exists($fullPath) ){ | ||
41 | + | ||
42 | + // Parse Info / Get Extension | ||
43 | + $fsize = filesize($fullPath); | ||
44 | + $path_parts = pathinfo($fullPath); | ||
45 | + $ctype="image/png"; | ||
46 | + | ||
47 | + header("Pragma: public"); // required | ||
48 | + header("Expires: 0"); | ||
49 | + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); | ||
50 | + header("Cache-Control: private",false); // required for certain browsers | ||
51 | + header("Content-Type: $ctype"); | ||
52 | + header("Content-Disposition: attachment; filename=\"".basename($fullPath)."\";" ); | ||
53 | + header("Content-Transfer-Encoding: binary"); | ||
54 | + header("Content-Length: ".$fsize); | ||
55 | + ob_clean(); | ||
56 | + flush(); | ||
57 | + readfile( $fullPath ); | ||
58 | + | ||
59 | + } else | ||
60 | + { | ||
61 | + header("HTTP/1.0 400 Bad Request"); | ||
62 | + echo json_encode(array("success" => false, "error" => "No existing plot")); | ||
63 | + return; | ||
64 | + } | ||
65 | +} | ||
66 | + | ||
67 | +?> | ||
0 | \ No newline at end of file | 68 | \ No newline at end of file |