diff --git a/pandora_console/include/ajax/tree.ajax.php b/pandora_console/include/ajax/tree.ajax.php index 448b4cfb71..c6e9670df8 100644 --- a/pandora_console/include/ajax/tree.ajax.php +++ b/pandora_console/include/ajax/tree.ajax.php @@ -40,6 +40,7 @@ if (is_ajax() === true) { include_once $config['homedir'].'/include/class/TreeGroup.class.php'; include_once $config['homedir'].'/include/class/TreeService.class.php'; include_once $config['homedir'].'/include/class/TreeGroupEdition.class.php'; + enterprise_include_once('include/class/TreeIPAMSupernet.class.php'); enterprise_include_once('include/class/TreePolicies.class.php'); enterprise_include_once('include/class/TreeGroupMeta.class.php'); include_once $config['homedir'].'/include/functions_reporting.php'; @@ -190,6 +191,18 @@ if (is_ajax() === true) { ); break; + case 'IPAM_supernets': + $tree = new TreeIPAMSupernet( + $type, + $rootType, + $id, + $rootID, + $serverID, + $childrenMethod, + $access + ); + break; + default: // No error handler. return; diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 898f389891..bc30d87f8c 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -159,6 +159,21 @@ var TreeController = { } }; + var IPAMSupernetCounterTitles = { + total_networks: { + totals: "Networks" + } + }; + + var IPAMNetworkCounterTitles = { + alive_ips: { + totals: "Alive IPs" + }, + total_ips: { + totals: "Total IPs" + } + }; + try { var title = ""; @@ -192,6 +207,12 @@ var TreeController = { case "services": title = serviceCounterTitles[counterType].totals; break; + case "IPAM_supernets": + title = IPAMSupernetCounterTitles[counterType].totals; + break; + case "IPAM_networks": + title = IPAMNetworkCounterTitles[counterType].totals; + break; default: if ( typeof controller.counterTitles != "undefined" && @@ -333,6 +354,113 @@ var TreeController = { hasCounters = true; } + } else if (type == "IPAM_supernets") { + var $counters = $("
"); + $counters.addClass("tree-node-counters"); + + if (counters.total_networks > 0) { + // Open the parentheses + $counters.append(" ("); + + if ( + typeof counters.total_networks !== "undefined" && + counters.total_networks >= 0 + ) { + var $networksCounter = $(""); + $networksCounter + .addClass("tree-node-counter") + .addClass("total") + .html(counters.total_networks); + + _processNodeCounterTitle( + $networksCounter, + type, + "total_networks" + ); + + $counters.append($networksCounter); + } else { + var $networksCounter = $(""); + $networksCounter + .addClass("tree-node-counter") + .addClass("total") + .html("0"); + + _processNodeCounterTitle( + $networksCounter, + type, + "total_networks" + ); + + $counters.append($networksCounter); + } + + // Close the parentheses + $counters.append(")"); + + hasCounters = true; + } + } else if (type == "IPAM_networks") { + var $counters = $(""); + $counters.addClass("tree-node-counters"); + + // Open the parentheses + $counters.append(" ("); + + if ( + typeof counters.alive_ips !== "undefined" && + counters.alive_ips >= 0 + ) { + var $aliveCounter = $(""); + $aliveCounter + .addClass("tree-node-counter") + .addClass("total") + .html(counters.alive_ips); + + _processNodeCounterTitle($aliveCounter, type, "alive_ips"); + + $counters.append($aliveCounter); + } else { + var $aliveCounter = $(""); + $aliveCounter + .addClass("tree-node-counter") + .addClass("total") + .html("0"); + + _processNodeCounterTitle($aliveCounter, type, "alive_ips"); + + $counters.append($aliveCounter); + } + + if ( + typeof counters.total_ips !== "undefined" && + counters.total_ips >= 0 + ) { + var $totalCounter = $(""); + $totalCounter + .addClass("tree-node-counter") + .addClass("total") + .html(counters.total_ips); + + _processNodeCounterTitle($totalCounter, type, "total_ips"); + + $counters.append(" : ").append($totalCounter); + } else { + var $totalCounter = $(""); + $totalCounter + .addClass("tree-node-counter") + .addClass("total") + .html("0"); + + _processNodeCounterTitle($totalCounter, type, "total_ips"); + + $counters.append(" : ").append($totalCounter); + } + + // Close the parentheses + $counters.append(")"); + + hasCounters = true; } else { var $counters = $(""); $counters.addClass("tree-node-counters"); @@ -637,6 +765,87 @@ var TreeController = { } $content.append(" " + element.alias); + break; + case "IPAM_supernets": + var IPAMSupernetDetailImage = $( + ' ' + ); + + if (typeof element.id !== "undefined") { + IPAMSupernetDetailImage.click(function(e) { + e.preventDefault(); + + var postData = { + page: "enterprise/include/ajax/ipam.ajax", + show_networkmap_statistics: 1, + "node_data[id_net]": element.id, + "node_data[type_net]": "supernet" + }; + + $.ajax({ + url: controller.ajaxURL, + type: "POST", + dataType: "html", + data: postData, + success: function(data, textStatus, xhr) { + controller.detailRecipient + .render("IPAMsupernets", data) + .open(); + } + }); + }).css("cursor", "pointer"); + + $content.append(IPAMSupernetDetailImage); + } + + if (element.name !== null) { + $content.append(" " + element.name); + } + + break; + case "IPAM_networks": + $content.addClass("ipam-network"); + + var IPAMNetworkDetailImage = $( + ' ' + ); + + if (typeof element.id !== "undefined") { + IPAMNetworkDetailImage.click(function(e) { + e.preventDefault(); + + //window.location.href = element.IPAMNetworkDetail; + var postData = { + page: "enterprise/include/ajax/ipam.ajax", + show_networkmap_statistics: 1, + "node_data[id_net]": element.id, + "node_data[type_net]": "network" + }; + + $.ajax({ + url: controller.ajaxURL, + type: "POST", + dataType: "html", + data: postData, + success: function(data, textStatus, xhr) { + controller.detailRecipient + .render("IPAMnetwork", data) + .open(); + } + }); + }).css("cursor", "pointer"); + + $content.append(IPAMNetworkDetailImage); + } + + if (element.name !== null) { + $content.append(" " + element.name); + } + break; case "services": if ( @@ -960,7 +1169,7 @@ var TreeController = { return; } } - // If exist the detail container, show the data + // If detail container exists, show the data. if ( typeof controller.detailRecipient !== "undefined" || disabled == false diff --git a/pandora_console/include/styles/tree.css b/pandora_console/include/styles/tree.css index c4cdf7d276..08b1d635ed 100644 --- a/pandora_console/include/styles/tree.css +++ b/pandora_console/include/styles/tree.css @@ -189,3 +189,7 @@ div#tree-controller-recipient { .tree-node .disabled { filter: opacity(0.3); } + +.ipam-network { + font-size: 9pt; +}