diff options
author | Olivier Lamy <olamy@apache.org> | 2013-02-11 17:12:31 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2013-02-11 17:12:31 +0000 |
commit | fc846059c13181d79f04df6aff4fc6a958adbe33 (patch) | |
tree | 93fe7d8bf89a980b090fc6a808fdbdf04d874dcd | |
parent | 59989f2bc7f3cffda0fe51a6b48cb07e1a49c0ea (diff) | |
download | archiva-fc846059c13181d79f04df6aff4fc6a958adbe33.tar.gz archiva-fc846059c13181d79f04df6aff4fc6a958adbe33.zip |
start ui for ldap group <-> roles mapping
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1444879 13f79535-47bb-0310-9956-ffa450edef68
2 files changed, 117 insertions, 6 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 8d4c2b997..c5c58a979 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 @@ -17,7 +17,7 @@ * under the License. */ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout","knockout.simpleGrid", - "knockout.sortable","jquery.validate","bootstrap"] + "knockout.sortable","jquery.ui","jquery.validate","bootstrap","select2"] , function(jquery,i18n,utils,jqueryTmpl,ko) { //------------------------- @@ -1257,6 +1257,11 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" this.usersCacheConfiguration=ko.observable(cacheConfiguration); this.usersCacheConfiguration.subscribe(function(newValue){self.modified(true)}); + this.ldapGroups=ko.observableArray([]); + this.ldapGroups.subscribe(function(newValue){self.modified(true)}); + + this.ldapGroupMappings=ko.observableArray([]); + this.ldapGroupMappings.subscribe(function(newValue){self.modified(true);}); } @@ -1349,6 +1354,8 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" this.usedUserManagerImpls=ko.observableArray([]); + this.allRoleNames=[]; + self.gridViewModel = new ko.simpleGrid.viewModel({ data: self.redbackRuntimeConfiguration().configurationPropertiesEntries, columns: [ @@ -1615,10 +1622,60 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" var redbackRuntimeConfiguration = mapRedbackRuntimeConfiguration(data); var redbackRuntimeConfigurationViewModel = new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations); - mainContent.html( $("#redback-runtime-configuration-main" ).tmpl() ); - ko.applyBindings(redbackRuntimeConfigurationViewModel,$("#redback-runtime-configuration-content" ).get(0)); - activateRedbackRuntimeGeneralFormValidation(); - activateLdapConfigurationFormValidation(); + + + // load ldap roles + $.ajax("restServices/redbackServices/ldapGroupMappingService/ldapGroups", { + type: "GET", + dataType: 'json', + success: function(data) { + var groups = []; + if(data&&data.strings){ + groups = $.isArray(data.strings)? $.map(data.strings,function(item){ + return item; + }):[data.strings]; + } + $.log("groups number:"+groups.length); + redbackRuntimeConfiguration.ldapGroups.push(groups); + + // load ldap group mappings if any + $.ajax("restServices/redbackServices/ldapGroupMappingService", { + type: "GET", + dataType: 'json', + success: function(data) { + var groupMappings=mapLdapGroupMappings(data); + + redbackRuntimeConfiguration.ldapGroupMappings(groupMappings); + redbackRuntimeConfiguration.modified(false); + + + $.ajax("restServices/redbackServices/roleManagementService/allRoles", { + type: "GET", + dataType: 'json', + success: function(data) { + + var allRoleNames = $.map(data, function(item) { + return item.name; + }); + + redbackRuntimeConfigurationViewModel.allRoleNames=allRoleNames; + + mainContent.html( $("#redback-runtime-configuration-main" ).tmpl() ); + ko.applyBindings(redbackRuntimeConfigurationViewModel,$("#redback-runtime-configuration-content" ).get(0)); + activateRedbackRuntimeGeneralFormValidation(); + activateLdapConfigurationFormValidation(); + $("#ldap-group-mappings-div select" ).select2({width: "element"}); + + } + }); + } + }); + } + }); + + + + } }); @@ -1627,6 +1684,27 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" } + LdapGroupMapping=function(group,roleNames){ + var self=this; + this.modified=ko.observable(false); + //private String group; + this.group=ko.observable(group); + this.group.subscribe(function(newValue){self.modified(true)}); + + //private Collection<String> roleNames; + this.roleNames=ko.observableArray(roleNames); + this.roleNames.subscribe(function(newValue){self.modified(true)}); + } + + mapLdapGroupMappings=function(data){ + if(data!=null){ + return $.map(data,function(item){ + return new LdapGroupMapping(item.group,item.roleNames?item.roleNames:[]); + }) + } + return []; + } + CacheConfiguration=function(timeToIdleSeconds,timeToLiveSeconds,maxElementsInMemory,maxElementsOnDisk){ var self=this; this.modified=ko.observable(false); 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 fb2b99f15..d21002a19 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 @@ -976,6 +976,7 @@ <ul class="nav nav-tabs"> <li class="active" id="redback-runtime-general-li"><a href="#redback-runtime-general-content" data-toggle="tab">${$.i18n.prop('redback.runtime.general.title')}</a></li> <li id="redback-runtime-ldap-li"><a href="#redback-runtime-ldap-content" data-toggle="tab">${$.i18n.prop('redback.runtime.ldap.title')}</a></li> + <li id="redback-ldap-mapping-li"><a href="#redback-runtime-ldap-mapping" data-toggle="tab">${$.i18n.prop('redback.runtime.ldap.mapping.title')}</a></li> <li id="redback-runtime-properties-li"><a href="#redback-runtime-properties-content" data-toggle="tab">${$.i18n.prop('redback.runtime.properties.title')}</a></li> <li id="redback-runtime-users-cache-li"><a href="#redback-runtime-users-cache-content" data-toggle="tab">${$.i18n.prop('redback.runtime.users.cache.title')}</a></li> </ul> @@ -1091,10 +1092,14 @@ </div> </div> + <div class="tab-pane" id="redback-runtime-ldap-mapping" data-bind='template: {name:"redback-runtime-ldap-mapping-tmpl",data: redbackRuntimeConfiguration}'> + + </div> + <div class="tab-pane" id="redback-runtime-properties-content"> <div class="well"> - <table id="proxyConnectorsTable" + <table id="proxyConnectorsTable" class="table-hover" data-bind="simpleGrid: gridViewModel,simpleGridTemplate:'properties-grid',pageLinksId:'properties-grid-pagination'"> </table> <div id="properties-grid-pagination"></div> @@ -1192,3 +1197,31 @@ ${$data.description} </div> </script> + +<script id="redback-runtime-ldap-mapping-tmpl" type="text/html"> + <div class="well" id="ldap-group-mappings-div"> + <table class="table table-condensed"> + <thead> + <tr> + <th>group</th> + <th>roles</th> + </tr> + </thead> + <tbody id="ldap-group-mappings-tbody"> + {{each(i, ldapGroupMapping) ldapGroupMappings()}} + <tr> + <td>${ldapGroupMapping.group()}</td> + <td> + <div> + <select id="roles-group-${ldapGroupMapping.group()}" data-bind="options: $parent.allRoleNames, selectedOptions: ldapGroupMapping.roleNames()" + size="5" multiple="true" ></select> + </div> + + </td> + </tr> + {{/each}} + + </tbody> + </table> + </div> +</script> |