Merge pull request #7056 from jlmitch5/fixCTITLdapForm

fix ctit ldap search form fields in ui
This commit is contained in:
jlmitch5 2017-07-14 13:15:16 -04:00 committed by GitHub
commit 70eeca1a38
4 changed files with 44 additions and 14 deletions

View File

@ -313,6 +313,15 @@ export default [
populateTacacsProtocol(false);
});
$scope.$on('codeMirror_populated', function() {
let tab = $stateParams.currentTab;
if (tab === 'auth') {
startCodeMirrors();
codeInputInitialized = true;
}
});
angular.extend(authVm, {
activeForm: activeForm,
activeAuthForm: activeAuthForm,

View File

@ -87,8 +87,9 @@ export default [
// behind the comma.
if(key === "AD_HOC_COMMANDS"){
$scope[key] = data[key].toString();
}
else {
} else if (key === "AUTH_LDAP_USER_SEARCH" || key === "AUTH_LDAP_GROUP_SEARCH") {
$scope[key] = JSON.stringify(data[key]);
} else {
$scope[key] = ConfigurationUtils.arrayToList(data[key], key);
}
@ -324,11 +325,12 @@ export default [
else if($scope[key + '_field'].reset === "CUSTOM_LOGO"){
$scope.$broadcast(key+'_reverted');
}
else if($scope[key + '_field'].type === "textarea" && _.isArray($scope.configDataResolve[key].default)){
$scope[key] = ConfigurationUtils.arrayToList($scope[key], key);
}
else if($scope[key + '_field'].hasOwnProperty('codeMirror')){
$scope[key] = '{}';
if (key === "AUTH_LDAP_USER_SEARCH" || key === "AUTH_LDAP_GROUP_SEARCH") {
$scope[key] = '[]';
} else {
$scope[key] = '{}';
}
$scope.$broadcast('codeMirror_populated', key);
}
loginUpdate();

View File

@ -9,16 +9,30 @@ export default ['$q',
return {
listToArray: function(input) {
if (input.indexOf('\n') !== -1) {
var payload;
if (input.indexOf('[') !== -1) {
try {
payload = JSON.parse(input);
if (!Array.isArray(payload)) {
payload = [];
}
} catch(err) {
payload = [];
}
} else if (input.indexOf('\n') !== -1) {
//Parse multiline input
return input.replace(/^\s+|\s+$/g, "").split('\n');
payload = input.replace(/^\s+|\s+$/g, "").split('\n');
} else {
if (input === '') {
return [];
if (input === '' || input === '{}') {
payload = [];
} else {
return input.replace(/^\s+|\s+$/g, "").split(/\s*,\s*/);
payload = input.replace(/^\s+|\s+$/g, "")
.split(/\s*,\s*/);
}
}
return payload;
},
arrayToList: function(input) {

View File

@ -51,11 +51,16 @@ export default
// converting yaml to json
try {
removeField(fld);
json_obj = jsyaml.load(scope[fld]);
if ($.isEmptyObject(json_obj)) {
scope[fld] = "{}";
}
else {
if (Array.isArray(json_obj)) {
scope[fld] = "[]";
} else {
scope[fld] = "{}";
}
} else {
scope[fld] = JSON.stringify(json_obj, null, " ");
}
createField(onReady, onChange, fld);