Set default values for complex nodes (may fix #1253)

environments/ppa-mbqj77/deployments/1
Xavier Guimard 7 years ago
parent 79f64c8270
commit bbf6d9f020
  1. 23
      lemonldap-ng-manager/site/coffee/manager.coffee
  2. 36
      lemonldap-ng-manager/site/htdocs/static/js/manager.js
  3. 2
      lemonldap-ng-manager/site/htdocs/static/js/manager.min.js

@ -342,16 +342,7 @@ llapp.controller 'TreeCtrl', [
$scope.showModal('prompt.html', name).then ->
n= $scope.result
if n
node = $scope.addTemplateNode n, 'virtualHost'
delete node.nodes[0].cnodes
node.nodes[0].nodes = [
id: "virtualHosts/new__#{n}/locationRules/default",
type: "rule",
title: "default",
comment: "",
re: "default",
data: "deny"
]
$scope.addTemplateNode n, 'virtualHost'
$scope.duplicateVhost = ->
name = if $scope.domain then ".#{$scope.domain.data}" else '.example.com'
@ -398,10 +389,22 @@ llapp.controller 'TreeCtrl', [
title: name
type: type
nodes: templates type, "new__#{name}"
setDefault t.nodes
cs.$modelValue.nodes.push t
cs.expand()
return t
setDefault = (node) ->
for n in node
if n.cnodes and n.default
delete n.cnodes
n._nodes = n.default
if n._nodes
setDefault n._nodes
else if n.default or n.default == 0
n.data = n.default
node
_getAll = (node) ->
d = $q.defer()
d2 = $q.defer()

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.10.0
// Generated by CoffeeScript 1.12.7
/*
LemonLDAP::NG Manager client
@ -23,7 +23,7 @@ This file contains:
llapp.controller('TreeCtrl', [
'$scope', '$http', '$location', '$q', '$uibModal', '$translator', '$cookies', '$htmlParams', function($scope, $http, $location, $q, $uibModal, $translator, $cookies, $htmlParams) {
var _checkSaveResponse, _download, _getAll, _stoggle, c, id, pathEvent, readError, setHelp;
var _checkSaveResponse, _download, _getAll, _stoggle, c, id, pathEvent, readError, setDefault, setHelp;
$scope.links = window.links;
$scope.menu = $htmlParams.menu;
$scope.menulinks = window.menulinks;
@ -405,21 +405,10 @@ This file contains:
field: 'hostname'
};
return $scope.showModal('prompt.html', name).then(function() {
var n, node;
var n;
n = $scope.result;
if (n) {
node = $scope.addTemplateNode(n, 'virtualHost');
delete node.nodes[0].cnodes;
return node.nodes[0].nodes = [
{
id: "virtualHosts/new__" + n + "/locationRules/default",
type: "rule",
title: "default",
comment: "",
re: "default",
data: "deny"
}
];
return $scope.addTemplateNode(n, 'virtualHost');
}
});
};
@ -479,10 +468,27 @@ This file contains:
type: type,
nodes: templates(type, "new__" + name)
};
setDefault(t.nodes);
cs.$modelValue.nodes.push(t);
cs.expand();
return t;
};
setDefault = function(node) {
var len, n, o;
for (o = 0, len = node.length; o < len; o++) {
n = node[o];
if (n.cnodes && n["default"]) {
delete n.cnodes;
n._nodes = n["default"];
}
if (n._nodes) {
setDefault(n._nodes);
} else if (n["default"] || n["default"] === 0) {
n.data = n["default"];
}
}
return node;
};
_getAll = function(node) {
var d, d2;
d = $q.defer();

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save