From a2d36a65f6d62985ebb04dfea853937491030284 Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Thu, 18 Dec 2014 18:13:22 +0100 Subject: [PATCH] Added new info to the tree --- pandora_console/include/ajax/tree.ajax.php | 2 +- .../include/javascript/tree/TreeController.js | 67 ++++++++++++++++++- 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/ajax/tree.ajax.php b/pandora_console/include/ajax/tree.ajax.php index 28f5a14f79..bdd209c033 100644 --- a/pandora_console/include/ajax/tree.ajax.php +++ b/pandora_console/include/ajax/tree.ajax.php @@ -77,7 +77,7 @@ if (is_ajax ()) { elseif ($data["monitor_warning"] > 0) { $status['status'] = 'warning'; } - elseif (($data["monitor_unknown"] > 0) || ($data["agents_unknown"] > 0)) { + elseif (($data["monitor_unknown"] > 0) || ($data["agents_unknown"] > 0)) { $status['status'] = 'unknown'; } elseif ($data["monitor_ok"] > 0) { diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index afe319be9d..bd37a5294d 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -79,15 +79,76 @@ TreeController = { $content.addClass("node-content"); switch (element.type) { case 'group': + if (typeof element.icon != 'undefined' && element.icon.length > 0) { + $content.append('') + } $content.append(element.name); break; case 'agent': $content.append(element.name); + case 'module': + $content.append(element.name); break; default: $content.append(element.name); break; } + + // Load the status counters + if (typeof element.counters != 'undefined' && element.counters.length > 0) { + var $counters = $("
"); + $counters.addClass('tree-node-counters'); + + + $content.append($counters); + } + // Load the counters asynchronously + else if (typeof element.searchCounters != 'undefined' && element.searchCounters) { + var $counters = $("
"); + $counters + .addClass('tree-node-counters') + .append(' (') + .append('') + .append(')'); + + // $.ajax({ + // url: controller.ajaxURL, + // type: 'POST', + // dataType: 'json', + // data: { + // page: controller.ajaxPage, + // getChildren: 1, + // id: element.id, + // type: element.type, + // filter: controller.filter + // }, + // complete: function(xhr, textStatus) { + + // }, + // success: function(data, textStatus, xhr) { + // if (data.success) { + + // if (typeof data.counters != 'undefined' && data.counters.length > 0) { + + // } + // else { + + // } + // } + // else { + + // } + // }, + // error: function(xhr, textStatus, errorThrown) { + + // } + // }); + + + $content.append($counters); + } + // If exist the detail container, show the data if (typeof controller.detailRecipient != 'undefined' && controller.detailRecipient.length > 0) { $content.click(function (e) { @@ -123,7 +184,9 @@ TreeController = { var $children = _processGroup($node, element.tree); $node.data('children', $children); - $leafIcon.click(function () { + $leafIcon.click(function (e) { + e.preventDefault(); + if ($node.hasClass("leaf-open")) { $node .removeClass("leaf-open") @@ -165,7 +228,7 @@ TreeController = { }, complete: function(xhr, textStatus) { $node.removeClass("leaf-loading"); - $node.addClass("children-loaded") + $node.addClass("children-loaded"); }, success: function(data, textStatus, xhr) { if (data.success) {