Clear credentials when granting or revoking PI rights in manage institution page
[myslice.git] / portal / templates / fed4fire / fed4fire_institution.html
index 90da984..626225c 100644 (file)
           </div>
        </div>
        <div class="tab-pane row" id="requests">
+        <div id="spinner" style="padding-top:40px; padding-left:40px;"></div>
        </div>
 </div>
 <script>
 $(document).ready(function() {
     {% if person %}
     {% if user_details.parent_authority %}
-
+        $('#spinner').spin();
+        
         $.post("/rest/myslice:slice/",{'fields':['slice_hrn','users','url','slice_date_created'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
             var list_slices = [];
             var table_slices = [];
@@ -209,7 +211,7 @@ $(document).ready(function() {
             $.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><input type='checkbox' class='user' id='"+val.user_hrn+"' data-email='"+val.user_email+"'></td>";
                 user_row += "<td>"+val.user_email+"</td>";
                 user_row += "<td>"+val.user_hrn+"</td>";
                 /*
@@ -286,6 +288,8 @@ $(document).ready(function() {
                 if(this.checked){
                     var record_id = this.id;
                     pi_users.push(record_id)
+                    $.post("/credentials/clear/",{'emails':[this.dataset['email']]}, function(data) {
+                    }); // post credentials clear
                     flag = true;                
                 }
             });
@@ -316,9 +320,11 @@ $(document).ready(function() {
                                        for (var i=pi_users.length-1; i>=0; i--) {
                                        if (pi_users[i] === record_id) {
                                                pi_users.splice(i, 1);
+                            $.post("/credentials/clear/",{'emails':[this.dataset['email']]}, function(data) {
+                            }); // post credentials clear
+                            flag = true;                
                                        }
                                        }
-                    flag = true;                
                 }
             });
             if(flag == true){
@@ -341,6 +347,8 @@ $(document).ready(function() {
                         //alert("Rest Error for "+record_id+": "+data.error);
                     }
                 });
+            }else{
+                mysliceAlert('No action: User had no rights on: {{user_details.parent_authority}}','success', true);
             }
         });
     });