2 function get_users_in_slice(authority_hrn){
3 console.log(authority_hrn);
4 $("table#user-tab").html("<tr><th>+/-</th><th>Email</th><th>User hrn</th></tr>");
6 $.post("/rest/user/",{'filters':{'parent_authority': authority_hrn}}, function( data ) {
10 user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
11 user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
13 $.each( data, function( key, val ) {
14 list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
16 // checking the box for the users that belong to the selected slice
17 var flag_checkbox = 0;
18 for(var data in val.slices) {
19 var element = val.slices[data];
20 if (element == "{{slice}}"){
21 //console.log("the slice is: "+ element);
23 slice_users.push (val.user_hrn)
24 user_row += "<td><input type='checkbox' checked='True' class='user'></td>";
27 if(flag_checkbox != 1){
28 user_row += "<td><input type='checkbox' class='user'></td>";
30 user_row += "<td>"+val.user_email+"</td>";
31 user_row += "<td>"+val.user_hrn+"</td>";
32 //user_row += "<td>"+val.user_enabled+"</td>";
34 table_users.push(user_row);
37 $("table#user-tab tr:first").after(table_users.join( "" ));
38 $("div#user-tab-loaded").css("display","block");
39 $("div#user-tab-loading").css("display","none");
40 $("input:checkbox.user").click(function() {
41 user_hrn = $(this).closest('tr').find('td:eq(2)').html();
43 var record_id = this.id;
44 slice_users.push (user_hrn);
46 console.log(slice_users);
52 $(document).ready(function() {
53 // TODO: Add a filter based on the list of authorities
54 $.post("/rest/authority/",{'fields':['authority_hrn']}, function( data ) {
55 var list_authorities = [];
56 $.each( data, function( key, val ) {
57 auth_hrn = val.authority_hrn;
58 // Keep only the sub authorities, remove root auth
59 if(auth_hrn.indexOf(".") > -1){
60 list_authorities.push(auth_hrn);
61 if(auth_hrn=="{{user_details.parent_authority}}"){
62 $("#auth_list").append("<option value='"+auth_hrn+"' selected='selected'>"+auth_hrn+"</option>");
64 $("#auth_list").append("<option value='"+auth_hrn+"'>"+auth_hrn+"</option>");
68 }); // post rest/authority
70 get_users_in_slice("{{user_details.parent_authority}}");
72 $('button#addusers').click(function() {
73 $.post("/update/slice/",{'filters':{'slice_hrn':'{{slice}}'},'params':{'users':slice_users}}, function(data) {
75 // TODO: highlight row after success
76 //$('tr[id="'+record_id+'"]').highlight();
77 mysliceAlert('Success: slice updated','success', true);
79 mysliceAlert('Rest Error for: '+data.error,'warning', true);
81 }); // post update slice
83 // TODO: refresh table
84 //window.location="/portal/institution#slices";
86 }); // button#addusers click
91 <div class="col-md-2">
92 <div id="select-platform" class="list-group">
95 <ul class="list-group">
96 <li class="list-group-item">Authority:<b> {{user_details.parent_authority}}</b>
98 <li class="list-group-item" style="padding-left:5px;">
99 <select id="auth_list" onchange="get_users_in_slice(this.value);" style ="min-width:190px;">
105 <div class="col-md-10">
108 <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Useres" /></div>
109 <div id="user-tab-loaded" style="display:none;">
110 <table id="user-tab" class="table">
113 <!-- XXX TODO: for the moment only PIs have access to Update but users that have slice credentials should also have access to that -->
115 {% if 'is_pi' in pi %}
116 <button id="addusers" type="button" class="btn btn-default"><span class="glyphicon glyphicon-ok"></span> Update users</button>