← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2476: Pivot table: using the orgunit tree instead of orgunit level, improves usability and performance

 

------------------------------------------------------------
revno: 2476
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-01-06 23:22:18 +0100
message:
  Pivot table: using the orgunit tree instead of orgunit level, improves usability and performance
modified:
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pivottable/impl/DefaultPivotTableService.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/pivottable/action/GetPivotTableAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/criteria.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/pivot.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewPivotTableForm.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-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pivottable/impl/DefaultPivotTableService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pivottable/impl/DefaultPivotTableService.java	2010-08-31 05:47:11 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pivottable/impl/DefaultPivotTableService.java	2011-01-06 22:22:18 +0000
@@ -89,7 +89,7 @@
     // PivotTableService implementation
     // -------------------------------------------------------------------------
 
-    public PivotTable getPivotTable( int indicatorGroupId, String periodTypeName, String startDate, String endDate, int level )
+    public PivotTable getPivotTable( int indicatorGroupId, String periodTypeName, String startDate, String endDate, int organisationUnitId )
     {
         PeriodType periodType = PeriodType.getPeriodTypeByName( periodTypeName );
         
@@ -97,7 +97,7 @@
             periodService.getPeriodsBetweenDates( periodType, getMediumDate( startDate ), getMediumDate( endDate ) ) );
         
         List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>( 
-            organisationUnitService.getOrganisationUnitsAtLevel( level ) );
+            organisationUnitService.getOrganisationUnit( organisationUnitId ).getChildren() );
          
         List<Indicator> indicators = null;
         Collection<AggregatedIndicatorValue> indicatorValues = null;

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/pivottable/action/GetPivotTableAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/pivottable/action/GetPivotTableAction.java	2010-05-06 13:24:03 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/pivottable/action/GetPivotTableAction.java	2011-01-06 22:22:18 +0000
@@ -102,11 +102,11 @@
         this.endDate = endDate;
     }
     
-    private Integer level;
+    private Integer organisationUnitId;
 
-    public void setLevel( Integer level )
+    public void setOrganisationUnitId( Integer organisationUnitId )
     {
-        this.level = level;
+        this.organisationUnitId = organisationUnitId;
     }
 
     // -------------------------------------------------------------------------
