major updates to slice reservation page and plugins
[myslice.git] / portal / static / js / myslice-ui.js
index 4437941..de2ac74 100644 (file)
@@ -1,26 +1,29 @@
 
+/*
+ * Call it with level: success, info, warning, danger
+ */
+function mysliceAlert(msg, level, timeout) {
+       level = typeof level !== 'undefined' ? level : 'success';
+       timeout = typeof timeout !== 'undefined' ? timeout : false;
+       var el = $('#myslice-message');
+       el.find('.message').text(msg);
+       el.addClass('alert-' + level);
+       el.parent().fadeIn('fast');
+       if (timeout) {
+               setTimeout(function(){el.alert('close');},5000);
+       }
+};
 /* Table initialisation */
 $(document).ready(function() {
        
        var platformParameters = {};
        
-               
-       $.get("/rest/platform", function(data) {
-               var list = '<div class="list-group-item sl-platfrom"><span class="list-group-item-heading">Testbeds</span></div>';
-               for(i=0; i<data.length;i++) {
-                       list += '<a href="#" class="list-group-item sl-platfrom" data-platform="'+data[i].platform+'"><span class="list-group-item-heading">'+data[i].platform_longname+'</span><p class="list-group-item-text">'+data[i].platform+'</p></a>';
-               }
-               $('#select-platform').html(list);
-       }).done(function() {
-               
+       $('#myslice-message').bind('closed.bs.alert', function () {
+               $(this).parent().hide();
        });
+
+       //mysliceAlert('hello','danger');
        
-       /* Testbeds list */
-       $("div#testbed-list").ready(function() {
-               $("table#testbedList").load("/table/network/", { "fields" : ["network_hrn","description"], "options": ["checkbox"] }, function() {
-                       
-               });
-       });
        
        $("#objectList").load("/table/resource/", {"fields" : ["hostname","hrn","country","type"], "options": ["checkbox"] }, function(data) {
                $(this).dataTable( {
@@ -37,7 +40,15 @@ $(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);
+                    /*
+                                       if (myslice.count() > 0) {
+                                               $('#badge-pending').text(myslice.count());
+                                               $('#badge-pending').show();
+                                       }
+                    */
                                }
                    }
                } );
@@ -51,18 +62,20 @@ $(document).ready(function() {
                                row.removeClass("active");
                                myslice.del(id);
                                cnt = myslice.count();
+                /*
                                $('#badge-pending').text(cnt);
                                if (cnt <= 0) {
                                        $('#badge-pending').hide();
-                               }
+                               }*/
                        } else {
                                row.addClass("active");
                                myslice.add(id);
+                /*
                                cnt = myslice.count();
                                $('#badge-pending').text(cnt);
                                if (cnt > 0) {
                                        $('#badge-pending').show();
-                               }
+                               }*/
                        }
                });
        });