← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5544: User/system charts. Work in progress.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 5544 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-12-22 14:58:49 +0100
message:
  User/system charts. Work in progress.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml
  dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java
  dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/style.css
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/jsonInitialize.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	2011-12-22 13:09:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java	2011-12-22 13:11:13 +0000
@@ -44,6 +44,7 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.RelativePeriods;
+import org.hisp.dhis.user.User;
 
 import javax.xml.bind.annotation.*;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -122,6 +123,8 @@
     private RelativePeriods relatives;
 
     private boolean userOrganisationUnit;
+    
+    private User user;
 
     // -------------------------------------------------------------------------
     // Transient properties
@@ -645,4 +648,14 @@
     {
         this.groups = groups;
     }
+
+    public User getUser()
+    {
+        return user;
+    }
+
+    public void setUser( User user )
+    {
+        this.user = user;
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml	2011-12-22 13:09:31 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml	2011-12-22 13:57:33 +0000
@@ -86,6 +86,8 @@
     </component>
 
     <property name="userOrganisationUnit" not-null="true" />
+    
+    <many-to-one name="user" class="org.hisp.dhis.user.User" column="userid" foreign-key="fk_chart_userid" />
 
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java	2011-12-19 21:47:47 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java	2011-12-22 13:09:43 +0000
@@ -39,6 +39,7 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.RelativePeriods;
+import org.hisp.dhis.user.CurrentUserService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -79,6 +80,13 @@
     {
         this.organisationUnitService = organisationUnitService;
     }
+    
+    private CurrentUserService currentUserService;
+
+    public void setCurrentUserService( CurrentUserService currentUserService )
+    {
+        this.currentUserService = currentUserService;
+    }
 
     // -------------------------------------------------------------------------
     // Input
@@ -202,6 +210,13 @@
     {
         this.organisationUnitIds = organisationUnitIds;
     }
+    
+    private boolean system;
+
+    public void setSystem( boolean system )
+    {
+        this.system = system;
+    }
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -277,6 +292,11 @@
             chart.setOrganisationUnits( new ArrayList<OrganisationUnit>( organisationUnitService
                 .getOrganisationUnits( organisationUnitIds ) ) );
         }
+        
+        if ( !system )
+        {
+            chart.setUser( currentUserService.getCurrentUser() );
+        }
 
         chartService.saveOrUpdate( chart );
 

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/META-INF/dhis/beans.xml	2011-12-14 19:46:03 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/META-INF/dhis/beans.xml	2011-12-22 13:43:32 +0000
@@ -57,6 +57,7 @@
         <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
         <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
         <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+        <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
     </bean>
 
     <bean id="org.hisp.dhis.visualizer.action.DeleteChartsAction"

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/struts.xml	2011-12-14 13:52:15 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/struts.xml	2011-12-22 12:01:45 +0000
@@ -51,6 +51,14 @@
 
         <!-- Chart -->
 
