← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 75: Legend combo bug fixed. Config code style improved. Gridpanel colors implemented.

 

------------------------------------------------------------
revno: 75
committer: Jan Henrik Overland janhenrik.overland@xxxxxxxxx
branch nick: trunk
timestamp: Tue 2009-03-17 17:09:40 +0530
message:
  Legend combo bug fixed. Config code style improved. Gridpanel colors implemented.
modified:
  gis/dhis-gis-geostat/demos/geostat/config.js
  gis/dhis-gis-geostat/demos/geostat/geostat.js
  gis/dhis-gis-geostat/demos/geostat/index.html
  gis/dhis-gis-geostat/mfbase/mapfish/widgets/geostat/Choropleth.js

=== modified file 'gis/dhis-gis-geostat/demos/geostat/config.js'
--- gis/dhis-gis-geostat/demos/geostat/config.js	2009-03-16 06:59:29 +0000
+++ gis/dhis-gis-geostat/demos/geostat/config.js	2009-03-17 11:39:40 +0000
@@ -3,31 +3,31 @@
 
 
 // SHAPE FILES
-empty = '';
-level_1 = '../../../geoserver/wfs?request=GetFeature&typename=who:admin1&outputformat=json&version=1.0.0'; // provinces
-level_2 = '../../../geoserver/wfs?request=GetFeature&typename=who:admin2&outputformat=json&version=1.0.0'; // districts
-level_3 = '../../../geoserver/wfs?request=GetFeature&typename=who:admin3&outputformat=json&version=1.0.0'; // chiefdoms
+hidden = '../../../geoserver/wfs?request=GetFeature&typename=who:india_st&outputformat=json&version=1.0.0'; // init widget map. not visible. should be as light as possible
+level_1 = '../../../geoserver/wfs?request=GetFeature&typename=who:india_st&outputformat=json&version=1.0.0'; // provinces
+level_2 = '../../../geoserver/wfs?request=GetFeature&typename=who:india_st&outputformat=json&version=1.0.0'; // districts
+level_3 = '../../../geoserver/wfs?request=GetFeature&typename=who:india_ds&outputformat=json&version=1.0.0'; // chiefdoms
 
