diff --git a/lemonldap-ng-manager/site/static/forms/authChoice.html b/lemonldap-ng-manager/site/static/forms/authChoice.html
index 42508b6ee..3d2f62683 100644
--- a/lemonldap-ng-manager/site/static/forms/authChoice.html
+++ b/lemonldap-ng-manager/site/static/forms/authChoice.html
@@ -13,7 +13,7 @@
|
- |
diff --git a/lemonldap-ng-manager/site/static/forms/authChoiceContainer.html b/lemonldap-ng-manager/site/static/forms/authChoiceContainer.html
index b5f5ccade..6395877c3 100644
--- a/lemonldap-ng-manager/site/static/forms/authChoiceContainer.html
+++ b/lemonldap-ng-manager/site/static/forms/authChoiceContainer.html
@@ -17,7 +17,7 @@
-
+
|
diff --git a/lemonldap-ng-manager/site/static/js/filterFunctions.js b/lemonldap-ng-manager/site/static/js/filterFunctions.js
index 377ef5bd5..edde7596f 100644
--- a/lemonldap-ng-manager/site/static/js/filterFunctions.js
+++ b/lemonldap-ng-manager/site/static/js/filterFunctions.js
@@ -1,5 +1,5 @@
var filterFunctions = {
- 'authParams': function($scope, $q, node) {
+ 'authParams': function(scope, $q, node) {
/* Here, `node` is the root node (authParams) and `n` points to its
* conditional subnodes. This subnodes have the property `show` that can
* be set to true or false depending on what has to be displayed
@@ -8,29 +8,56 @@ var filterFunctions = {
/* 1. be sure to have all datas in main nodes */
var wait = [];
node.nodes.forEach(function(n) {
- wait.push($scope.getKey(n));
+ wait.push(scope.getKey(n));
});
/* 2. then do the job */
$q.all(wait).then(function() {
/* 2.1. Get all modules needed */
var all = false;
var nToShow = [];
+ var p = function(s) {
+ var tmp = s.toLowerCase();
+ if (tmp == 'ad') {
+ tmp = 'ldap';
+ }
+ if (tmp == 'openidconnect') {
+ tmp = 'oidc';
+ }
+ nToShow.push(tmp + 'Params');
+ }
if (node.nodes[0].data.match(/^(Choice|Multi)/)) {
for (var i = 1; i < 3; i++) {
node.nodes[i].data = node.nodes[0].data;
}
- all = true;
+ //all = true;
}
node.nodes.forEach(function(n) {
- var tmp = n.data.toLowerCase();
- if (tmp == 'ad') {
- tmp = 'ldap';
+ p(n.data);
+ });
+ /* Get choice or multi sub modules */
+ node.nodes_cond.forEach(function(n) {
+ if (node.nodes[0].data == 'Choice' && n.id == 'choiceParams') {
+ var nd = n._nodes ? n._nodes : n.nodes;
+ if (!nd[1].cnodes) {
+ nd = nd[1]._nodes ? nd[1]._nodes : nd[1].nodes;
+ nd.forEach(function(m) {
+ m.data.forEach(function(s) {
+ p(s);
+ });
+ });
+ }
}
- if (tmp == 'openidconnect') {
- tmp = 'oidc';
+ else if (node.nodes[0].data == 'Multi' && n.id == 'multiParams') {
+ var nd = n._nodes ? n._nodes : n.nodes;
+ var sep = nd[2].data || ';';
+ var reg = new RegExp('(?:^|' + sep + ')(\w+)');
+ var s = nd[0].data + sep + nd[1].data;
+ while ((result = reg.exec(s)) !== null) {
+ p(result);
+ }
}
- nToShow.push(tmp + 'Params');
});
+ console.log(nToShow);
/* 2.2 Display modules */
node.nodes_cond.forEach(function(n) {
if (!all && nToShow.indexOf(n.id) == -1) {
diff --git a/lemonldap-ng-manager/site/static/js/manager.js b/lemonldap-ng-manager/site/static/js/manager.js
index 6d4198de2..977486263 100644
--- a/lemonldap-ng-manager/site/static/js/manager.js
+++ b/lemonldap-ng-manager/site/static/js/manager.js
@@ -108,14 +108,14 @@
if (!button.action) button.action = button.title;
//try {
switch (typeof button.action) {
- case 'function':
- button.action($scope.currentNode, $scope);
- break;
- case 'string':
- $scope[button.action]();
- break;
- default:
- console.log(typeof button.action);
+ case 'function':
+ button.action($scope.currentNode, $scope);
+ break;
+ case 'string':
+ $scope[button.action]();
+ break;
+ default:
+ console.log(typeof button.action);
};
//} catch (e) {
// alert("Error: " + e.message);
@@ -173,7 +173,8 @@
$scope.waiting = false;
$scope.data.pop();
})
- }, function() {
+ },
+ function() {
console.log('Saving canceled');
});
$scope.showM = false;
@@ -196,16 +197,27 @@
$scope.cancel = function() {
$scope.currentNode.data = null;
$scope.getKey($scope.currentNode);
- }
+ };
var id = 1;
$scope._findContainer = function() {
+ return $scope._findScopeContainer().$modelValue;
+ };
+ $scope._findScopeContainer = function() {
var cs = $scope.currentScope;
while (!cs.$modelValue.type.match(/Container$/)) {
cs = cs.$parentNodeScope;
}
- return cs.$modelValue;
+ return cs;
+ };
+
+ $scope._findScopeByKey = function(k) {
+ var cs = $scope.currentScope;
+ while (! (cs.$modelValue.title === k)) {
+ cs = cs.$parentNodeScope;
+ }
+ return cs;
}
/* Add rules entry */
@@ -240,9 +252,10 @@
node.nodes.push({
"id": node.id + '/n' + (id++),
"title": "1-key",
- "data": ['LDAP','LDAP','Null'],
+ "data": ['Null', 'Null', 'Null'],
"type": "authChoice"
});
+ $scope.execFilters($scope._findScopeByKey('authParams'));
};
/* Add hash entry */
@@ -315,26 +328,22 @@
$scope.addSamlIDP = function() {
var name = window.prompt($translator.translate('samlPartnerName'));
- if (name)
- $scope.addTemplateNode(name, 'samlIDPMetaDataNode');
+ if (name) $scope.addTemplateNode(name, 'samlIDPMetaDataNode');
};
$scope.addSamlSP = function() {
var name = window.prompt($translator.translate('samlPartnerName'));
- if (name)
- $scope.addTemplateNode(name, 'samlSPMetaDataNode');
+ if (name) $scope.addTemplateNode(name, 'samlSPMetaDataNode');
};
$scope.addOidcOp = function() {
var name = window.prompt($translator.translate('oidcOPName'));
- if (name)
- $scope.addTemplateNode(name, 'oidcOPMetaDataNode');
+ if (name) $scope.addTemplateNode(name, 'oidcOPMetaDataNode');
};
$scope.addOidcRp = function() {
var name = window.prompt($translator.translate('oidcRPName'));
- if (name)
- $scope.addTemplateNode(name, 'oidcRPMetaDataNode');
+ if (name) $scope.addTemplateNode(name, 'oidcRPMetaDataNode');
};
$scope.addTemplateNode = function(name, type) {
@@ -420,10 +429,11 @@
/* authParams mechanism: show used auth modules only (launched by stoggle) */
$scope.filters = {};
- $scope.execFilters = function() {
+ $scope.execFilters = function(scope) {
+ scope = scope ? scope : $scope;
for (var filter in $scope.filters) {
if ($scope.filters.hasOwnProperty(filter)) {
- filterFunctions[filter]($scope, $q, $scope.filters[filter]);
+ filterFunctions[filter](scope, $q, $scope.filters[filter]);
}
}
};
@@ -481,8 +491,10 @@
d.reject('Empty response from server');
} else if (data.error) {
if (data.error == 'setDefault') {
- if (node.default) {
- node.nodes = node.default.slice(0);
+ if (node.
+ default) {
+ node.nodes = node.
+ default.slice(0);
} else node.nodes = [];
delete node.cnodes;
d.resolve('Set data to default value');
@@ -515,7 +527,8 @@
$scope.openCnode = function(scope) {
$scope.download(scope).then(function() {
scope.toggle();
- }, function(reason) {
+ },
+ function(reason) {
if (typeof reason == 'string') {
alert(reason);
}
@@ -552,7 +565,8 @@
f = 'text';
}
if (node.nodes || node._nodes || node.cnodes) {
- $scope.form = f != 'text' ? f : 'home';
+ $scope.form = f != 'text' ? f:
+ 'home';
} else {
$scope.form = f;
/* Get datas */
@@ -591,7 +605,8 @@
}).error(function(j, e) {
$scope.waiting = false;
});
- }, function() {
+ },
+ function() {
console.log('New key cancelled');
});
}
@@ -632,15 +647,18 @@
};
$q.all(tmp).then(function() {
d.resolve(node.data);
- }, function(j, e) {
+ },
+ function(j, e) {
d.reject(e);
$scope.waiting = false;
});
} else {
$http.get($scope.confPrefix + $scope.currentCfg.cfgNum + '/' + (node.get ? node.get : node.title)).success(function(data) {
/* Set default value if response is null or if asked by server */
- if ((data.value === null || (data.error && data.error == 'setDefault')) && node.default !== null) {
- node.data = node.default;
+ if ((data.value === null || (data.error && data.error == 'setDefault')) && node.
+ default !== null) {
+ node.data = node.
+ default;
} else {
node.data = data.value;
}
@@ -664,7 +682,6 @@
return d.promise;
};
-
/* function `pathEvent(event, next; current)`:
* Called when $location.path() change, launch getCfg() with the new
* configuration number
@@ -722,22 +739,20 @@
$scope.waiting = true;
$scope.data = [];
$q.all([
- $translator.init($scope.lang),
- $http.get(staticPrefix + "struct.json").success(function(data) {
- tmp = data;
- console.log("Structure loaded");
- })
- ])
- .then(function() {
- console.log("Starting structure binding");
- $scope.data = tmp;
- tmp = null;
- setScopeVars($scope);
- $scope.form = 'home';
- $scope.waiting = false;
- }, function(j, e) {
- $scope.waiting = false;
- });
+ $translator.init($scope.lang), $http.get(staticPrefix + "struct.json").success(function(data) {
+ tmp = data;
+ console.log("Structure loaded");
+ })]).then(function() {
+ console.log("Starting structure binding");
+ $scope.data = tmp;
+ tmp = null;
+ setScopeVars($scope);
+ $scope.form = 'home';
+ $scope.waiting = false;
+ },
+ function(j, e) {
+ $scope.waiting = false;
+ });
};
var c = $location.path().match(new RegExp('^/confs/(latest|[0-9]+)'));
if (!c) {