+        <action name="addOrUpdateSystemChart"
+            class="org.hisp.dhis.visualizer.action.AddOrUpdateChartAction">
+            <result name="success" type="velocity-json">
+                /dhis-web-visualizer/void.vm</result>
+            <param name="requiredAuthorities">F_DV_ADMIN</param>
+            <param name="system">true</param>
+        </action>
+
         <action name="addOrUpdateChart"
             class="org.hisp.dhis.visualizer.action.AddOrUpdateChartAction">
             <result name="success" type="velocity-json">

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js	2011-12-22 09:50:44 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js	2011-12-22 13:11:13 +0000
@@ -8,7 +8,7 @@
         ],
         jsonfy: function(r) {
             r = Ext.JSON.decode(r.responseText);
-            var obj = {system: {rootNode: {id: r.rn[0], name: r.rn[1], level: 1}, periods: {}}};
+            var obj = {system: {rootNode: {id: r.rn[0], name: r.rn[1], level: 1}, periods: {}, isAdmin: r.isAdmin}};
             for (var relative in r.p) {
                 obj.system.periods[relative] = [];
                 for (var i = 0; i < r.p[relative].length; i++) {
@@ -34,10 +34,11 @@
             dataelement_get: 'getDataElementsMinified.action',
             organisationunitchildren_get: 'getOrganisationUnitChildren.action',
             favorite_addorupdate: 'addOrUpdateChart.action',
+            favorite_addorupdatesystem: 'addOrUpdateSystemChart.action',            
             favorite_get: 'charts/',
-            favorite_getall: 'charts.json?links=false',
+            favorite_getall: 'charts.json?paging=false&links=false',
             favorite_delete: 'deleteCharts.action'
-        },        
+        },
         dimension: {
             data: {
                 value: 'data',
@@ -705,9 +706,10 @@
                         var store = DV.store.favorite;
                         params.uid = store.getAt(store.findExact('name', params.name)).data.id;
                     }
+                    var url = DV.cmp.favorite.system.getValue() ? DV.conf.finals.ajax.favorite_addorupdatesystem : DV.conf.finals.ajax.favorite_addorupdate;
                     
                     Ext.Ajax.request({
-                        url: DV.conf.finals.ajax.path_visualizer + DV.conf.finals.ajax.favorite_addorupdate,
+                        url: DV.conf.finals.ajax.path_visualizer + url,
                         params: params,
                         success: function() {
                             DV.store.favorite.load({callback: function() {
@@ -2591,6 +2593,18 @@
                                                                     height: 24
                                                                 },
                                                                 items: [
+                                                                    ' ',
+                                                                    {
+                                                                        xtype: 'checkbox',
+                                                                        boxLabel: 'System',
+                                                                        disabled: !DV.init.system.isAdmin,
+                                                                        disabledCls: 'dv-invisible',
+                                                                        listeners: {
+                                                                            added: function() {
+                                                                                DV.cmp.favorite.system = this;
+                                                                            }
+                                                                        }
+                                                                    },
                                                                     '->',
                                                                     {
                                                                         text: 'Save',
@@ -2607,7 +2621,7 @@
                                                                             var value = DV.cmp.favorite.name.getValue();
                                                                             if (DV.state.isRendered && value) {
                                                                                 if (DV.store.favorite.findExact('name', value) != -1) {
-                                                                                    var item = value.length > 35 ? (value.substr(0,35) + '...') : value;
+                                                                                    var item = value.length > 40 ? (value.substr(0,40) + '...') : value;
                                                                                     var w = Ext.create('Ext.window.Window', {
                                                                                         title: 'Save favorite',
                                                                                         width: DV.conf.layout.window_confirm_width,

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/style.css'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/style.css	2011-12-19 22:15:46 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/style.css	2011-12-22 13:11:13 +0000
@@ -6,6 +6,11 @@
     font-size: 11px;
 }
 
+/* Disable class invisible */
+.dv-invisible .x-form-item-body {
+    display: none;
+}
+
 /* Combobox empty text */
 .x-form-empty-field, textarea.x-form-empty-field {
     font-size: 20px;
@@ -245,6 +250,15 @@
     font-size: 11px;
 }
 
+/* DV toolbar checkbox */
+.dv-toolbar .x-form-cb-wrap {
+    padding-top: 5px;
+}
+.dv-toolbar .x-form-cb-label-after {
+    margin-left: 3px;
+    color: #333;
+}
+
 /* Button dv-toolbar font size */
 .dv-toolbar * {
     font-size: 11px;

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/jsonInitialize.vm'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/jsonInitialize.vm	2011-12-19 20:20:31 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/jsonInitialize.vm	2011-12-22 12:01:45 +0000
@@ -1,1 +1,1 @@
-{"rn":["$!{rootNode.id}","$!encoder.jsonEncode(${rootNode.name})"],"p":{"lastMonth":[#foreach($p in $lastMonth)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$lastMonth.size()),#end#end],"last12Months":[#foreach($p in $last12Months)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$last12Months.size()),#end#end],"lastQuarter":[#foreach($p in $lastQuarter)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$lastQuarter.size()),#end#end],"last4Quarters":[#foreach($p in $last4Quarters)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$last4Quarters.size()),#end#end],"lastSixMonth":[#foreach($p in $lastSixMonth)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$lastSixMonth.size()),#end#end],"last2SixMonths":[#foreach($p in $last2SixMonths)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$last2SixMonths.size()),#end#end],"thisYear":[#foreach($p in $thisYear)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$thisYear.size()),#end#end],"last5Years":[#foreach($p in $last5Years)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$last5Years.size()),#end#end]}}
\ No newline at end of file
+{"isAdmin":$auth.hasAccess( "dhis-web-visualizer", "addOrUpdateSystemChart" ),"rn":["$!{rootNode.id}","$!encoder.jsonEncode(${rootNode.name})"],"p":{"lastMonth":[#foreach($p in $lastMonth)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$lastMonth.size()),#end#end],"last12Months":[#foreach($p in $last12Months)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$last12Months.size()),#end#end],"lastQuarter":[#foreach($p in $lastQuarter)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$lastQuarter.size()),#end#end],"last4Quarters":[#foreach($p in $last4Quarters)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$last4Quarters.size()),#end#end],"lastSixMonth":[#foreach($p in $lastSixMonth)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$lastSixMonth.size()),#end#end],"last2SixMonths":[#foreach($p in $last2SixMonths)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$last2SixMonths.size()),#end#end],"thisYear":[#foreach($p in $thisYear)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$thisYear.size()),#end#end],"last5Years":[#foreach($p in $last5Years)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$last5Years.size()),#end#end]}}
\ No newline at end of file