dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17676
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7124: Impl report table interpretations in dashboard
------------------------------------------------------------
revno: 7124
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-05-31 23:51:26 +0200
message:
Impl report table interpretations in dashboard
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java
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/webapp/dhis-web-dashboard-integration/interpretation.vm
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.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-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java 2012-05-31 18:16:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java 2012-05-31 21:51:26 +0000
@@ -38,6 +38,7 @@
import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.reporttable.ReportTable;
import org.hisp.dhis.user.User;
@@ -56,6 +57,8 @@
private ReportTable reportTable;
+ private OrganisationUnit organisationUnit; // Applicable to report table only
+
private String text;
private User user;
@@ -81,9 +84,10 @@
this.created = new Date();
}
- public Interpretation( ReportTable reportTable, String text )
+ public Interpretation( ReportTable reportTable, OrganisationUnit organisationUnit, String text )
{
this.reportTable = reportTable;
+ this.organisationUnit = organisationUnit;
this.text = text;
this.created = new Date();
}
@@ -97,6 +101,16 @@
this.comments.add( comment );
}
+ public boolean isChartInterpretation()
+ {
+ return chart != null;
+ }
+
+ public boolean isReportTableInterpretation()
+ {
+ return reportTable != null;
+ }
+
// -------------------------------------------------------------------------
// Get and set methods
// -------------------------------------------------------------------------
@@ -130,6 +144,20 @@
}
@JsonProperty
+ @JsonDeserialize( as = BaseIdentifiableObject.class )
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ public OrganisationUnit getOrganisationUnit()
+ {
+ return organisationUnit;
+ }
+
+ public void setOrganisationUnit( OrganisationUnit organisationUnit )
+ {
+ this.organisationUnit = organisationUnit;
+ }
+
+ @JsonProperty
@JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
public String getText()
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml 2012-05-31 18:16:45 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml 2012-05-31 21:51:26 +0000
@@ -20,7 +20,10 @@
<many-to-one name="reportTable" class="org.hisp.dhis.reporttable.ReportTable" column="reporttableid"
foreign-key="fk_interpretation_reporttableid" />
-
+
+ <many-to-one name="organisationUnit" class="org.hisp.dhis.organisationunit.OrganisationUnit" column="organisationunitid"
+ foreign-key="fk_interpretation_organisationunitid" />
+
<property name="text" column="interpretationtext" type="text" />
<many-to-one name="user" class="org.hisp.dhis.user.User" column="userid"
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java 2012-05-31 20:29:41 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java 2012-05-31 21:51:26 +0000
@@ -33,6 +33,8 @@
import org.hisp.dhis.common.Pager;
import org.hisp.dhis.interpretation.Interpretation;
import org.hisp.dhis.interpretation.InterpretationService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.reporttable.ReportTable;
import org.hisp.dhis.reporttable.ReportTableService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -41,6 +43,7 @@
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;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@@ -67,6 +70,9 @@
@Autowired
private ReportTableService reportTableService;
+ @Autowired
+ private OrganisationUnitService organisationUnitService;
+
@Override
protected List<Interpretation> getEntityList( WebMetaData metaData, WebOptions options )
{
@@ -97,13 +103,15 @@
}
@RequestMapping( value = "/chart/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } )
- public void shareChartInterpretation( @PathVariable( "uid" ) String chartUid, @RequestBody String text, HttpServletResponse response ) throws IOException
+ public void shareChartInterpretation(
+ @PathVariable( "uid" ) String chartUid,
+ @RequestBody String text, HttpServletResponse response ) throws IOException
{
Chart chart = chartService.getChart( chartUid );
if ( chart == null )
{
- ContextUtils.conflictResponse( response, "Chart identifier not valid" );
+ ContextUtils.conflictResponse( response, "Chart identifier not valid: " + chartUid);
return;
}
@@ -115,17 +123,33 @@
}
@RequestMapping( value = "/reportTable/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } )
- public void shareReportTableInterpretation( @PathVariable( "uid" ) String reportTableUid, @RequestBody String text, HttpServletResponse response ) throws IOException
+ public void shareReportTableInterpretation(
+ @PathVariable( "uid" ) String reportTableUid,
+ @RequestParam( value = "ou", required = false ) String orgUnitUid,
+ @RequestBody String text, HttpServletResponse response ) throws IOException
{
ReportTable reportTable = reportTableService.getReportTable( reportTableUid );
if ( reportTable == null )
{
- ContextUtils.conflictResponse( response, "Report table identifier not valid" );
+ ContextUtils.conflictResponse( response, "Report table identifier not valid: " + reportTableUid );
return;
}
- Interpretation interpretation = new Interpretation( reportTable, text );
+ OrganisationUnit orgUnit = null;
+
+ if ( orgUnitUid != null )
+ {
+ orgUnit = organisationUnitService.getOrganisationUnit( orgUnitUid );
+
+ if ( orgUnit == null )
+ {
+ ContextUtils.conflictResponse( response, "Organisation unit identifier not valid: " + orgUnitUid );
+ return;
+ }
+ }
+
+ Interpretation interpretation = new Interpretation( reportTable, orgUnit, text );
interpretationService.saveInterpretation( interpretation );
@@ -133,7 +157,9 @@
}
@RequestMapping( value = "/{uid}/comment", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } )
- public void postComment( @PathVariable( "uid" ) String uid, @RequestBody String text, HttpServletResponse response ) throws IOException
+ public void postComment(
+ @PathVariable( "uid" ) String uid,
+ @RequestBody String text, HttpServletResponse response ) throws IOException
{
interpretationService.addInterpretationComment( uid, text );
=== 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 2012-05-29 21:23:47 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties 2012-05-31 21:51:26 +0000
@@ -40,4 +40,5 @@
data_visualizer=Data Visualizer
add_a_comment=Add a comment
new_interpretations=new interpretations
-new_interpretation=new interpretation
\ No newline at end of file
+new_interpretation=new interpretation
+click_to_view_report_table=Click to view report table
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretation.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretation.vm 2012-05-31 20:29:41 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretation.vm 2012-05-31 21:51:26 +0000
@@ -14,12 +14,19 @@
<div class="interpretationText">
${ip.text}
</div>
+ #if( $ip.chartInterpretation )
<div class="interpretationChart">
<img style="cursor:pointer"
src="../api/charts/${ip.chart.uid}/data?date=${format.formatDate( $ip.created )}&width=530&height=300"
onclick="javascript:window.location.href='../dhis-web-visualizer/app/index.html?id=${ip.chart.uid}&date=${format.formatDate( $ip.created )}'"
title="Click to view in Data Visualizer">
</div>
+ #else
+ <div class="interpretationChart">
+ #if( $ip.organisationUnit )#set( $ou = "&ou=" + $ip.organisationUnit.uid )#else#set( $ou = "" )#end
+ <a class="bold" title="$i18n.getString( 'click_to_view_report_table' )" href="../dhis-web-reporting/exportTable.action?uid=${ip.reportTable.uid}?pe=${format.formatDate( $ip.created )}${ou}">$encoder.htmlEncode( $ip.reportTable.name )</a>
+ </div>
+ #end
#set( $comments = $ip.comments )
<div class="interpretationCommentArea">
@@ -36,7 +43,7 @@
</div>
#end
</div>
- <textarea id="commentArea${ip.uid}" class="commentArea" placeholder="$i18n.getString( 'add_a_comment' )..."></textarea><br>
+ <textarea id="commentArea${ip.uid}" class="commentArea" placeholder="$i18n.getString( 'add_a_comment' )..."></textarea>
<input type="button" class="commentButton" value="Post comment" onclick="postComment( '${ip.uid}' )">
</div>
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js 2012-05-29 21:23:47 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js 2012-05-31 21:51:26 +0000
@@ -23,20 +23,23 @@
var created = getCurrentDate();
- $.ajax( url, {
- type: "POST",
- contentType: "text/html",
- data: text,
- success: function() {
- var template =
- "<div><div class=\"interpretationName\"><span class=\"bold pointer\" " +
- "onclick=\"showUserInfo( \'${userId}\' )\">${userName}<\/span> " +
- "<span class=\"grey\">${created}<\/span><\/div><\/div>" +
- "<div class=\"interpretationText\">${text}<\/div>";
-
- $.tmpl( template, { "userId": currentUser.id, "userName": currentUser.name, created: created, text: text } ).appendTo( "#comments" + uid );
-
- $( "#commentArea" + uid ).val( "" );
- }
- } );
+ if ( text.length && $.trim( text ).length )
+ {
+ $.ajax( url, {
+ type: "POST",
+ contentType: "text/html",
+ data: $.trim( text ),
+ success: function() {
+ var template =
+ "<div><div class=\"interpretationName\"><span class=\"bold pointer\" " +
+ "onclick=\"showUserInfo( \'${userId}\' )\">${userName}<\/span> " +
+ "<span class=\"grey\">${created}<\/span><\/div><\/div>" +
+ "<div class=\"interpretationText\">${text}<\/div>";
+
+ $.tmpl( template, { "userId": currentUser.id, "userName": currentUser.name, created: created, text: text } ).appendTo( "#comments" + uid );
+
+ $( "#commentArea" + uid ).val( "" );
+ }
+ } );
+ }
}
\ No newline at end of file
=== 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 2012-05-29 19:30:37 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css 2012-05-31 21:51:26 +0000
@@ -166,20 +166,19 @@
.interpretationText
{
- margin-bottom: 18px;
+ margin-bottom: 16px;
}
.interpretationChart
{
- margin-bottom: 12px;
+ margin-bottom: 16px;
}
.interpretationCommentArea
{
margin-top: 10px;
padding: 18px 20px 14px 20px;
- background-color: #f2f3f4;
- border: 1px solid #d5d5d5;
+ background-color: #eef1f3;
border-radius: 3px;
}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java 2012-05-31 20:29:41 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java 2012-05-31 21:51:26 +0000
@@ -81,7 +81,23 @@
{
this.format = format;
}
-
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private String uid;
+
+ public String getUid()
+ {
+ return uid;
+ }
+
+ public void setUid( String uid )
+ {
+ this.uid = uid;
+ }
+
private String pe;
public void setPe( String pe )
@@ -91,27 +107,16 @@
private String ou;
+ public String getOu()
+ {
+ return ou;
+ }
+
public void setOu( String ou )
{
this.ou = ou;
}
-
- // -------------------------------------------------------------------------
- // Input
- // -------------------------------------------------------------------------
-
- private String uid;
-
- public String getUid()
- {
- return uid;
- }
-
- public void setUid( String uid )
- {
- this.uid = uid;
- }
-
+
private String type;
public void setType( String type )
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js 2012-05-31 20:29:41 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js 2012-05-31 21:51:26 +0000
@@ -84,14 +84,18 @@
} );
}
-function shareInterpretation( uid )
+function shareInterpretation( uid, ou )
{
var text = $( "#interpretationArea" ).val();
- if ( text.length )
+ if ( text.length && $.trim( text ).length )
{
+ text = $.trim( text );
+
var url = "../api/interpretations/reportTable/" + uid;
+ url += ( ou && ou.length ) ? "?ou=" + ou : "";
+
$.ajax( url, {
type: "POST",
contentType: "text/html",
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm 2012-05-31 20:29:41 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm 2012-05-31 21:51:26 +0000
@@ -22,5 +22,5 @@
<div id="shareForm">
<textarea id="interpretationArea" class="interpretationArea" placeholder="$i18n.getString( 'write_your_interpretation' )..."></textarea>
-<input type="button" class="interpretationButton" value="$i18n.getString( 'share' )" onclick="shareInterpretation( '${uid}' )">
+<input type="button" class="interpretationButton" value="$i18n.getString( 'share' )" onclick="shareInterpretation( '${uid}', '$!{ou}' )">
</div>
\ No newline at end of file