fix ctit ldap search form fields in ui

This commit is contained in:
John Mitchell 2017-07-13 13:54:26 -04:00
parent 7c68700df9
commit 3e25ad5ffc
3 changed files with 30 additions and 10 deletions

View File

@ -77,8 +77,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);
}

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);