X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fstatic%2Fjs%2Fmyslice-ui.js;h=ef95e465fd6b0a04272093377b5cf3a556e505c7;hb=06bb8f5589ce25cbf4b3215367105ddf6cd3fa57;hp=9522a94d0fcd865b672b7e9caac8410c1c258e82;hpb=2a609a565beff7c90ff6f0118285ee4995c9d6f6;p=unfold.git diff --git a/portal/static/js/myslice-ui.js b/portal/static/js/myslice-ui.js index 9522a94d..ef95e465 100644 --- a/portal/static/js/myslice-ui.js +++ b/portal/static/js/myslice-ui.js @@ -4,38 +4,27 @@ $(document).ready(function() { var platformParameters = {}; - var oTable = $("#objectList"); - $.get("/rest/platform", function(data) { - var list = '
Testbeds
'; - for(i=0; i'+data[i].platform_longname+'

'+data[i].platform+'

'; - } - $('#select-platform').html(list); - }).done(function() { - // $('a.sl-platfrom').click(function() { - // console.log($(this).data('platform')); - // platformParameters = { "platform" : $(this).data('platform') }; - // $('a.sl-platfrom').removeClass('active'); - // $(this).addClass('active'); -// - // oTable.load("/list/resource", platformParameters, function(data) { - // oTable.fnDraw(); - // }); -// - // $('body').data('filters',platformParameters); - // }); - }); + /* Testbeds list */ - $('div#testbed-list').ready(function() { - $('table#testbedList').load("/table/network/",{'fields' : ['platform'], 'options': ['checkbox']}, function() { - - }); + $("table#testbedList").load("/table/network/", { "fields" : ["network_hrn","description"], "options": ["checkbox"] }, function() { + $(this).dataTable( { + "sScrollY": window.innerHeight - 275, + "sDom": "frtiS", + "bScrollCollapse": true, + "bStateSave": true, + "bPaginate": false, + "bLengthChange": false, + "bFilter": false, + "bSort": true, + "bInfo": false, + "bAutoWidth": true, + "bAutoHeight": false + } ); }); - //{'columns' : ['hostname','country','type'], 'filters' : { 'country' : 'France' } } - oTable.load("/table/resource/", {'fields' : ['hostname','hrn','country','type'], 'options': ['checkbox'] }, function(data) { + $("#objectList").load("/table/resource/", {"fields" : ["hostname","hrn","country","type"], "options": ["checkbox"] }, function(data) { $(this).dataTable( { "sScrollY": window.innerHeight - 275, "sDom": "frtiS", @@ -47,14 +36,47 @@ $(document).ready(function() { "bSort": true, "bInfo": false, "bAutoWidth": true, - "bAutoHeight": false + "bAutoHeight": false, + "fnInitComplete": function(oSettings, json) { + for(var i = 0; i < myslice.pending.length; i++) { + 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(); + } + } + } } ); + + + $("input[type=checkbox]").click(function() { + var cnt = 0; + var id = $(this).val(); + var row = $(this).parent().parent() + if (row.hasClass("active")) { + 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(); + } + } + }); }); -} ); - -function drawTable(data) { -} + +}); //http://stackoverflow.com/questions/5100539/django-csrf-check-failing-with-an-ajax-post-request //make sure to expose csrf in our outcoming ajax/post requests