@@ -126,7 +126,7 @@
 
     public String execute()
     {
-        pivotTable = pivotTableService.getPivotTable( indicatorGroupId, periodTypeName, startDate, endDate, level );
+        pivotTable = pivotTableService.getPivotTable( indicatorGroupId, periodTypeName, startDate, endDate, organisationUnitId );
         
         for ( Period period : pivotTable.getPeriods() )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2011-01-06 12:40:57 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2011-01-06 22:22:18 +0000
@@ -263,7 +263,8 @@
       <result name="success" type="velocity">/main.vm</result>
       <param name="page">/dhis-web-reporting/viewPivotTableForm.vm</param>
       <param name="menu">/dhis-web-reporting/menu.vm</param>
-      <param name="javascripts">javascript/pivot.js,javascript/criteria.js</param>
+      <param name="javascripts">../dhis-web-commons/oust/oust.js,javascript/pivot.js,javascript/criteria.js</param>
+      <interceptor-ref name="organisationUnitTreeStack"/>
     </action>
     
     <action name="getPivotTable" class="org.hisp.dhis.reporting.pivottable.action.GetPivotTableAction">

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/criteria.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/criteria.js	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/criteria.js	2011-01-06 22:22:18 +0000
@@ -13,7 +13,7 @@
 
 function loadIndicatorGroups()
 {
-  var list = document.getElementById( "indicatorGroup" );
+  var list = byId( "indicatorGroup" );
     
   $.getJSON(
     "getIndicatorGroups.action",
@@ -32,7 +32,7 @@
 
 function loadPeriodTypes()
 {
-  var list = document.getElementById( "periodType" );
+  var list = byId( "periodType" );
     
   $.getJSON(
     "getPeriodTypes.action",
@@ -44,25 +44,8 @@
         
         addOption( list, name, name );
       }
-    }
-  );
-}
-
-function loadOrgunitLevels()
-{
-  var list = document.getElementById( "level" );
-  
-  $.getJSON(
-    "getOrganisationUnitLevels.action",
-    function( json )
-    {
-      for ( var i=0; i<json.organisationUnitLevels.length; i++ )
-      {
-        var level = json.organisationUnitLevels[i].level;
-        var name = json.organisationUnitLevels[i].name;
-        
-        addOption( list, level, name );
-      }
+      
+      $( "#periodType option[value=Monthly]" ).attr( "selected", "selected" );
     }
   );
 }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/pivot.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/pivot.js	2010-01-26 15:20:42 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/pivot.js	2011-01-06 22:22:18 +0000
@@ -18,11 +18,21 @@
 var currentPeriod = 0;
 var currentOrgunit = 0;
 
+var organisationUnitId = -1;
+
 // -----------------------------------------------------------------------------
 // Public methods
 // -----------------------------------------------------------------------------
 
 /**
+ * Callback method from oust.
+ */
+function organisationUnitSelected( orgunits )
+{
+	organisationUnitId = orgunits ? orgunits[0] : null;
+}
+
+/**
  * This method is called from the UI and is responsible for retrieving data from 
  * the server and setting the global variables.
  */
@@ -30,23 +40,17 @@
 {
   clearGlobalVariables();
   
-  var indicatorGroupList = document.getElementById( "indicatorGroup" );
-  var periodTypeList = document.getElementById( "periodType" );
-  var levelList = document.getElementById( "level" );
-  
-  var indicatorGroupId = indicatorGroupList.options[ indicatorGroupList.selectedIndex ].value;
-  var indicatorGroupName = indicatorGroupList.options[ indicatorGroupList.selectedIndex ].text;
-  var startDate = document.getElementById( "startDate" ).value;
-  var endDate = document.getElementById( "endDate" ).value;
-  var periodTypeName = periodTypeList.options[ periodTypeList.selectedIndex ].value;
-  var level = levelList.options[ levelList.selectedIndex ].value;
+  var indicatorGroupId = $( "#indicatorGroup" ).val();
+  var indicatorGroupName = $( "#indicatorGroup" ).text();
+  var startDate = $( "#startDate" ).val();
+  var endDate = $( "#endDate" ).val();
+  var periodTypeName = $( "#periodType" ).val();
   
   document.getElementById( "dataLabel" ).innerHTML = 
     i18n_indicator_group + ": " + indicatorGroupName +
     ", " + i18n_start_date + ": " + startDate + 
     ", " + i18n_end_date + ": " + endDate + 
-    ", " + i18n_period_type + ": " + periodTypeName +
-    ", " + i18n_organisation_unit_level + ": " + level;
+    ", " + i18n_period_type + ": " + periodTypeName;
   
   var url = "getPivotTable.action";
   
@@ -61,7 +65,7 @@
       "periodTypeName": periodTypeName, 
       "startDate": startDate, 
       "endDate": endDate, 
-      "level": level 
+      "organisationUnitId": organisationUnitId 
     },
     function( json ) 
     {

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewPivotTableForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewPivotTableForm.vm	2010-09-20 08:49:55 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewPivotTableForm.vm	2011-01-06 22:22:18 +0000
@@ -14,8 +14,8 @@
 {
   position: relative;
   left: 2px;
-  width: 230px;
-  height: 300px;
+  width: 265px;
+  height: 470px;
   border: 1px solid #b0b0b0;
   background-color: #d9ece1;
   padding-left: 20px;
@@ -26,8 +26,8 @@
 {
   position: relative;
   left: 2px;
-  width: 230px;
-  height: 130px;
+  width: 265px;
+  height: 137px;
   border: 1px solid #b0b0b0;
   background-color: #d9ece1;
   padding-left: 20px;
@@ -74,33 +74,28 @@
 
 <p>
 <label>$i18n.getString( "indicator_group" )</label>
-<select id="indicatorGroup" style="width:200px">
+<select id="indicatorGroup" style="width:250px">
   <option value="-1">[ All ]</option>
 </select>
 </p>
 
 <p>
 <label>$i18n.getString( "start_date" ) ($i18n.getString( "format.date.label" ))</label><br>
-<input type="text" id="startDate" style="width:180px">
+<input type="text" id="startDate" style="width:210px">
 </p>
 
 <p>
 <label>$i18n.getString( "end_date" ) ($i18n.getString( "format.date.label" ))</label><br>
-<input type="text" id="endDate" style="width:180px">
+<input type="text" id="endDate" style="width:210px">
 </p>
 
 <p>
 <label>$i18n.getString( "period_type" )</label>
-<select id="periodType" style="width:200px">
-  <option value="null">[ $i18n.getString( "select_period_type" )... ]</option>
-</select>
+<select id="periodType" style="width:250px"></select>
 </p>
 
 <p>
-<label>$i18n.getString( "organisation_unit_level" )</label>
-<select id="level" style="width:200px">
-  <option value="-1">[ $i18n.getString( "select_level" )... ]</option>
-</select>
+<div id="selectionTree" style="width:250px; height:200px"></div>
 </p>
 
 <p>
@@ -174,8 +169,12 @@
 <script type="text/javascript">
   loadIndicatorGroups();
   loadPeriodTypes();
-  loadOrgunitLevels();
   loadListeners();
+  
+  selectionTreeSelection.setMultipleSelectionAllowed( false );
+  selectionTreeSelection.setListenerFunction( organisationUnitSelected );
+  selectionTree.clearSelectedOrganisationUnits();
+  selectionTree.buildSelectionTree();
 </script>
 
 <!-- Calendar setup -->