-shapefiles = new Array(empty, level_1, level_2, level_3);
+shapefiles = new Array(hidden, level_1, level_2, level_3);
 
 shpcols = {
 
-    1: [ { type: "Province", // What kind of orgunit. Displayed in the info box.
-           name: "NAME", // Shapefile column holding the name of the orgunit. Displayed in the info box.
-           geocode: "NAME", // Shapefile column holding a unique value
+    1: [ { type: "Territory", // What kind of orgunit. Displayed in the info box.
+           name: "STATE", // Shapefile column holding the name of the orgunit. Displayed in the info box.
+           geocode: "", // Shapefile column holding a unique value
            value: "value" } ], // Must be set to "value"
     
-    2: [ { type: "District",
-           name: "NAME",
-           geocode: "NAME",
+    2: [ { type: "State",
+           name: "STATE",
+           geocode: "STATE",
            value: "value", // Must be set to "value"
-           parent1: "ADM1_NAME" } ], // Shapefile column holding the name of the parent orgunit (1 level above)
+           parent1: "STATE" } ], // Shapefile column holding the name of the parent orgunit (1 level above)
            
-    3: [ { type: "Chiefdom",
-           name: "CHIEFDOM",
-           geocode: "CHIEFDOM",
+    3: [ { type: "District",
+           name: "DISTRICT",
+           geocode: "DISTRICT",
            value: "value", // Must be set to "value"
-           parent1: "DISTRICT", // Shapefile column holding the name of the parent orgunit (1 level above)
+           parent1: "STATE", // Shapefile column holding the name of the parent orgunit (1 level above)
            parent2: "PROVINCE" } ], // (2 levels above)
            
     4: [ { type: "Org. unit",
@@ -41,6 +41,12 @@
 
 pointLayer = 4; // the shpcols point layer number
 
+init_map = 'who:india_st';
+init_longitude = 82;
+init_latitude = 22;
+init_zoom = 5;
+
+
 
 // LAYER NAMES
 choroplethLayerName = "Choropleth";
@@ -49,7 +55,8 @@
 
 // LAYOUT
 west_width = 270; // viewport west
-south_height = 100; // viewport south
+north_height = 0;
+south_height = 80; // viewport south
 
 gridpanel_width = 255;
 combo_width = 150;
\ No newline at end of file

=== modified file 'gis/dhis-gis-geostat/demos/geostat/geostat.js'
--- gis/dhis-gis-geostat/demos/geostat/geostat.js	2009-03-16 08:26:47 +0000
+++ gis/dhis-gis-geostat/demos/geostat/geostat.js	2009-03-17 11:39:40 +0000
@@ -19,7 +19,7 @@
                                      
     var vmap0 = new OpenLayers.Layer.WMS("OpenLayers WMS",
                                          "../../../geoserver/wms?", 
-                                         {layers: 'who:sl_init'});
+                                         {layers: init_map}); // config.js
                                    
     // define choropleth layer and its styling
     var choroplethLayer = new OpenLayers.Layer.Vector(choroplethLayerName, {
@@ -73,7 +73,7 @@
     selectFeatureChoropleth.activate();
     selectFeaturePoint.activate();
 
-    map.setCenter(new OpenLayers.LonLat(-11.8, 8.5), 8);
+    map.setCenter(new OpenLayers.LonLat(init_longitude, init_latitude), init_zoom); // config.js
 
 
     // create choropleth widget
@@ -149,7 +149,7 @@
                 // raw
                 region: 'north',
                 el: 'north',
-                height: 32
+                height: north_height
             }),
             
             {
@@ -158,8 +158,8 @@
                 id: 'south-panel',
                 split: true,
                 height: south_height,
-                minSize: 100,
-                maxSize: 100,
+                minSize: 50,
+                maxSize: 200,
                 collapsible: true,
                 title: 'Information',
                 margins: '0 0 0 0',
@@ -264,7 +264,7 @@
     var y = south_panel.y - height - padding_y;
 
     popup_feature = new Ext.Window({
-    title: 'Feature',
+    title: 'Area',
     width: 190,
     height: height,
     layout: 'fit',
@@ -318,12 +318,14 @@
 {
     var selected = Ext.getCmp('grid_gp').getSelectionModel().getSelected();
     organisationUnitId = selected.data["id"],
-    geoCode = feature.attributes["NAME"];
+    geoCode = feature.attributes[ shpcols[choropleth.selectedLevel][0].name ];
 
-    if (!selected) {
+    if (!selected)
+    {
         alert("ikke valgt");
     }
-    else {
+    else
+    {
         Ext.Ajax.request( 
         {
             url: 'http://localhost:' + localhost_port + '/dhis-webservice/updateOrganisationUnitGeoCode.service',
@@ -340,6 +342,8 @@
             } 
         });
     }
+    
+    choropleth.gridStore.reload();
 
     popup_feature.hide();
 
@@ -426,6 +430,8 @@
     var indicatorId = Ext.getCmp('indicator_cb').getValue();
     var periodId = Ext.getCmp('period_cb').getValue();
     var level = Ext.getCmp('level_cb').getValue();
+    
+alert(    indicatorId + "\n" + periodId + "\n" + level);
 
     var url = 'http://localhost:' + localhost_port + '/dhis-webservice/getMapValues.service';
     format = 'json';
@@ -500,15 +506,17 @@
     var featuresLength = features.length;
     var data = Ext.util.JSON.decode(responseText);
     var dataLength = data.mapvalues.length;
+    
+alert(featuresLength + "\n" + dataLength);    
 
-    for ( var j=0; j < featuresLength; j++ ) 
+    for (var j=0; j < featuresLength; j++) 
     {
         features[j].attributes["value"] = 0;
-
-        for ( var i=0; i < dataLength; i++ )
+        
+        for (var i=0; i < dataLength; i++)
         {
             if (features[j].attributes[shpcols[level][0].geocode] == data.mapvalues[i].geoCode)
-            {
+            {   
                 features[j].attributes["value"] = data.mapvalues[i].value;
             }
         }

=== modified file 'gis/dhis-gis-geostat/demos/geostat/index.html'
--- gis/dhis-gis-geostat/demos/geostat/index.html	2009-03-16 08:26:47 +0000
+++ gis/dhis-gis-geostat/demos/geostat/index.html	2009-03-17 11:39:40 +0000
@@ -28,6 +28,10 @@
     <!-- Div script -->
     <script type="text/javascript" src="config.js"></script>
     <script type="text/javascript" src="geostat.js"></script>
+    <style>
+        .assigned-row {background-color: #DBFFDC}
+        .not-assigned-row {background-color: #FFEFD5}
+    </style>
 </head>
 
 <body>
@@ -42,9 +46,7 @@
         </div>
     </div>
     
-    <div id="north" style="padding: 5px">
-        <h1 style="font-size:20px; font-family:tahoma; color:#555555">DHIS2 Geostat</h1>
-    </div>
+    <div id="north" style="padding: 5px"></div>
     
     <div id="olmap"></div>
     

=== modified file 'gis/dhis-gis-geostat/mfbase/mapfish/widgets/geostat/Choropleth.js'
--- gis/dhis-gis-geostat/mfbase/mapfish/widgets/geostat/Choropleth.js	2009-03-16 06:59:29 +0000
+++ gis/dhis-gis-geostat/mfbase/mapfish/widgets/geostat/Choropleth.js	2009-03-17 11:39:40 +0000
@@ -137,7 +137,7 @@
      *    Inits the component
      */
      
-    selectedLevel : false,
+    selectedLevel : 1,
      
     isDrillDown : false,
     
@@ -145,6 +145,9 @@
     
     selectedValue : false,
     
+    gridPanelTitle : '',
+    
+    
     initComponent : function() {
     
     
@@ -191,27 +194,40 @@
             
         legendStore = new Ext.data.JsonStore({
               url: 'http://localhost:' + localhost_port + '/dhis-webservice/getLegendMinAndMaxOfIndicator.service',
-              baseParams: { indicatorId: '52460', format: 'json' },
               root: 'legendSet',
               fields: ['id', 'name'],
               autoLoad: false
             });
             
-        panelStore = new Ext.data.JsonStore({
-            url: 'http://localhost:' + localhost_port + '/dhis-webservice/getOrganisationUnitsAtLevel.service',
-            baseParams: { level: 2, format: 'json' },
-            root: 'organisationUnit',
-            fields: ['id', 'name'],
-            autoLoad: true
-        });
-        
         gridStore = new Ext.data.JsonStore({
             url: 'http://localhost:' + localhost_port + '/dhis-webservice/getOrganisationUnitsAtLevel.service',
+            baseParams: { level: this.selectedLevel, format: 'json' },
             root: 'organisationUnits',
-            fields: ['id', 'name'],
+            fields: ['id', 'name', 'geoCode'],
             autoLoad: false
         });
-        
+
+        
+        gridView = new Ext.grid.GridView({ 
+            forceFit: true, 
+            getRowClass: function (row, index){
+                var cls = ''; 
+                var data = row.data;
+
+                switch (data.geoCode) { 
+                    case '': 
+                        cls = 'not-assigned-row';
+                        break;
+                    default:
+                        cls = 'assigned-row';
+                    }
+                return cls;
+            }
+        });
+        
+        
+
+
         // end DHIS
     
 
@@ -220,6 +236,8 @@
         
             // DHIS
          
+        { html: '<b>Geostat viewer</b><br><br>' },
+        
         {
             xtype: 'combo',
             id: 'indicatorgroup_cb',
@@ -263,8 +281,20 @@
             emptyText: 'Select indicator',
             selectOnFocus: true,
             width: combo_width,
-            store: indicatorStore
+            store: indicatorStore,
+            listeners: {
+                'select': {
+                    fn: function()
+                    {
+                        Ext.getCmp('legend_cb').reset();
+                        var iId = Ext.getCmp('indicator_cb').getValue();
+                        legendStore.baseParams = { indicatorId: iId, format: 'json' };
+                        legendStore.reload();
+                    }
+                }
+            }
         },
+        
         {
             xtype: 'combo',
             id: 'periodtype_cb',
@@ -338,10 +368,10 @@
             }
         },
         
-        {html:'<br>'},
+//        {html:'<br>'},
             
 /*            
-            {
+        {
             xtype: 'combo',
             fieldLabel: 'Method',
             name: 'method',
@@ -358,7 +388,7 @@
                         ['CLASSIFY_BY_QUANTILS', 'Quantils']]
             })
             
-            },
+        },
 */
           
           {
@@ -377,7 +407,9 @@
                 data: [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9]]
             })
             
-            },{
+            },
+            
+            {
        
 
             xtype: 'combo',
@@ -456,7 +488,7 @@
             scope: this
         },
         
-        { html: '<br><hr><br><b>Org. unit assignment</b><br><br>' },
+        { html: '<br><br><b>Assign org. units</b><br><br>' },
         
         {
             xtype: 'combo',
@@ -482,7 +514,7 @@
                         
                         gridStore.baseParams = { level: value, format: 'json' };
                         gridStore.reload();
-
+                        
                         this.classify2(true);
                     },
                     scope: this
@@ -500,18 +532,21 @@
             scope: this
         },
         
-        { html: '<br><br>' },
+        { html: '<br>' },
 
         {
             xtype: 'grid',
             id: 'grid_gp',
+            title: this.gridPanelTitle,
             store: gridStore,
             columns: [
                 { id: 'name', dataIndex: 'name', sortable: true, width: gridpanel_width-2 }
             ],
             autoHeight: true,
             autoScroll: true,
-            width: gridpanel_width
+            height: 100,
+            width: gridpanel_width,
+            view: gridView
         }
         
         ];



--

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.