archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1446590 - in /archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js: archiva/general-admin.js templates/archiva/general-admin.html
Date Fri, 15 Feb 2013 14:14:36 GMT
Author: olamy
Date: Fri Feb 15 14:14:35 2013
New Revision: 1446590

URL: http://svn.apache.org/r1446590
Log:
[MRM-1736] map roles to ldap groups
update mapping implemented.

Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js?rev=1446590&r1=1446589&r2=1446590&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js
Fri Feb 15 14:14:35 2013
@@ -1372,6 +1372,8 @@ define("archiva.general-admin",["jquery"
 
     this.usedUserManagerImpls=ko.observableArray([]);
 
+    this.modifiesLdapGroupMappings=ko.observableArray([]);
+
     this.allRoleNames=[];
 
     self.gridViewModel = new ko.simpleGrid.viewModel({
@@ -1392,24 +1394,6 @@ define("archiva.general-admin",["jquery"
       }
     });
 
-    self.ldapGroupMappingsViewModel=new ko.simpleGrid.viewModel({
-      data: self.redbackRuntimeConfiguration().ldapGroupMappings,
-      columns: [
-        {
-          headerText: $.i18n.prop('redback.runtime.ldap.mapping.group.label'),
-          rowText: "group"
-        },
-        {
-          headerText: $.i18n.prop('redback.runtime.ldap.mapping.roles.label'),
-          rowText: "value"
-        }
-      ],
-      pageSize: 10,
-      gridUpdateCallBack: function(){
-        activatePopoverDoc();
-      }
-    });
-
     findUserManagerImplementationInformation=function(id){
       for(var i= 0;i<self.userManagerImplementationInformations().length;i++){
         $.log(id+""+self.userManagerImplementationInformations()[i].beanId);
@@ -1509,6 +1493,7 @@ define("archiva.general-admin",["jquery"
     }
 
     saveRedbackRuntimeConfiguration=function(){
+
       var mainContent=$("#main-content");
       var valid = mainContent.find("#redback-runtime-general-form-id").valid();
       if (valid==false) {
@@ -1564,14 +1549,71 @@ define("archiva.general-admin",["jquery"
             saveButton.button('reset');
             self.redbackRuntimeConfiguration().modified(false);
             self.redbackRuntimeConfiguration().ldapConfiguration().modified(false);
+            saveModifyLdapGroupMapping();
           }
         }
       );
 
+
+
+    }
+
+    saveModifyLdapGroupMapping=function(){
+      //save modified ldap group mappings if any
+      if(self.modifiesLdapGroupMappings().length>0){
+        $.log("save modifiesLdapGroupMappings");
+        $.each(self.modifiesLdapGroupMappings(),function(idx,item){
+          if(!(item.automatic&item.roleNames().length<2)){
+            $.log("update mapping for group:"+item.group());
+            var mainContent=$("#main-content");
+            var saveButton = mainContent.find("#redback-runtime-configuration-save" );
+            saveButton.button('loading');
+            clearUserMessages();
+            var userMessages=$("#user-messages");
+            userMessages.html(mediumSpinnerImg());
+            $.ajax("restServices/redbackServices/ldapGroupMappingService",
+                   {
+                     type: "POST",
+                     contentType: 'application/json',
+                     data:ko.toJSON(item),
+                     dataType: 'json',
+                     success: function(data) {
+                       var message=$.i18n.prop('redback-runtime-ldap-group-mapping.updated');
+                       displaySuccessMessage(message);
+                     },
+                     error: function(data) {
+                       var res = $.parseJSON(data.responseText);
+                       displayRestError(res);
+                     },
+                     complete:function(data){
+                       removeMediumSpinnerImg(userMessages);
+                       saveButton.button('reset');
+                       self.redbackRuntimeConfiguration().modified(false);
+                       self.redbackRuntimeConfiguration().ldapConfiguration().modified(false);
+                     }
+                   }
+            );
+          }
+        });
+
+
+      } else {
+        $.log("not save modifiesLdapGroupMappings");
+      }
+      self.modifiesLdapGroupMappings=ko.observableArray([]);
     }
 
-    modifyLdapGroupMapping=function(ldapGroupMapping){
-      $.log('modifyLdapGroupMapping');
+    this.modifyLdapGroupMapping=function(roleNames,ldapGroupMapping){
+      var toAdd=true;
+      $.each(self.modifiesLdapGroupMappings(),function(idx,item){
+        if(item.group()==ldapGroupMapping.group()){
+          toAdd=false;
+        }
+      });
+      if(toAdd){
+        self.modifiesLdapGroupMappings().push(ldapGroupMapping);
+      }
+      $.log('modifyLdapGroupMapping:'+ldapGroupMapping.group()+','+self.modifiesLdapGroupMappings().length);
     };
   }
 
@@ -1726,9 +1768,6 @@ define("archiva.general-admin",["jquery"
             }
           });
 
-
-
-
         }
       });
 
@@ -1755,11 +1794,12 @@ define("archiva.general-admin",["jquery"
       self.modified(true);
       $.log("roleNames modified");
       if(subscribeFn){
-        subscribeFn(newValue)
+        subscribeFn(newValue,self);
       }
     });
 
     this.automatic=automatic?automatic:false;
+    this.update=true;
   }
 
   mapLdapGroupMappings=function(data,modifyLdapGroupMapping){

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html?rev=1446590&r1=1446589&r2=1446590&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html
Fri Feb 15 14:14:35 2013
@@ -1243,8 +1243,8 @@
   <table class="table table-condensed">
     <thead>
       <tr>
-        <th>group</th>
-        <th>roles</th>
+        <th>${$.i18n.prop('redback.runtime.ldap.mapping.group.label')}</th>
+        <th>${$.i18n.prop('redback.runtime.ldap.mapping.roles.label')}</th>
       </tr>
     </thead>
     <tbody id="ldap-group-mappings-tbody">
@@ -1253,7 +1253,7 @@
         <td>${ldapGroupMapping.group()}</td>
         <td>
           <div>
-            <select id="roles-group-${ldapGroupMapping.group()}" data-bind="options: $parent.allRoleNames,
selectedOptions: ldapGroupMapping.roleNames()"
+            <select id="roles-group-${ldapGroupMapping.group()}" data-bind="options: $parent.allRoleNames,
selectedOptions: ldapGroupMapping.roleNames"
                     size="5" multiple="true" ></select>
           </div>
 



Mime
View raw message