=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ChartController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ChartController.java 2015-01-12 17:23:39 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ChartController.java 2015-01-14 16:58:34 +0000 @@ -169,6 +169,7 @@ @RequestParam( value = "ou", required = false ) String ou, @RequestParam( value = "width", defaultValue = "800", required = false ) int width, @RequestParam( value = "height", defaultValue = "500", required = false ) int height, + @RequestParam( value = "attachment", required = false ) boolean attachment, HttpServletResponse response ) throws IOException { Chart chart = chartService.getChartNoAcl( uid ); @@ -185,7 +186,7 @@ String filename = CodecUtils.filenameEncode( chart.getName() ) + ".png"; - contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PNG, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, false ); + contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PNG, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, attachment ); ChartUtilities.writeChartAsPNG( response.getOutputStream(), jFreeChart, width, height ); } @@ -198,6 +199,7 @@ @RequestParam( value = "width", defaultValue = "800", required = false ) int width, @RequestParam( value = "height", defaultValue = "500", required = false ) int height, @RequestParam( value = "skipTitle", required = false ) boolean skipTitle, + @RequestParam( value = "attachment", required = false ) boolean attachment, HttpServletResponse response ) throws IOException { Indicator indicator = indicatorService.getIndicator( indicatorUid ); @@ -214,7 +216,7 @@ chart = chartService.getJFreeOrganisationUnitChart( indicator, unit, !skipTitle, i18nManager.getI18nFormat() ); } - contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PNG, CacheStrategy.RESPECT_SYSTEM_SETTING, "chart.png", false ); + contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PNG, CacheStrategy.RESPECT_SYSTEM_SETTING, "chart.png", attachment ); ChartUtilities.writeChartAsPNG( response.getOutputStream(), chart, width, height ); } === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapController.java 2015-01-02 11:37:51 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapController.java 2015-01-14 16:58:34 +0000 @@ -195,6 +195,7 @@ @RequestParam( value = "ou", required = false ) String ou, @RequestParam( required = false ) Integer width, @RequestParam( required = false ) Integer height, + @RequestParam( value = "attachment", required = false ) boolean attachment, HttpServletResponse response ) throws Exception { Map map = mappingService.getMapNoAcl( uid ); @@ -219,7 +220,7 @@ OrganisationUnit unit = ou != null ? organisationUnitService.getOrganisationUnit( ou ) : null; - renderMapViewPng( map, date, unit, width, height, response ); + renderMapViewPng( map, date, unit, width, height, attachment, response ); } //-------------------------------------------------------------------------- @@ -283,14 +284,14 @@ } } - private void renderMapViewPng( Map map, Date date, OrganisationUnit unit, Integer width, Integer height, HttpServletResponse response ) + private void renderMapViewPng( Map map, Date date, OrganisationUnit unit, Integer width, Integer height, boolean attachment, HttpServletResponse response ) throws Exception { BufferedImage image = mapGenerationService.generateMapImage( map, date, unit, width, height ); if ( image != null ) { - contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PNG, CacheStrategy.RESPECT_SYSTEM_SETTING, "map.png", false ); + contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PNG, CacheStrategy.RESPECT_SYSTEM_SETTING, "map.png", attachment ); ImageIO.write( image, "PNG", response.getOutputStream() ); } === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties 2015-01-14 10:27:59 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties 2015-01-14 16:58:34 +0000 @@ -121,3 +121,6 @@ could_not_delete_interpretation=Could not delete interpretation, please try again later could_not_delete_interpretation_comment=Could not delete interpretation comment, please try again later could_not_save_interpretation=Could not save interpretation, please try again later +download=Download +api_link=API link +get_as_image=Get as image \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/dashboard.vm' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/dashboard.vm 2015-01-14 16:50:54 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/dashboard.vm 2015-01-14 16:58:34 +0000 @@ -31,9 +31,10 @@ var i18n_see_fewer_hits = '$encoder.jsEscape( $i18n.getString( "see_fewer_hits" ), "'")'; var i18n_add = '$encoder.jsEscape( $i18n.getString( "add" ), "'")'; var i18n_click_and_drag_to_new_position = '$encoder.jsEscape( $i18n.getString( "click_and_drag_to_new_position" ), "'")'; +var i18n_get_as_image = '$encoder.jsEscape( $i18n.getString( "get_as_image" ), "'")'; jQuery( document ).ready( function() { - dhis2.leftBar.resetPosition(); ## Force left bar initial position when displaying dashboard + dhis2.leftBar.resetPosition(); }); @@ -81,7 +82,11 @@
- +
+ $i18n.getString( "download" ) + $i18n.getString( "api_link" ): +
+
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js 2015-01-14 13:17:15 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js 2015-01-14 16:58:34 +0000 @@ -25,6 +25,7 @@ dhis2.db.currentShareType; dhis2.db.currentShareId; dhis2.db.currentMaxType = []; +dhis2.db.contextPath; dhis2.db.maxItems = 40; dhis2.db.shapeNormal = "normal"; dhis2.db.shapeDoubleWidth = "double_width"; @@ -60,6 +61,10 @@ dhis2.db.currentKey = "dhis2.dashboard.current." + json.username; dhis2.db.renderDashboardListLoadFirst(); } ); + + $.getJSON( "../api/system/info.json", function( json ) { + dhis2.db.contextPath = json.contextPath; + } ); } ); //------------------------------------------------------------------------------ @@ -82,7 +87,7 @@ chartItem: "
  • " + "
  • ${i18n_remove}" + - "${i18n_view}" + + "${i18n_get_as_image}" + "${i18n_share}" + "${i18n_explore}" + "${i18n_resize}" + @@ -92,7 +97,7 @@ eventChartItem: "
  • " + "
  • " + @@ -101,7 +106,7 @@ mapItem: "
  • " + "
  • ${i18n_remove}" + - "${i18n_view}" + + "${i18n_get_as_image}" + "${i18n_share}" + "${i18n_explore}" + "${i18n_resize}" + @@ -111,7 +116,6 @@ reportTableItem: "
  • " + "
  • ${i18n_remove}" + - "${i18n_view}" + "${i18n_share}" + "${i18n_explore}" + "${i18n_resize}" + @@ -121,7 +125,6 @@ eventReportItem: "
  • " + "
  • ${i18n_remove}" + - "${i18n_view}" + "${i18n_share}" + "${i18n_explore}" + "${i18n_resize}" + @@ -531,7 +534,7 @@ if ( "chart" == dashboardItem.type ) { $d.append( $.tmpl( dhis2.db.tmpl.chartItem, { "itemId": dashboardItem.id, "id": dashboardItem.chart.id, "name": dashboardItem.chart.name, "style": style, - "i18n_remove": i18n_remove, "i18n_view": i18n_view_full_size, "i18n_share": i18n_share_interpretation, "i18n_click_and_drag_to_new_position": i18n_click_and_drag_to_new_position } ) ); + "i18n_remove": i18n_remove, "i18n_get_as_image": i18n_get_as_image, "i18n_share": i18n_share_interpretation, "i18n_click_and_drag_to_new_position": i18n_click_and_drag_to_new_position } ) ); DHIS.getChart({ url: '..', @@ -566,7 +569,7 @@ else if ( "eventChart" == dashboardItem.type ) { $d.append( $.tmpl( dhis2.db.tmpl.eventChartItem, { "itemId": dashboardItem.id, "id": dashboardItem.eventChart.id, - "name": dashboardItem.eventChart.name, "style": style, "i18n_remove": i18n_remove, "i18n_view": i18n_view_full_size, + "name": dashboardItem.eventChart.name, "style": style, "i18n_remove": i18n_remove, "i18n_get_as_image": i18n_get_as_image, "i18n_share": i18n_share_interpretation, "i18n_click_and_drag_to_new_position": i18n_click_and_drag_to_new_position, "i18n_explore": i18n_explore } ) ); DHIS.getEventChart({ @@ -602,7 +605,7 @@ else if ( "map" == dashboardItem.type ) { $d.append( $.tmpl( dhis2.db.tmpl.mapItem, { "itemId": dashboardItem.id, "id": dashboardItem.map.id, "name": dashboardItem.map.name, "style": style, - "i18n_remove": i18n_remove, "i18n_view": i18n_view_full_size, "i18n_share": i18n_share_interpretation, "i18n_click_and_drag_to_new_position": i18n_click_and_drag_to_new_position } ) ); + "i18n_remove": i18n_remove, "i18n_get_as_image": i18n_get_as_image, "i18n_share": i18n_share_interpretation, "i18n_click_and_drag_to_new_position": i18n_click_and_drag_to_new_position } ) ); DHIS.getMap({ url: '..', @@ -619,7 +622,7 @@ else if ( "reportTable" == dashboardItem.type ) { $d.append( $.tmpl( dhis2.db.tmpl.reportTableItem, { "itemId": dashboardItem.id, "id": dashboardItem.reportTable.id, "name": dashboardItem.reportTable.name, "style": style, - "i18n_remove": i18n_remove, "i18n_view": i18n_view_full_size, "i18n_share": i18n_share_interpretation, "i18n_click_and_drag_to_new_position": i18n_click_and_drag_to_new_position } ) ); + "i18n_remove": i18n_remove, "i18n_share": i18n_share_interpretation, "i18n_click_and_drag_to_new_position": i18n_click_and_drag_to_new_position } ) ); DHIS.getTable({ url: '..', @@ -637,7 +640,7 @@ else if ( "eventReport" == dashboardItem.type ) { $d.append( $.tmpl( dhis2.db.tmpl.reportTableItem, { "itemId": dashboardItem.id, "id": dashboardItem.reportTable.id, "name": dashboardItem.reportTable.name, "style": style, - "i18n_remove": i18n_remove, "i18n_view": i18n_view_full_size, "i18n_share": i18n_share_interpretation, "i18n_click_and_drag_to_new_position": i18n_click_and_drag_to_new_position } ) ); + "i18n_remove": i18n_remove, "i18n_share": i18n_share_interpretation, "i18n_click_and_drag_to_new_position": i18n_click_and_drag_to_new_position } ) ); DHIS.getEventReport({ url: '..', @@ -1083,11 +1086,16 @@ $( "#chartImage" ).attr( "src", url ); + var link = dhis2.db.contextPath + url.substring( 2 ); + + $( "#chartImageUrl" ).html( link ); + $( "#chartImageUrl" ).attr( "href", link ); + $( "#chartView" ).dialog( { autoOpen : true, modal : true, - height : height + 65, - width : width + 25, + height : height + 110, + width : width + 40, resizable : false, title : title } ); @@ -1112,3 +1120,13 @@ title : title } ); } + +dhis2.db.downloadImage = function() +{ + var url = $( "#chartImage" ).attr( "src" ); + + if ( url ) { + url = url + "&attachment=true"; + window.location.href = url; + } +} === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css 2015-01-14 14:29:24 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css 2015-01-14 16:58:34 +0000 @@ -340,6 +340,19 @@ margin: 0; } +#chartViewHeader +{ + border-bottom: 1px solid #e0e0e0; + padding: 2px 5px 5px 3px; + margin: 6px 6px; +} + +#chartViewHeader a +{ + color: #3162C5; + margin-right: 5px; +} + .gridTable th { text-align: center;