diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index d3649d9318..0ed884d19a 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -28,23 +28,34 @@ TreeController = { return; } - function _processGroup (container, elements) { + function _processGroup (container, elements, rootGroup) { var $group = $(""); - $group - .addClass("tree-group") - .hide(); + + if (typeof rootGroup != 'undefinded' && rootGroup == true) { + $group + .addClass("tree-root") + .hide(); + } + else { + rootGroup = false; + $group + .addClass("tree-group") + .hide(); + } container.append($group); - var last; + var lastNode; + var firstNode; elements.forEach(function(element, index) { - last = index == elements.length - 1 ? true : false; - element.jqObject = _processNode($group, element, last); + lastNode = index == elements.length - 1 ? true : false; + firstNode = rootGroup && index == 0 ? true : false; + element.jqObject = _processNode($group, element, lastNode, firstNode); }, $group); return $group; } - function _processNode (container, element, last) { + function _processNode (container, element, lastNode, firstNode) { var $node = $("
  • "); var $leafIcon = $("
    "); var $content = $("
    "); @@ -68,9 +79,12 @@ TreeController = { .append($leafIcon) .append($content); - if (typeof last != 'undefinded' && last == true) { + if (typeof lastNode != 'undefinded' && lastNode == true) { $node.addClass("tree-last"); } + if (typeof firstNode != 'undefinded' && firstNode == true) { + $node.addClass("tree-first"); + } container.append($node); @@ -174,41 +188,10 @@ TreeController = { this.recipient.empty(); - var $loadingImage = $(''); - - var $children = _processGroup(this.recipient, this.tree); + var $children = _processGroup(this.recipient, this.tree, true); $children.show(); this.recipient.data('children', $children); - - // $.ajax({ - // url: this.ajaxURL, - // type: 'POST', - // dataType: 'json', - // data: { - // page: this.ajaxPage, - // getChildren: 1, - // type: element.type - // }, - // complete: function(xhr, textStatus) { - // $loadingImage.remove(); - // }, - // success: function(data, textStatus, xhr) { - // if (data.success) { - // var $children = _processGroup(this.recipient, data.elements); - // $children.show(); - - // this.recipient.data('children', $children); - // } - // else { - // $loadingImage.remove(); - // this.recipient.html("
    " + this.errorMessage + "
    "); - // } - // }, - // error: function(xhr, textStatus, errorThrown) { - // this.recipient.html("
    " + this.errorMessage + "
    "); - // } - // }); }, load: function () { this.reload(); @@ -217,16 +200,6 @@ TreeController = { this.tree = tree; this.reload(); }, - addLeaf: function (leaf) { - // this.tree.unshift(leaf); - // this.reload(); - }, - removeLeaf: function (leafID) { - if (leafID != 0 && this.tree.length > 0) { - this.tree.splice(leafID, 1); - this.reload(); - } - }, init: function (data) { if (typeof data.recipient != 'undefined' && data.recipient.length > 0) { this.recipient = data.recipient; diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 1b797e86a5..34a899ba8f 100755 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -2838,6 +2838,7 @@ table#policy_modules td * { /* Tree view styles */ .tree-group { margin-left: 16px; + padding-top: 4px; } .tree-node { @@ -2865,10 +2866,18 @@ table#policy_modules td * { background-image: url(../../images/tree/last_expanded.png); } +.tree-node.tree-first.leaf-open>.leaf-icon { + background-image: url(../../images/tree/first_expanded.png); +} + .tree-node.leaf-closed>.leaf-icon { background-image: url(../../images/tree/last_closed.png); } +.tree-node.tree-first.leaf-closed>.leaf-icon { + background-image: url(../../images/tree/first_closed.png); +} + .tree-node.leaf-loading>.leaf-icon { background-image: url(../../images/tree/last_expanded.png); } @@ -2877,6 +2886,10 @@ table#policy_modules td * { background-image: url(../../images/tree/last_leaf.png); } +.tree-node.tree-first.leaf-empty>.leaf-icon { + background-image: url(../../images/tree/first_leaf.png); +} + .tree-node>.leaf-icon { background-position: 0px 0px; background-repeat: no-repeat;