2015-05-14 08:44:38 +02:00
|
|
|
var filterFunctions = {
|
2015-12-15 20:05:44 +01:00
|
|
|
'authParams': function(scope, $q, node) {
|
2015-05-14 08:44:38 +02:00
|
|
|
/* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* 1. be sure to have all datas in main nodes */
|
|
|
|
var wait = [];
|
2017-02-06 19:04:07 +01:00
|
|
|
console.log('filterFunctions called');
|
2015-05-14 08:44:38 +02:00
|
|
|
node.nodes.forEach(function(n) {
|
2015-12-15 20:05:44 +01:00
|
|
|
wait.push(scope.getKey(n));
|
2015-05-14 08:44:38 +02:00
|
|
|
});
|
|
|
|
/* 2. then do the job */
|
|
|
|
$q.all(wait).then(function() {
|
|
|
|
/* 2.1. Get all modules needed */
|
|
|
|
var all = false;
|
|
|
|
var nToShow = [];
|
2015-12-15 20:05:44 +01:00
|
|
|
var p = function(s) {
|
|
|
|
var tmp = s.toLowerCase();
|
|
|
|
if (tmp == 'ad') {
|
|
|
|
tmp = 'ldap';
|
|
|
|
}
|
|
|
|
if (tmp == 'openidconnect') {
|
|
|
|
tmp = 'oidc';
|
|
|
|
}
|
|
|
|
nToShow.push(tmp + 'Params');
|
|
|
|
}
|
2017-02-06 18:40:17 +01:00
|
|
|
if (node.nodes[0].data.match(/^Choice/)) {
|
|
|
|
node.nodes[2].data = 'Choice';
|
2015-05-14 08:44:38 +02:00
|
|
|
}
|
2017-02-06 18:40:17 +01:00
|
|
|
|
2015-05-14 08:44:38 +02:00
|
|
|
node.nodes.forEach(function(n) {
|
2015-12-15 20:05:44 +01:00
|
|
|
p(n.data);
|
|
|
|
});
|
|
|
|
/* Get choice or multi sub modules */
|
|
|
|
node.nodes_cond.forEach(function(n) {
|
2017-02-06 19:04:07 +01:00
|
|
|
var restart = 0;
|
2017-02-06 18:40:17 +01:00
|
|
|
var nd = n._nodes ? n._nodes : n.nodes;
|
2015-12-15 20:05:44 +01:00
|
|
|
if (node.nodes[0].data == 'Choice' && n.id == 'choiceParams') {
|
2017-02-06 19:04:07 +01:00
|
|
|
console.log('Choice is selected');
|
2017-02-06 18:40:17 +01:00
|
|
|
if (nd[1].cnodes) {
|
2017-02-06 19:04:07 +01:00
|
|
|
restart++;
|
2017-02-06 18:40:17 +01:00
|
|
|
}
|
|
|
|
else {
|
2015-12-15 20:05:44 +01:00
|
|
|
nd = nd[1]._nodes ? nd[1]._nodes : nd[1].nodes;
|
|
|
|
nd.forEach(function(m) {
|
|
|
|
m.data.forEach(function(s) {
|
|
|
|
p(s);
|
|
|
|
});
|
|
|
|
});
|
2016-01-12 18:20:22 +01:00
|
|
|
};
|
2015-05-14 08:44:38 +02:00
|
|
|
}
|
2017-02-06 18:40:17 +01:00
|
|
|
else if (node.nodes[0].data == 'Combination' && n.id == 'combinationParams') {
|
2017-02-06 19:04:07 +01:00
|
|
|
console.log('Combination is selected');
|
2017-02-06 18:40:17 +01:00
|
|
|
if (nd[1].cnodes) {
|
2017-02-06 19:04:07 +01:00
|
|
|
restart++;
|
2015-12-15 20:05:44 +01:00
|
|
|
}
|
2017-02-06 18:40:17 +01:00
|
|
|
else {
|
|
|
|
nd = nd[1]._nodes ? nd[1]._nodes : nd[1].nodes;
|
2017-02-06 19:04:07 +01:00
|
|
|
nd.forEach(function(m) {
|
|
|
|
p(m.data.type);
|
|
|
|
});
|
|
|
|
}
|
2015-10-22 10:40:08 +02:00
|
|
|
}
|
2017-02-06 19:04:07 +01:00
|
|
|
if(restart==1) {
|
2017-02-06 18:40:17 +01:00
|
|
|
scope.waiting = true;
|
|
|
|
scope.download({
|
|
|
|
'$modelValue': nd[1]
|
|
|
|
}).then(function() {
|
|
|
|
filterFunctions.authParams(scope, $q, node)
|
|
|
|
});
|
|
|
|
return;
|
2017-02-06 19:04:07 +01:00
|
|
|
}
|
2015-05-14 08:44:38 +02:00
|
|
|
});
|
|
|
|
/* 2.2 Display modules */
|
|
|
|
node.nodes_cond.forEach(function(n) {
|
|
|
|
if (!all && nToShow.indexOf(n.id) == -1) {
|
|
|
|
n.show = false
|
|
|
|
} else {
|
|
|
|
n.show = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2017-02-06 18:40:17 +01:00
|
|
|
}
|