From c378b096881184c41eef2ac80795ef7af0a24973 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 15 Feb 2013 14:14:35 +0000 Subject: [PATCH] [MRM-1736] map roles to ldap groups update mapping implemented. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1446590 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/webapp/js/archiva/general-admin.js | 88 ++++++++++++++----- .../js/templates/archiva/general-admin.html | 6 +- 2 files changed, 67 insertions(+), 27 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js index e27f4857e..02cf3403c 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js @@ -1372,6 +1372,8 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" 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","i18n","utils","jquery.tmpl","knockout" } }); - 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;i0){ + $.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([]); + } + + 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","i18n","utils","jquery.tmpl","knockout" } }); - - - } }); @@ -1755,11 +1794,12 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" 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){ diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html index 20d067185..43d87876e 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html @@ -1243,8 +1243,8 @@ - - + + @@ -1253,7 +1253,7 @@
grouproles${$.i18n.prop('redback.runtime.ldap.mapping.group.label')}${$.i18n.prop('redback.runtime.ldap.mapping.roles.label')}
${ldapGroupMapping.group()}
-
-- 2.39.5