resources google map
authorCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Tue, 4 Mar 2014 16:01:20 +0000 (17:01 +0100)
committerCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Tue, 4 Mar 2014 16:01:20 +0000 (17:01 +0100)
portal/static/js/myslice-ui.js
portal/static/js/onelab_slice-resource-view.js
portal/templates/onelab/onelab_slice-resource-view.html

index 1f62c47..0003057 100644 (file)
@@ -29,7 +29,9 @@ $(document).ready(function() {
                "bAutoHeight": false,
                "fnInitComplete": function(oSettings, json) {
                                for(var i = 0; i < myslice.pending.length; i++) {
-                                       $('*[data-key="'+myslice.pending[i]+'"]').addClass("active");
+                                       var el = $('*[data-key="'+myslice.pending[i]+'"]');
+                                       el.addClass("active");
+                                       el.find('input[type=checkbox]').prop('checked', true);
                                }
                    }
                } );
index f2bd93d..52850a3 100644 (file)
@@ -4,6 +4,10 @@ $(document).ready(function() {
         $(this).parent().addClass('active');
         $('div.panel').hide();
         $('div#'+$(this).data('panel')).show();
+        
+        if ($(this).data('panel') == 'map') {
+               mapInit();
+        }
     });
     
     $.get("/rest/platform", function(data) {
@@ -16,33 +20,39 @@ $(document).ready(function() {
                
        });
        
+   //google.maps.event.addDomListener(window, 'load', initialize);
+});
+
+function mapInit() {
+       
     $.get("/rest/resource/", {"fields" : ["hostname","latitude","longitude"] }, function(data) {
        
-       var mapOptions = {
-      center: new google.maps.LatLng(48.8567, 2.3508),
-      zoom: 4,
-      scrollwheel: false
-    };
-    var map = new google.maps.Map(document.getElementById("map"), mapOptions);
-        marker = new google.maps.Marker({
-               position: new google.maps.LatLng(48.8567, 2.3508),
-               map: map,
-               icon: '/static/img/marker2.png'
-           });
-       for (i = 0; i < data.length; i++) {  
-               if (!data[i].longitude) continue;
-           marker = new google.maps.Marker({
-               position: new google.maps.LatLng(data[i].latitude, data[i].longitude),
-               map: map
-           });
-       
-           google.maps.event.addListener(marker, 'click', (function(marker, i) {
-               return function() {
-                 infowindow.setContent(data[i].hostname);
-                 infowindow.open(map, marker);
-               };
-       })(marker, i));
-    }
-  });
-   //google.maps.event.addDomListener(window, 'load', initialize);
-});
\ No newline at end of file
+               var mapOptions = {
+             center: new google.maps.LatLng(48.8567, 2.3508),
+             zoom: 4,
+             scrollwheel: false
+           };
+           var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
+                marker = new google.maps.Marker({
+                       position: new google.maps.LatLng(48.8567, 2.3508),
+                       map: map,
+                       icon: '/static/img/marker2.png'
+                   });
+               
+               for (i = 0; i < data.length; i++) {  
+                       if (!data[i].longitude) continue;
+                   marker = new google.maps.Marker({
+                       position: new google.maps.LatLng(data[i].latitude, data[i].longitude),
+                       map: map
+                   });
+                       var infowindow = new google.maps.InfoWindow();
+
+                   google.maps.event.addListener(marker, 'click', (function(marker, i) {
+                       return function() {
+                         infowindow.setContent(data[i].hostname);
+                         infowindow.open(map, marker);
+                       };
+               })(marker, i));
+           }
+         });
+}
index 895e2ed..1fcecf9 100644 (file)
@@ -45,7 +45,9 @@
                        <div id="resources" class="panel">
                                <table cellpadding="0" cellspacing="0" border="0" class="table" id="objectList"></table>
                        </div>
-                       <div id="map" class="panel" style="height:370px;" style="display:none;"></div>
+                       <div id="map" class="panel" style="height:370px;display:none;">
+                               <div id="map-canvas" style="height:100%;"></div>
+                       </div>
                </div>
        </div>
 {% endblock %}
\ No newline at end of file