← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9223: FRED-API: latlng fix in GeoUtils. Also added a basic view of core properties in UI.

 

------------------------------------------------------------
revno: 9223
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2012-12-08 14:49:49 +0300
message:
  FRED-API: latlng fix in GeoUtils. Also added a basic view of core properties in UI.
modified:
  dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/GeoUtils.java
  dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facility.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-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/GeoUtils.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/GeoUtils.java	2012-12-06 20:06:23 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/GeoUtils.java	2012-12-08 11:49:49 +0000
@@ -51,8 +51,8 @@
         {
             List list = new ObjectMapper().readValue( coordinatesString, List.class );
 
-            coordinates.lat = convertToDouble( list.get( 0 ) );
-            coordinates.lng = convertToDouble( list.get( 1 ) );
+            coordinates.lat = convertToDouble( list.get( 1 ) );
+            coordinates.lng = convertToDouble( list.get( 0 ) );
         }
         catch ( Exception ignored )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facility.vm'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facility.vm	2012-12-06 20:06:23 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facility.vm	2012-12-08 11:49:49 +0000
@@ -1,1 +1,66 @@
-FACILITY
\ No newline at end of file
+<script src="http://maps.google.com/maps/api/js?sensor=false";></script>
+
+<script>
+    $(function () {
+        var coordinates = JSON.parse("$entity.coordinates");
+
+        if (coordinates.length > 0) {
+            $('#facilityLatitude').val(coordinates[0]);
+            $('#facilityLongitude').val(coordinates[1]);
+
+            var latlng = new google.maps.LatLng(coordinates[0], coordinates[1]);
+
+            var options = {
+                zoom: 12,
+                center: latlng,
+                mapTypeId: google.maps.MapTypeId.HYBRID
+            };
+
+            var map = new google.maps.Map(document.getElementById("mapTarget"), options);
+
+            var marker = new google.maps.Marker({
+                position: latlng,
+                map: map,
+                title: "$entity.name"
+            });
+        }
+    });
+</script>
+
+<div class="container-fluid">
+    <div class="span4">
+        <div style="height: 320px;" id="mapTarget" class="img-polaroid"></div>
+    </div>
+
+    <div class="span4">
+        <form id="facilityForm">
+            #set( $inputSize = "span12")
+
+            <fieldset>
+                <legend>Facility</legend>
+
+                <label for="facilityID">ID</label>
+                <input id="facilityID" disabled="disabled" type="text" class="$inputSize" value="$entity.id"/>
+
+                <label for="facilityName">Name</label>
+                <input #if(true)disabled#end id="facilityName" type="text" class="$inputSize" value="$entity.name"/>
+
+                <label for="facilityActive">Active</label>
+
+                <select id="facilityActive" #if(true)disabled#end class="$inputSize">
+                    <option value="true" #if($entity.active)selected#end>Yes</option>
+                    <option value="false" #if(!$entity.active)selected#end>No</option>
+                </select>
+
+                <label for="facilityLatitude">Latitude</label>
+                <input #if(true)disabled#end id="facilityLatitude" type="text" class="$inputSize" value=""/>
+
+                <label for="facilityLongitude">Longitude</label>
+                <input #if(true)disabled#end id="facilityLongitude" type="text" class="$inputSize" value=""/>
+            </fieldset>
+
+            <button #if(true)disabled#end type="submit" class="btn btn-info">Update</button>
+        </form>
+    </div>
+</div>
+