You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/01/12 15:11:51 UTC

svn commit: r1230551 - in /archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback: roles.js users.js

Author: olamy
Date: Thu Jan 12 14:11:50 2012
New Revision: 1230551

URL: http://svn.apache.org/viewvc?rev=1230551&view=rev
Log:
add call and bean mapping for ApplicationRoles data

Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js?rev=1230551&r1=1230550&r2=1230551&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js Thu Jan 12 14:11:50 2012
@@ -257,5 +257,44 @@ $(function() {
     $("#role-edit-users-li").addClass("active");
   }
 
+  ApplicationRoles = function(name,description,globalRoles,roleTemplates,resources){
+    //private String name;
+    this.name = name;
+    //private String description;
+    this.description = description;
+    //private Collection<String> globalRoles;
+    this.globalRoles = globalRoles;
+    //private Collection<RoleTemplate> roleTemplates;
+    this.roleTemplates = roleTemplates;
+    //private Collection<String> resources;
+    this.resources = resources;
+  }
+
+  mapApplicationRoles=function(data){
+    var roleTemplates = data.roleTemplates ? $.isArray(data.roleTemplates) ? $.map(data.roleTemplates, function(item) {
+      return mapRoleTemplate(item);
+    }):new Array(mapRoleTemplate(data.roleTemplates)):null;
+
+    return new ApplicationRoles(data.name,data.description,mapStringArray(data.globalRoles),roleTemplates,mapStringArray(data.resources));
+  }
+
+  RoleTemplate = function(id,namePrefix,delimiter,description,resource,roles){
+    //private String id;
+    this.id = id;
+    //private String namePrefix;
+    this.namePrefix = namePrefix;
+    //private String delimiter = " - ";
+    this.delimiter = delimiter;
+    //private String description;
+    this.description = description;
+    //private String resource;
+    this.resource = resource;
+    //private List<String> roles;
+    this.roles = roles;
+  }
+
+  mapRoleTemplate = function(data){
+    return new RoleTemplate(data.id,data.namePrefix,data.delimiter,data.description,mapStringArray(data.roles));
+  }
 
 });
\ No newline at end of file

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js?rev=1230551&r1=1230550&r2=1230551&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js Thu Jan 12 14:11:50 2012
@@ -159,7 +159,6 @@ $(function() {
           async: false,
           dataType: 'json',
           success: function(data) {
-            //$("#user-edit-roles-view").show();
             var mappedRoles = $.map(data.role, function(item) {
               return mapRole(item);
             });
@@ -168,6 +167,14 @@ $(function() {
             ko.applyBindings(viewModel,$("#user-edit-roles-view").get(0));
             $("#main-content #edit_user_details_pills_headers").pills();
 
+            $("#main-content #edit_user_details_pills_headers").bind('change', function (e) {
+              //$.log( $(e.target).attr("href") ); // activated tab
+              //e.relatedTarget // previous tab
+              if ($(e.target).attr("href")=="#user-edit-roles-edit") {
+                editUserRoles(user);
+              }
+            })
+
           }
         }
       );
@@ -175,6 +182,21 @@ $(function() {
     }
   }
 
+  editUserRoles=function(user){
+    $.log("editUserRoles:"+user.username());
+    $("#user-edit-roles-edit").html(smallSpinnerImg());
+    $.ajax("restServices/redbackServices/roleManagementService/getApplicationRoles/"+encodeURIComponent(user.username()), {
+        type: "GET",
+        async: false,
+        dataType: 'json',
+        success: function(data) {
+          $("#user-edit-roles-edit").html("loaded");
+
+        }
+      }
+    );
+  }
+
   UserViewModel=function(user) {
     this.user=user;
     this.roles = ko.observableArray(new Array());