dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27952
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13939: SQL view, using web api for download
------------------------------------------------------------
revno: 13939
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-02-05 12:56:38 +0200
message:
SQL view, using web api for download
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SqlViewController.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm
--
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/SqlViewController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SqlViewController.java 2013-08-23 16:00:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SqlViewController.java 2014-02-05 10:56:38 +0000
@@ -129,6 +129,19 @@
GridUtils.toHtml( grid, response.getWriter() );
}
+
+ @RequestMapping( value = "/{uid}/data.pdf", method = RequestMethod.GET )
+ public void getViewPdf( @PathVariable( "uid" ) String uid,
+ @RequestParam(required=false) Set<String> criteria, HttpServletResponse response ) throws Exception
+ {
+ SqlView sqlView = sqlViewService.getSqlViewByUid( uid );
+
+ Grid grid = sqlViewService.getSqlViewGrid( sqlView, SqlView.getCriteria( criteria ) );
+
+ contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PDF, CacheStrategy.RESPECT_SYSTEM_SETTING );
+
+ GridUtils.toPdf( grid, response.getOutputStream() );
+ }
@RequestMapping( value = "/{uid}/execute", method = RequestMethod.POST )
public void executeView( @PathVariable( "uid" ) String uid, HttpServletResponse response )
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2014-01-20 10:20:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2014-02-05 10:56:38 +0000
@@ -231,6 +231,8 @@
get_report_as_xls=Download as Excel
get_report_as_csv=Download as CSV
get_report_as_pdf=Download as PDF
+get_report_as_html=Download as HTML
+get_report_as_xml=Download as XML
data_element_structure=Data element structure
constant=Constant
constant_management=Constant Management
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml 2013-12-04 10:20:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml 2014-02-05 10:56:38 +0000
@@ -365,9 +365,6 @@
</action>
<action name="exportSqlView" class="org.hisp.dhis.dataadmin.action.sqlview.ExportSqlViewResultAction">
- <result name="csv" type="gridCsvResult" />
- <result name="xls" type="gridXlsResult" />
- <result name="pdf" type="gridPdfResult" />
<result name="html" type="velocity">/main.vm</result>
<param name="menu">/dhis-web-maintenance-dataadmin/menu.vm</param>
<param name="page">
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js 2014-01-15 11:29:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js 2014-02-05 10:56:38 +0000
@@ -84,9 +84,3 @@
}
);
}
-
-function exportSqlView( id, type ) {
- var url = "exportSqlView.action?id=" + id + "&type=" + type;
-
- window.location.href = url;
-}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm 2013-01-31 05:16:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm 2014-02-05 10:56:38 +0000
@@ -17,9 +17,11 @@
<input type="hidden" id="viewTableName" value="${viewTableName}"/>
<div>
-<input type="button" value="$i18n.getString( 'get_report_as_xls' )" onclick="exportSqlView( '${sqlView.id}', 'xls' )" style="width:140px"/>
-<input type="button" value="$i18n.getString( 'get_report_as_csv' )" onclick="exportSqlView( '${sqlView.id}', 'csv' )" style="width:140px"/>
-<input type="button" value="$i18n.getString( 'get_report_as_pdf' )" onclick="exportSqlView( '${sqlView.id}', 'pdf' )" style="width:140px"/>
+<input type="button" value="$i18n.getString( 'get_report_as_xls' )" onclick="window.location.href='../api/sqlViews/${sqlView.uid}/data.xls'" style="width:140px"/>
+<input type="button" value="$i18n.getString( 'get_report_as_csv' )" onclick="window.location.href='../api/sqlViews/${sqlView.uid}/data.csv'"/>
+<input type="button" value="$i18n.getString( 'get_report_as_pdf' )" onclick="window.location.href='../api/sqlViews/${sqlView.uid}/data.pdf'"/>
+<input type="button" value="$i18n.getString( 'get_report_as_html' )" onclick="window.location.href='../api/sqlViews/${sqlView.uid}/data.html'"/>
+<input type="button" value="$i18n.getString( 'get_report_as_xml' )" onclick="window.location.href='../api/sqlViews/${sqlView.uid}/data.xml'"/>
<input type="button" value="$i18n.getString( 'back' )" onclick="javascript:window.location.href='showSqlViewListForm.action'" style="width:140px"/>
</div>
<br/>