this.usedUserManagerImpls=ko.observableArray([]);
+ this.modifiesLdapGroupMappings=ko.observableArray([]);
+
this.allRoleNames=[];
self.gridViewModel = new ko.simpleGrid.viewModel({
}
});
- 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);
}
saveRedbackRuntimeConfiguration=function(){
+
var mainContent=$("#main-content");
var valid = mainContent.find("#redback-runtime-general-form-id").valid();
if (valid==false) {
saveButton.button('reset');
self.redbackRuntimeConfiguration().modified(false);
self.redbackRuntimeConfiguration().ldapConfiguration().modified(false);
+ saveModifyLdapGroupMapping();
}
}
);
+
+
}
- modifyLdapGroupMapping=function(ldapGroupMapping){
- $.log('modifyLdapGroupMapping');
+ 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([]);
+ }
+
+ 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);
};
}
}
});
-
-
-
}
});
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){