← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9272: Dashboard, adding an org unit parameter to the chart request if the chart contains user org unit/...

 

------------------------------------------------------------
revno: 9272
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-12-11 22:17:31 +0100
message:
  Dashboard, adding an org unit parameter to the chart request if the chart contains user org unit/children. This is necessary when you have a server/proxy cache in order to distinguish between the requests.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/ProvideContentAction.java
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/dashboard.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/chart/Chart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java	2012-09-24 13:50:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java	2012-12-11 21:17:31 +0000
@@ -363,6 +363,11 @@
         return 500;
     }
 
+    public boolean hasUserOrgUnit()
+    {
+        return userOrganisationUnit || userOrganisationUnitChildren;
+    }
+    
     // -------------------------------------------------------------------------
     // Getters and setters
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/ProvideContentAction.java'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/ProvideContentAction.java	2012-06-03 16:26:12 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/ProvideContentAction.java	2012-12-11 21:17:31 +0000
@@ -37,6 +37,9 @@
 import org.hisp.dhis.chart.ChartService;
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.dashboard.DashboardManager;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
 
 import com.opensymphony.xwork2.Action;
 import com.opensymphony.xwork2.ActionContext;
@@ -65,6 +68,13 @@
     {
         this.chartService = chartService;
     }
+    
+    private CurrentUserService currentUserService;
+
+    public void setCurrentUserService( CurrentUserService currentUserService )
+    {
+        this.currentUserService = currentUserService;
+    }
 
     // -------------------------------------------------------------------------
     // Input
@@ -101,6 +111,13 @@
     {
         return chartAreas;
     }
+    
+    private OrganisationUnit organisationUnit;
+
+    public OrganisationUnit getOrganisationUnit()
+    {
+        return organisationUnit;
+    }
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -133,7 +150,14 @@
             
             chartAreas.add( chart );
         }
+        
+        User user = currentUserService.getCurrentUser();
 
+        if ( user != null )
+        {
+            organisationUnit = user.getOrganisationUnit();
+        }
+        
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml	2012-10-14 18:31:58 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml	2012-12-11 21:17:31 +0000
@@ -15,6 +15,7 @@
     scope="prototype">
     <property name="manager" ref="org.hisp.dhis.dashboard.DashboardManager" />
     <property name="chartService" ref="org.hisp.dhis.chart.ChartService" />
+    <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
   </bean>
 
   <bean id="org.hisp.dhis.dashboard.action.SetAreaItemAction" class="org.hisp.dhis.dashboard.action.SetAreaItemAction"

=== 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	2012-12-05 15:11:32 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/dashboard.vm	2012-12-11 21:17:31 +0000
@@ -13,7 +13,7 @@
     <a href="javascript:hideDropDown()">$i18n.getString( "close" )</a>
     <a href="javascript:clearArea( '${areaDivId}' )">$i18n.getString( "clear" )</a>
     #if( $chart )
-    <a href="javascript:viewChart( '../api/charts/${chart.uid}/data', '${encoder.htmlEncode( $chart.name )}' )">$i18n.getString( "view_full_size" )</a>
+    <a href="javascript:viewChart( '../api/charts/${chart.uid}/data#if( $chart.hasUserOrgUnit() )?ou=${organisationUnit.uid}#end', '${encoder.htmlEncode( $chart.name )}' )">$i18n.getString( "view_full_size" )</a>
     <a href="javascript:viewShareForm( '${chart.uid}', '${encoder.htmlEncode( $chart.name )}' )">$i18n.getString( "share" )</a>
     #end
 </div>
@@ -49,7 +49,8 @@
         </ul>
     </div>
     #if ( $chart )
-        <img style="cursor:pointer" src="../api/charts/${chart.uid}/data?width=310&height=310" onclick="explore( '${chart.uid}' )" title="$i18n.getString( 'click_to_explore' )">
+        <img style="cursor:pointer" src="../api/charts/${chart.uid}/data?width=310&height=310#if( $chart.hasUserOrgUnit() )&ou=${organisationUnit.uid}#end" 
+            onclick="explore( '${chart.uid}' )" title="$i18n.getString( 'click_to_explore' )">
     #else
         <div class="labelText">
         	$i18n.getString( 'this_is_a_chart_area' )<br><br>