1 <script type="text/javascript" src="{{STATIC_URL}}/js/jquery-ui.js"></script>
2 <script type="text/javascript" src="{{STATIC_URL}}/js/jquery.qtip.min.js"></script>
3 <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/jquery.qtip.min.css">
4 <link rel="stylesheet" href="{{ STATIC_URL }}css/jquery-ui.css">
6 function get_users_in_slice(authority_hrn){
7 console.log(authority_hrn);
8 $("table#user-tab").html("<tr><th>+/-</th><th>Email</th><th>User hrn</th></tr>");
10 $.post("/rest/user/",{'filters':{'parent_authority': authority_hrn}}, function( data ) {
14 user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
15 user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
17 $.each( data, function( key, val ) {
18 list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
20 // checking the box for the users that belong to the selected slice
21 var flag_checkbox = 0;
22 for(var data in val.slices) {
23 var element = val.slices[data];
24 if (element == "{{slice}}"){
25 //console.log("the slice is: "+ element);
27 slice_users.push (val.user_hrn)
28 user_row += "<td><input type='checkbox' checked='True' class='user'></td>";
31 if(flag_checkbox != 1){
32 user_row += "<td><input type='checkbox' class='user'></td>";
34 user_row += "<td>"+val.user_email+"</td>";
35 user_row += "<td>"+val.user_hrn+"</td>";
36 //user_row += "<td>"+val.user_enabled+"</td>";
38 table_users.push(user_row);
41 $("table#user-tab tr:first").after(table_users.join( "" ));
42 $("div#user-tab-loaded").css("display","block");
43 $("div#user-tab-loading").css("display","none");
44 $("input:checkbox.user").click(function() {
45 user_hrn = $(this).closest('tr').find('td:eq(2)').html();
47 var record_id = this.id;
48 slice_users.push (user_hrn);
50 console.log(slice_users);
56 $(document).ready(function() {
57 // TODO: Add a filter based on the list of authorities
58 $.post("/rest/authority/",{'fields':['authority_hrn']}, function( data ) {
59 var list_authorities = [];
60 $.each( data, function( key, val ) {
61 auth_hrn = val.authority_hrn;
62 // Keep only the sub authorities, remove root auth
63 if(auth_hrn.indexOf(".") > -1){
64 list_authorities.push(auth_hrn);
65 list_authorities.sort();
66 if(auth_hrn=="{{user_details.parent_authority}}"){
67 $('#auth_list').val(auth_hrn);
71 $( "#auth_list" ).autocomplete({
72 source: list_authorities,
74 change: function (event, ui) {
75 get_users_in_slice(this.value);
77 //http://api.jqueryui.com/autocomplete/#event-change -
78 //The item selected from the menu, if any. Otherwise the property is null
79 //so clear the item for force selection
80 jQuery("#auth_list").val("");
81 alert("Please select an authority from the given list.")
84 //select: function( event, ui ) {console.log(jQuery(this))}
86 }); // post rest/authority
88 get_users_in_slice("{{user_details.parent_authority}}");
90 $('button#addusers').click(function() {
91 $.post("/update/slice/",{'filters':{'slice_hrn':'{{slice}}'},'params':{'users':slice_users}}, function(data) {
93 // TODO: highlight row after success
94 //$('tr[id="'+record_id+'"]').highlight();
95 mysliceAlert('Success: slice updated','success', true);
97 mysliceAlert('Rest Error for: '+data.error,'warning', true);
99 }); // post update slice
101 // TODO: refresh table
102 //window.location="/portal/institution#slices";
104 }); // button#addusers click
105 $('[title!=""]').qtip();
106 }); // document ready
109 <div class="col-md-2">
110 <div id="select-platform" class="list-group">
113 <ul class="list-group">
114 <li class="list-group-item">Authority</li>
115 <li class="list-group-item" style="padding-left:5px;">
116 <input type="text" id="auth_list" style ="min-width:190px;"
117 title="The default value is the authority that you belong to and the selected users belong to this slice.
118 You can view users of other authorities (organizations) from the list that apears when you click in the field and start to type.
119 Use the arrow keys to scroll through the list; type part of the name to narrow down the list."/>
124 <div class="col-md-10">
127 <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Useres" /></div>
128 <div id="user-tab-loaded" style="display:none;">
129 <table id="user-tab" class="table">
132 <!-- XXX TODO: for the moment only PIs have access to Update but users that have slice credentials should also have access to that -->
134 {% if 'is_pi' in pi %}
135 <button id="addusers" type="button" class="btn btn-default"><span class="glyphicon glyphicon-ok"></span> Update users</button>