dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27061
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13420: DV, migrating export of chart to png and pdf to web api
------------------------------------------------------------
revno: 13420
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-12-24 16:33:27 +0100
message:
DV, migrating export of chart to png and pdf to web api
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SvgConversionController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java
dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/index.html
dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SvgConversionController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SvgConversionController.java 2013-12-23 22:31:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SvgConversionController.java 2013-12-24 15:33:27 +0000
@@ -45,7 +45,6 @@
import org.hisp.dhis.system.util.CodecUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@@ -57,8 +56,8 @@
@Autowired
private ContextUtils contextUtils;
- @RequestMapping( value = "/svg.png", method = RequestMethod.POST, consumes = ContextUtils.CONTENT_TYPE_XML )
- public void toPng( @RequestBody String svg, @RequestParam( required = false ) String filename, HttpServletResponse response )
+ @RequestMapping( value = "/svg.png", method = RequestMethod.POST, consumes = { ContextUtils.CONTENT_TYPE_XML, ContextUtils.CONTENT_TYPE_FORM_ENCODED } )
+ public void toPng( @RequestParam String svg, @RequestParam( required = false ) String filename, HttpServletResponse response )
throws Exception
{
String name = filename != null ? ( CodecUtils.filenameEncode( filename ) + ".png" ) : "file.png";
@@ -68,8 +67,8 @@
convertToPng( svg, response.getOutputStream() );
}
- @RequestMapping( value = "/svg.pdf", method = RequestMethod.POST, consumes = ContextUtils.CONTENT_TYPE_XML )
- public void toPdf( @RequestBody String svg, @RequestParam( required = false ) String filename, HttpServletResponse response )
+ @RequestMapping( value = "/svg.pdf", method = RequestMethod.POST, consumes = { ContextUtils.CONTENT_TYPE_XML, ContextUtils.CONTENT_TYPE_FORM_ENCODED } )
+ public void toPdf( @RequestParam String svg, @RequestParam( required = false ) String filename, HttpServletResponse response )
throws Exception
{
String name = filename != null ? ( CodecUtils.filenameEncode( filename ) + ".pdf" ) : "file.pdf";
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java 2013-12-22 09:15:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java 2013-12-24 15:33:27 +0000
@@ -74,6 +74,7 @@
public static final String CONTENT_TYPE_JPG = "image/jpeg";
public static final String CONTENT_TYPE_EXCEL = "application/vnd.ms-excel";
public static final String CONTENT_TYPE_JAVASCRIPT = "application/javascript; charset=UTF-8";
+ public static final String CONTENT_TYPE_FORM_ENCODED = "application/x-www-form-urlencoded";
public static final String HEADER_USER_AGENT = "User-Agent";
public static final String HEADER_CACHE_CONTROL = "Cache-Control";
=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/index.html'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/index.html 2013-11-28 11:24:14 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/index.html 2013-12-24 15:33:27 +0000
@@ -13,8 +13,7 @@
<body>
<form id="exportForm" method="post">
<input type="hidden" id="svgField" name="svg"/>
- <input type="hidden" id="typeField" name="type"/>
- <input type="hidden" id="nameField" name="name"/>
+ <input type="hidden" id="filenameField" name="filename"/>
</form>
<script src="../../dhis-web-commons/javascripts/ext/ext-all.js"></script>
=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js 2013-12-24 15:22:04 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js 2013-12-24 15:33:27 +0000
@@ -1356,10 +1356,9 @@
svg = svg.parent().dom.innerHTML;
Ext.query('#svgField')[0].value = svg;
- Ext.query('#typeField')[0].value = type;
- Ext.query('#nameField')[0].value = 'test';
+ Ext.query('#filenameField')[0].value = 'test';
- form.action = '../exportImage.action';
+ form.action = '../../api/svg.' + type;
form.submit();
};
}());