Institution: message when update succeed or fails using rest
authorLoic Baron <loic.baron@lip6.fr>
Mon, 19 May 2014 09:48:57 +0000 (11:48 +0200)
committerLoic Baron <loic.baron@lip6.fr>
Mon, 19 May 2014 09:48:57 +0000 (11:48 +0200)
portal/static/js/institution.js
portal/templates/institution.html
portal/templates/onelab/onelab_institution.html

index 5595b3e..173021f 100644 (file)
@@ -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);
                     }
                 });
                 
index 4ec49ca..a127595 100644 (file)
@@ -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 = [];
                 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);
                                 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 %}
index 0a424fa..409c13f 100644 (file)
@@ -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 = [];
                 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);
         });
                
                
-         $.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 %}