93e6866d5248ebe5939bc9ee7d4e4d33335b4634
[unfold.git] / portal / static / js / onelab_slice-resource-view.js
1 $(document).ready(function() {
2     $('li#GoogleMap').click(function (e) {
3         $('.'+this.id).trigger('show');
4     });
5
6     $('a.sl-platform').click(function (e) {
7         $('.'+this.id).trigger('show');
8     });
9
10
11         $('ul.nav-resources a').click(function() {
12         $('ul.nav-resources li').removeClass('active');
13         $(this).parent().addClass('active');
14         $('div.panel').hide();
15         $('div#'+$(this).data('panel')).show();
16         /*
17         if ($(this).data('panel') == 'map') {
18                 mapInit();
19         }
20         */
21     });
22     
23     $.get("/rest/network", function(data) {
24                 var list = '<div class="list-group-item sl-platform"><span class="list-group-item-heading">Testbeds</span></div>';
25                 for(i=0; i<data.length;i++) {
26                         list += '<a href="#" class="list-group-item sl-platform" data-platform="'+data[i].network_hrn+'"><span class="list-group-item-heading">'+data[i].network_longname+'</span><p class="list-group-item-text">'+data[i].network_hrn+'</p></a>';
27                 }
28                 $('#select-platform').html(list);
29         }).done(function() {
30                 
31         });
32         
33         $('button#ApplyPendind').click(function() {
34                 myslice.apply();
35                 // $.each(myslice.pending, function(k, p) {
36                         // console.log(p);
37                 // });
38                 // $.post("/update/slice", {}, function() {
39 //                      
40                 // });
41         });
42         
43    //google.maps.event.addDomListener(window, 'load', initialize);
44 });
45
46 function mapInit() {
47         
48     $.get("/rest/resource/", {"fields" : ["hostname","latitude","longitude"] }, function(data) {
49         
50                 var mapOptions = {
51               center: new google.maps.LatLng(48.8567, 2.3508),
52               zoom: 4,
53               scrollwheel: false
54             };
55             var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
56                  marker = new google.maps.Marker({
57                         position: new google.maps.LatLng(48.8567, 2.3508),
58                         map: map,
59                         icon: '/static/img/marker2.png'
60                     });
61                 
62                 for (i = 0; i < data.length; i++) {  
63                         if (!data[i].longitude) continue;
64                     marker = new google.maps.Marker({
65                         position: new google.maps.LatLng(data[i].latitude, data[i].longitude),
66                         map: map
67                     });
68                         var infowindow = new google.maps.InfoWindow();
69
70                         google.maps.event.addListener(marker, 'click', (function(marker, i) {
71                         return function() {
72                           infowindow.setContent(data[i].hostname);
73                           infowindow.open(map, marker);
74                         };
75                 })(marker, i));
76             }
77           });
78 }