← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3310: Work in progress

 

------------------------------------------------------------
revno: 3310
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-04-07 10:52:20 +0200
message:
  Work in progress
added:
  labs/dhis-web-light/src/main/java/org/hisp/dhis/light/action/GetReportParamsAction.java
  labs/dhis-web-light/src/main/webapp/dhis-web-light/inputReportParamsForm.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardManager.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/webapp/dhis-web-dashboard-integration/mainForm.vm
  labs/dhis-web-light/src/main/java/org/hisp/dhis/light/action/ProvideContentAction.java
  labs/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml
  labs/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties
  labs/dhis-web-light/src/main/resources/struts.xml
  labs/dhis-web-light/src/main/webapp/dhis-web-light/dashboard.vm
  labs/dhis-web-light/src/main/webapp/dhis-web-light/javascript/dhis-web-light.js
  labs/dhis-web-light/src/main/webapp/dhis-web-light/style/dhis-web-light.css


--
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/dashboard/DashboardManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardManager.java	2011-03-24 16:58:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardManager.java	2011-04-07 08:52:20 +0000
@@ -36,6 +36,8 @@
  */
 public interface DashboardManager
 {
+    final String CHART_AREA_PREFIX = "chartArea";
+    
     void setAreaItem( String area, String item );
     
     void clearArea( String area );

=== 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	2011-04-07 07:21:11 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/ProvideContentAction.java	2011-04-07 08:52:20 +0000
@@ -94,11 +94,6 @@
 
     private List<Object> chartAreas = new ArrayList<Object>();
 
-    public void setChartAreas( List<Object> chartAreas )
-    {
-        this.chartAreas = chartAreas;
-    }
-
     public List<Object> getChartAreas()
     {
         return chartAreas;
@@ -124,7 +119,7 @@
         
         for ( int i = 1; i <= chartsInDashboardCount; i++ )
         {
-            chartAreas.add( content.get( "chartArea" + i ) );
+            chartAreas.add( content.get( DashboardManager.CHART_AREA_PREFIX + i ) );
         }
 
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/mainForm.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/mainForm.vm	2011-04-06 20:58:06 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/mainForm.vm	2011-04-07 08:52:20 +0000
@@ -66,13 +66,13 @@
 #set( $startHr = ($count0 % $sizeHalf) == 0 )
 #set( $endHr =  ($count0 % $sizeHalf) == ($sizeHalf - 1) )
 
-#if($startHr) <tr> #end
+#if( $startHr )<tr> #end
 	<td style="width:305px; padding-left: 10px;">
-		#dropDownButtonDiv( "chartDropDown$velocityCount" "chartArea$velocityCount" )
-		#chartDropDownListDiv( "chartArea$velocityCount" "chartDropDown$velocityCount" $chart )
+		#dropDownButtonDiv( "chartDropDown${velocityCount}" "chartArea${velocityCount}" )
+		#chartDropDownListDiv( "chartArea${velocityCount}" "chartDropDown${velocityCount}" $chart )
 	</td>
 #end
-#if($endHr) </tr> #end
+#if( $endHr )</tr> #end
 </table>
 
 	</td>

=== added file 'labs/dhis-web-light/src/main/java/org/hisp/dhis/light/action/GetReportParamsAction.java'
--- labs/dhis-web-light/src/main/java/org/hisp/dhis/light/action/GetReportParamsAction.java	1970-01-01 00:00:00 +0000
+++ labs/dhis-web-light/src/main/java/org/hisp/dhis/light/action/GetReportParamsAction.java	2011-04-07 08:52:20 +0000
@@ -0,0 +1,148 @@
+package org.hisp.dhis.light.action;
+
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.Calendar;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.period.MonthlyPeriodType;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.report.Report;
+import org.hisp.dhis.reporttable.ReportParams;
+import org.hisp.dhis.reporttable.ReportTable;
+import org.hisp.dhis.reporttable.ReportTableService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class GetReportParamsAction
+    implements Action
+{
+    private static final int AVAILABLE_REPORTING_MONTHS = 24;
+    
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ReportTableService reportTableService;
+
+    public void setReportTableService( ReportTableService reportTableService )
+    {
+        this.reportTableService = reportTableService;
+    }
+
+    private I18nFormat format;
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private Integer id;
+
+    public Integer getId()
+    {
+        return id;
+    }
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+        
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private ReportParams reportParams;
+
+    public ReportParams getReportParams()
+    {
+        return reportParams;
+    }
+        
+    private SortedMap<Integer, String> reportingPeriods = new TreeMap<Integer, String>();
+
+    public SortedMap<Integer, String> getReportingPeriods()
+    {
+        return reportingPeriods;
+    }
+    
+    private Report report;
+
+    public Report getReport()
+    {
+        return report;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+        if ( id != null )
+        {
+            ReportTable reportTable = reportTableService.getReportTable( id, ReportTableService.MODE_REPORT_TABLE );
+            
+            if ( reportTable != null )
+            {
+                reportParams = reportTable.getReportParams();
+                                
+                if ( reportParams.isParamReportingMonth() )
+                {
+                    MonthlyPeriodType periodType = new MonthlyPeriodType();
+                    
+                    Calendar cal = PeriodType.createCalendarInstance();
+                    
+                    for ( int i = 0; i < AVAILABLE_REPORTING_MONTHS; i++ )
+                    {
+                        int month = i + 1;    
+                        cal.add( Calendar.MONTH, -1 );                    
+                        Period period = periodType.createPeriod( cal.getTime() );                    
+                        String periodName = format.formatPeriod( period );
+                        
+                        reportingPeriods.put( month, periodName );
+                    }                
+                }
+            }
+        }
+        
+        return SUCCESS;
+    }
+}

=== modified file 'labs/dhis-web-light/src/main/java/org/hisp/dhis/light/action/ProvideContentAction.java'
--- labs/dhis-web-light/src/main/java/org/hisp/dhis/light/action/ProvideContentAction.java	2011-03-28 16:19:29 +0000
+++ labs/dhis-web-light/src/main/java/org/hisp/dhis/light/action/ProvideContentAction.java	2011-04-07 08:52:20 +0000
@@ -1,5 +1,6 @@
 package org.hisp.dhis.light.action;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.hisp.dhis.dashboard.DashboardConfiguration;
@@ -12,7 +13,6 @@
 import org.hisp.dhis.user.User;
 
 import com.opensymphony.xwork2.Action;
-import com.opensymphony.xwork2.ActionContext;
 
 public class ProvideContentAction
     implements Action
@@ -59,6 +59,13 @@
     {
         return documents;
     }
+    
+    private List<String> charts = new ArrayList<String>();
+
+    public List<String> getCharts()
+    {
+        return charts;
+    }
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -68,10 +75,15 @@
         throws Exception
     {
         DashboardConfiguration config = dashboardManager.getConfiguration();
-        
-        if ( config != null )
+
+        for ( int i = 0; i < 8; i++ )
         {
-            ActionContext.getContext().getActionInvocation().getStack().push( config.getAreaItems() );
+            String id = config.getAreaItems().get( DashboardManager.CHART_AREA_PREFIX + ( i + 1 ) );
+            
+            if ( id != null )
+            {
+                charts.add( id );
+            }
         }
         
         User user = currentUserService.getCurrentUser();

=== modified file 'labs/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml'
--- labs/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2011-03-24 19:34:13 +0000
+++ labs/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2011-04-07 08:52:20 +0000
@@ -16,4 +16,9 @@
     <property name="chartService" ref="org.hisp.dhis.chart.ChartService"/>
   </bean>
   
+  <bean id="org.hisp.dhis.light.action.GetReportParamsAction"
+    class="org.hisp.dhis.light.action.GetReportParamsAction" scope="prototype">
+    <property name="reportTableService" ref="org.hisp.dhis.reporttable.ReportTableService"/>
+  </bean>
+  
 </beans>
\ No newline at end of file

=== modified file 'labs/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties'
--- labs/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties	2011-03-24 19:34:13 +0000
+++ labs/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties	2011-04-07 08:52:20 +0000
@@ -0,0 +1,3 @@
+report_table_parameters = Report parameters
+reporting_month = Reporting month
+get_report = Get report

=== modified file 'labs/dhis-web-light/src/main/resources/struts.xml'
--- labs/dhis-web-light/src/main/resources/struts.xml	2011-03-24 19:34:13 +0000
+++ labs/dhis-web-light/src/main/resources/struts.xml	2011-04-07 08:52:20 +0000
@@ -19,5 +19,9 @@
       </result>
     </action>
     
+    <action name="getReportParams" class="org.hisp.dhis.light.action.GetReportParamsAction">
+      <result name="success" type="velocity">/dhis-web-light/inputReportParamsForm.vm</result>
+    </action>
+    
   </package>
 </struts>
\ No newline at end of file

=== modified file 'labs/dhis-web-light/src/main/webapp/dhis-web-light/dashboard.vm'
--- labs/dhis-web-light/src/main/webapp/dhis-web-light/dashboard.vm	2011-04-04 13:45:27 +0000
+++ labs/dhis-web-light/src/main/webapp/dhis-web-light/dashboard.vm	2011-04-07 08:52:20 +0000
@@ -21,6 +21,10 @@
 
 <div class="contentDiv">
 
+#foreach( $id in $charts )
+<div class="contentChartDiv"><img src="getChart.action?id=${id}" style="width:100%"></div>
+#end
+
 #if( $chartAreaA )
 <div class="contentChartDiv"><img src="getChart.action?id=${chartAreaA}" style="width:100%"></div>
 #end
@@ -45,7 +49,7 @@
 
 <div class="contentDiv">
 #foreach( $table in $reportTables )
-<div class="contentItemDiv" id="reportTable${table.id}" onclick="generateReportTable( '${table.id}' )">$encoder.htmlEncode( $table.name )</div>
+<div class="contentItemDiv" id="reportTable${table.id}" onclick="getReportParams( '${table.id}' )">$encoder.htmlEncode( $table.name )</div>
 #end
 </div>
 

=== added file 'labs/dhis-web-light/src/main/webapp/dhis-web-light/inputReportParamsForm.vm'
--- labs/dhis-web-light/src/main/webapp/dhis-web-light/inputReportParamsForm.vm	1970-01-01 00:00:00 +0000
+++ labs/dhis-web-light/src/main/webapp/dhis-web-light/inputReportParamsForm.vm	2011-04-07 08:52:20 +0000
@@ -0,0 +1,100 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd";>
+<html>
+<head>
+  <title>DHIS 2</title>
+  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+  
+  <link type="text/css" rel="stylesheet" media="screen" href="../dhis-web-commons/css/widgets.css">
+  <link type="text/css" rel="stylesheet" media="screen" href="style/dhis-web-light.css">
+  
+  <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/jquery.min.js"></script>
+  <script type="text/javascript" src="../dhis-web-commons/javascripts/commons.js"></script>
+  <script type="text/javascript" src="../dhis-web-commons/javascripts/commons.ajax.js"></script>
+  <script type="text/javascript" src="../dhis-web-commons/oust/oust.js"></script>
+  <script type="text/javascript" src="../request.js"></script>
+  <script type="text/javascript" src="javascript/dhis-web-light.js"></script>
+  
+</head>
+<head>
+<body>
+
+<script type="text/javascript">
+	jQuery(document).ready(function() {
+		#if( !$!reportParams.isSet() )
+		generateReport();
+		#end
+	});
+
+	var i18n_process_completed = '$encoder.jsEscape( $i18n.getString( "process_completed" ), "'")';
+	var i18n_please_wait = '$encoder.jsEscape( $i18n.getString( "please_wait" ), "'")';
+	var i18n_please_select_unit = '$encoder.jsEscape( $i18n.getString( "select_organisation_unit" ), "'")';
+</script>
+
+<h3>$i18n.getString( "report_table_parameters" )</h3>
+
+<input type="hidden" id="id" name="id" value="$!id" />
+
+<table>
+	
+    <!-- Reporting month -->
+    
+    #if ( $!reportParams.isParamReportingMonth() )
+    
+    <tr>
+        <th>$i18n.getString( "reporting_month" )</th>
+    </tr>
+    <tr>
+        <td>
+            <select id="reportingPeriod" name="reportingPeriod" style="width:325px">               
+                #foreach ( $key in $reportingPeriods.keySet() )
+                    <option value="$key">$reportingPeriods.get( $key )</option>
+                #end
+            </select>
+        </td>
+    </tr>
+    <tr>
+        <td colspan="4" style="height:10px"></td>
+    </tr>
+    
+    #end
+    
+    <!-- OrganisationUnit -->
+    
+    #if ( $!reportParams.isParamGrandParentOrganisationUnit() || $!reportParams.isParamParentOrganisationUnit() || $!reportParams.isParamOrganisationUnit() )
+        
+	<tr>
+        <th>$i18n.getString( "organisation_unit" )</th>
+    </tr>
+    <tr>
+	    <td>
+			<div id="selectionTree" style="width:325px; height:200px"></div>	            
+			<script type="text/javascript">
+				selectionTreeSelection.setMultipleSelectionAllowed( false );
+				selectionTreeSelection.setListenerFunction( paramOrganisationUnitSet );
+				selectionTree.clearSelectedOrganisationUnits();
+			    selectionTree.buildSelectionTree();
+			</script>
+	    </td>
+	</tr>
+    <tr>
+        <td colspan="4" style="height:10px"></td>
+    </tr>
+    
+    #end
+    
+    <!-- Submit -->
+    
+    <tr>
+        <td>
+    	#if( $!reportParams.isSet() )
+        <input type="button" value="$i18n.getString( 'get_report' )" onclick="generateReport()" style="width:140px" />
+        <input type="button" value="$i18n.getString( 'back' )" onclick="javascript:window.location.href='displayManageTableForm.action'" style="width:140px" />
+        #end
+        </td>
+    </tr>
+</table>
+
+<span id="message"></span>
+
+</body>
+</html>

=== modified file 'labs/dhis-web-light/src/main/webapp/dhis-web-light/javascript/dhis-web-light.js'
--- labs/dhis-web-light/src/main/webapp/dhis-web-light/javascript/dhis-web-light.js	2011-04-04 13:45:27 +0000
+++ labs/dhis-web-light/src/main/webapp/dhis-web-light/javascript/dhis-web-light.js	2011-04-07 08:52:20 +0000
@@ -1,9 +1,49 @@
 
-$( document ).ready( function() {
-	
-} );
-
-function generateReportTable( id )
-{
-	
+// -----------------------------------------------------------------------------
+// Report table
+// -----------------------------------------------------------------------------
+
+function getReportParams( id )
+{
+	window.location.href = "getReportParams.action?id=" + id;
+}
+
+var paramOrganisationUnit = null;
+
+function paramOrganisationUnitSet( id )
+{
+	paramOrganisationUnit = id;
+}
+
+function validationError()
+{
+	if ( $( "#selectionTree" ).length && paramOrganisationUnit == null )
+	{
+		setMessage( i18n_please_select_unit );
+		return true;
+	}
+	
+	return false;
+}	
+
+function generateReportTable()
+{
+	if ( validationError() )
+	{
+		return false;
+	}
+	
+	var url = "id=" + $( "#id" ).val() + "&mode=" + $( "#mode" ).val();
+	    
+    if ( $( "#reportingPeriod" ).length )
+    {
+        url += "&reportingPeriod=" + $( "#reportingPeriod" ).val();
+    }
+        
+    if ( paramOrganisationUnit != null )
+    {
+        url += "&organisationUnitId=" + paramOrganisationUnit;
+    }
+    
+	window.location.href = "exportTable.action?type=html&" + url;
 }

=== modified file 'labs/dhis-web-light/src/main/webapp/dhis-web-light/style/dhis-web-light.css'
--- labs/dhis-web-light/src/main/webapp/dhis-web-light/style/dhis-web-light.css	2011-04-04 13:45:27 +0000
+++ labs/dhis-web-light/src/main/webapp/dhis-web-light/style/dhis-web-light.css	2011-04-07 08:52:20 +0000
@@ -1,6 +1,10 @@
 
+/*----------------------------------------------------------------------------*/
+/* Dashboard                                                                  */
+/*----------------------------------------------------------------------------*/
+
 html, body {
-  font-family: arial;
+  font-family: sans-serif;
 }
 
 body {
@@ -44,3 +48,62 @@
   background-color: #35699f;
   cursor: pointer;
 }
+
+/*----------------------------------------------------------------------------*/
+/* Organisation Unit Selection Tree                                           */
+/*----------------------------------------------------------------------------*/
+
+div#selectionTree 
+{
+  font-size: 9pt; /* Size to change */
+  background-color: white;
+  height: 300px;
+  width:595px;  
+  overflow:auto;
+  border:1px solid #cccccc;   
+}
+
+div#selectionTree ul 
+{
+  margin: 0em 0em 0em 1.5em;
+}
+
+div#selectionTree>ul 
+{
+  margin-left: 0em;
+}
+
+div#selectionTree li 
+{
+  list-style-type: none;
+  white-space: nowrap; /* Makes list items never wrap */
+}
+
+div#selectionTree span.toggle 
+{
+  font-family: courier new, monospace;
+  font-size: 9pt; /* Size to change */
+  cursor: pointer;
+}
+
+div#selectionTree a 
+{
+  color: black;
+  text-decoration: none;
+  cursor: pointer;
+}
+
+div#selectionTree a:hover 
+{
+  color: #808080;
+}
+
+div#selectionTree a.selected 
+{
+  color: orange;
+}
+
+div#selectionTree a.locked 
+{
+  color: green;
+}