From a9b096131dc518e52ec1de5e6846e537fa57a560 Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Wed, 17 Dec 2014 19:45:09 +0100 Subject: [PATCH] Fixes --- .../include/javascript/tree/TreeController.js | 19 +++++++++++-------- pandora_console/include/styles/pandora.css | 4 ++++ pandora_console/operation/tree.php | 5 ++--- pandora_console/operation/tree2.php | 6 ++++-- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index fa35444678..d0a6757273 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -26,7 +26,7 @@ TreeController = { errorMessage: "Error", baseURL: "", ajaxURL: "ajax.php", - ajaxPage: "include/ajax/tree.ajax.php", + ajaxPage: "include/ajax/tree.ajax", detailRecipient: '', reload: function () { // Bad recipient @@ -60,7 +60,7 @@ TreeController = { elements.forEach(function(element, index) { lastNode = index == elements.length - 1 ? true : false; firstNode = rootGroup && index == 0 ? true : false; - element.jqObject = _processNode($group, detailRecipient, element, lastNode, firstNode); + element.jqObject = _processNode($group, detailContainer, element, lastNode, firstNode); }, $group); return $group; @@ -119,7 +119,7 @@ TreeController = { $node.addClass("leaf-closed"); // Add children - var $children = _processGroup($node, this.detailContainer, element.children, this.baseURL); + var $children = _processGroup($node, detailContainer, element.children, this.baseURL); $node.data('children', $children); $leafIcon.click(function () { @@ -142,7 +142,9 @@ TreeController = { else if (typeof element.searchChildren != 'undefined' && element.searchChildren) { $node.addClass("leaf-closed"); - $leafIcon.click(function () { + $leafIcon.click(function (e) { + e.preventDefault(); + if (! $node.hasClass("children-loaded")) { $node .removeClass("leaf-closed") @@ -150,23 +152,24 @@ TreeController = { .addClass("leaf-loading"); $.ajax({ - url: this.ajaxURL, + url: controller.ajaxURL, type: 'POST', dataType: 'json', data: { - page: this.ajaxPage, + page: controller.ajaxPage, getChildren: 1, id: element.id, type: element.type }, complete: function(xhr, textStatus) { $node.removeClass("leaf-loading"); + $node.addClass("children-loaded") }, success: function(data, textStatus, xhr) { if (data.success) { $node.addClass("leaf-open"); - var $children = _processGroup($node, this.detailContainer, data.elements, this.baseURL); + var $children = _processGroup($node, detailContainer, data.tree, controller.baseURL); $children.slideDown(); $node.data('children', $children); @@ -298,7 +301,7 @@ TreeNodeDetailController = { errorMessage: "Error", baseURL: "", ajaxURL: "ajax.php", - ajaxPage: "include/ajax/tree.ajax.php", + ajaxPage: "include/ajax/tree.ajax", container: '', reload: function () { // Label diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index e032158767..31bbda4342 100755 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -2895,6 +2895,10 @@ table#policy_modules td * { background-image: url(../../images/tree/first_leaf.png); } +.tree-node.leaf-error>.leaf-icon { + background-image: url(../../images/tree/last_leaf.png); +} + .tree-node>.leaf-icon { background-position: 0px 0px; background-repeat: no-repeat; diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index d20ee435cd..cf0b52f1da 100755 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -1056,8 +1056,7 @@ echo "
"; recipient: $("div#tree-controller-recipient"), detailRecipient: $("div#tree-controller-detail-recipient"), tree: tree, - baseURL: "", - ajaxURL: "/ajax.php", - ajaxPage: "/include/ajax/tree.ajax.php" + baseURL: "/", + ajaxURL: "/ajax.php" }); diff --git a/pandora_console/operation/tree2.php b/pandora_console/operation/tree2.php index 144f0793fd..74918881a8 100644 --- a/pandora_console/operation/tree2.php +++ b/pandora_console/operation/tree2.php @@ -139,7 +139,7 @@ echo ""; $.ajax({ type: "POST", - url: "", + url: "/ajax.php", data: parameters, success: function(data) { if (data.success) { @@ -148,7 +148,9 @@ echo ""; treeController.init({ recipient: $("div#tree-controller-recipient"), page: page, - tree: data.tree + tree: data.tree, + baseURL: "/", + ajaxURL: "/ajax.php" }); } },