From: Loic Baron <loic.baron@lip6.fr> Date: Mon, 19 May 2014 09:48:57 +0000 (+0200) Subject: Institution: message when update succeed or fails using rest X-Git-Tag: myslice-1.1~101 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=f7750e08d78ebb75b222baf901853370cd7ffff5;p=unfold.git Institution: message when update succeed or fails using rest --- diff --git a/portal/static/js/institution.js b/portal/static/js/institution.js index 5595b3e0..173021f9 100644 --- a/portal/static/js/institution.js +++ b/portal/static/js/institution.js @@ -16,6 +16,24 @@ $(document).ready(function() { }); + $('button#deleteusers').click(function() { + $('input:checkbox.user').each(function (index) { + if(this.checked){ + var record_id = this.id; + $.post("/delete/user/",{'filters':{'user_hrn':this.id}}, function(data) { + if(data.success){ + $('tr[id="'+record_id+'"]').fadeOut("slow"); + $('tr[id="'+record_id+'"]').remove(); + mysliceAlert('Success: user deleted','success', true); + }else{ + mysliceAlert('Rest Error for: '+data.error,'warning', true); + //alert("Rest Error for "+record_id+": "+data.error); + } + }); + } + }); + }); + /* TODO: factorize into functions */ $('button#deleteslices').click(function() { $('input:checkbox.slice').each(function (index) { @@ -25,11 +43,12 @@ $(document).ready(function() { if(data.success){ $('tr[id="'+record_id+'"]').fadeOut("slow"); $('tr[id="'+record_id+'"]').remove(); + mysliceAlert('Success: slice deleted','success', true); }else{ - alert("Rest Error for "+record_id+": "+data.error); + mysliceAlert('Rest Error for: '+data.error,'warning', true); + //alert("Rest Error for "+record_id+": "+data.error); } }); - } }); }); @@ -46,8 +65,10 @@ $(document).ready(function() { if(data.success){ // TODO: highlight row after success //$('tr[id="'+record_id+'"]').highlight(); + mysliceAlert('Success: slice renewed','success', true); }else{ - alert("Rest Error for "+record_id+": "+data.error); + mysliceAlert('Rest Error for: '+data.error,'warning', true); + //alert("Rest Error for "+record_id+": "+data.error); } }); diff --git a/portal/templates/institution.html b/portal/templates/institution.html index 4ec49ca2..a1275950 100644 --- a/portal/templates/institution.html +++ b/portal/templates/institution.html @@ -63,7 +63,7 @@ <th>slice_hrn</th> <th>users</th> <th>url</th> - <th>nodes</th> + <!-- <th>nodes</th> --> <th>expiration</th> </tr> </table> @@ -78,9 +78,9 @@ </div> </div> <script> - $(document).ready(function() { - {% if person %} - {% if user_details.parent_authority %} +$(document).ready(function() { + {% if person %} + {% if user_details.parent_authority %} $.post("/rest/authority/",{'filters':{'authority_hrn':'{{user_details.parent_authority}}'}}, function( data ) { var authority_data = []; @@ -127,7 +127,7 @@ slice_row += "<td><a href=\"/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></td>"; slice_row += "<td>"+users_length+"</td>"; slice_row += "<td>"+slice_url+"</td>"; - slice_row += "<td>"+nodes_length+"</td>"; + //slice_row += "<td>"+nodes_length+"</td>"; slice_row += "<td>"+val.slice_expires+"</td>"; slice_row += "</tr>"; table_slices.push(slice_row); @@ -158,34 +158,15 @@ user_row += "<td>"+val.user_enabled+"</td>"; user_row += "</tr>"; table_users.push(user_row); -// }); $("table#user-tab tr:last").after(table_users.join( "" )); $("div#user-tab-loaded").css("display","block"); $("div#user-tab-loading").css("display","none"); }); - $('button#deleteusers').click(function() { - $('input:checkbox.user').each(function (index) { - if(this.checked){ - var record_id = this.id; - $.post("/delete/user/",{'filters':{'user_hrn':this.id}}, function(data) { - if(data.success){ - $('tr[id="'+record_id+'"]').fadeOut("slow"); - $('tr[id="'+record_id+'"]').remove(); - }else{ - alert("Rest Error for "+record_id+": "+data.error); - } - }); - } - }); - }); - - {% endif %} {% endif %} -}); - +}); // end document.ready </script> {% endblock %} diff --git a/portal/templates/onelab/onelab_institution.html b/portal/templates/onelab/onelab_institution.html index 0a424fab..409c13f3 100644 --- a/portal/templates/onelab/onelab_institution.html +++ b/portal/templates/onelab/onelab_institution.html @@ -67,7 +67,7 @@ <th>slice_hrn</th> <th>users</th> <th>url</th> - <th>nodes</th> + <!-- <th>nodes</th> --> <th>expiration</th> </tr> </table> @@ -82,9 +82,9 @@ </div> </div> <script> - $(document).ready(function() { - {% if person %} - {% if user_details.parent_authority %} +$(document).ready(function() { + {% if person %} + {% if user_details.parent_authority %} $.post("/rest/authority/",{'filters':{'authority_hrn':'{{user_details.parent_authority}}'}}, function( data ) { var authority_data = []; @@ -171,7 +171,7 @@ slice_row += "<td><a href=\"/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></td>"; slice_row += "<td>"+users_length+"</td>"; slice_row += "<td>"+slice_url+"</td>"; - slice_row += "<td>"+nodes_length+"</td>"; + //slice_row += "<td>"+nodes_length+"</td>"; slice_row += "<td>"+val.slice_expires+"</td>"; slice_row += "</tr>"; table_slices.push(slice_row); @@ -185,50 +185,33 @@ }); - $.post("/rest/user/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) { - var list_users = []; - var table_users = []; - /* Available fields - user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name, - user_urn, user_last_name, user_phone, user_hrn, user_email, user_type - */ - $.each( data, function( key, val ) { - list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" ); - user_row = "<tr id='"+val.user_hrn+"'>"; - user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"'></td>"; - user_row += "<td>"+val.user_email+"</td>"; - user_row += "<td>"+val.user_hrn+"</td>"; - user_row += "<td>"+val.user_first_name+"</td>"; - user_row += "<td>"+val.user_last_name+"</td>"; - user_row += "<td>"+val.user_enabled+"</td>"; - user_row += "</tr>"; - table_users.push(user_row); -// - }); - $("table#user-tab tr:last").after(table_users.join( "" )); - $("div#user-tab-loaded").css("display","block"); - $("div#user-tab-loading").css("display","none"); - }); - - $('button#deleteusers').click(function() { - $('input:checkbox.user').each(function (index) { - if(this.checked){ - var record_id = this.id; - $.post("/delete/user/",{'filters':{'user_hrn':this.id}}, function(data) { - if(data.success){ - $('tr[id="'+record_id+'"]').fadeOut("slow"); - $('tr[id="'+record_id+'"]').remove(); - }else{ - alert("Rest Error for "+record_id+": "+data.error); - } - }); - } - }); - }); - {% endif %} - {% endif %} -}); + $.post("/rest/user/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) { + var list_users = []; + var table_users = []; + /* Available fields + user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name, + user_urn, user_last_name, user_phone, user_hrn, user_email, user_type + */ + $.each( data, function( key, val ) { + list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" ); + user_row = "<tr id='"+val.user_hrn+"'>"; + user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"'></td>"; + user_row += "<td>"+val.user_email+"</td>"; + user_row += "<td>"+val.user_hrn+"</td>"; + user_row += "<td>"+val.user_first_name+"</td>"; + user_row += "<td>"+val.user_last_name+"</td>"; + user_row += "<td>"+val.user_enabled+"</td>"; + user_row += "</tr>"; + table_users.push(user_row); + }); + $("table#user-tab tr:last").after(table_users.join( "" )); + $("div#user-tab-loaded").css("display","block"); + $("div#user-tab-loading").css("display","none"); + }); + {% endif %} + {% endif %} +}); // End document.ready </script> {% endblock %}