Merge branch 'ent-5193-IPAM-Supernet-Map-Tree-View' into 'develop'

implemented supernet treeview

See merge request artica/pandorafms!4431
This commit is contained in:
Daniel Rodriguez 2021-09-29 10:10:26 +00:00
commit 04d683286f
3 changed files with 227 additions and 1 deletions

View File

@ -40,6 +40,7 @@ if (is_ajax() === true) {
include_once $config['homedir'].'/include/class/TreeGroup.class.php'; include_once $config['homedir'].'/include/class/TreeGroup.class.php';
include_once $config['homedir'].'/include/class/TreeService.class.php'; include_once $config['homedir'].'/include/class/TreeService.class.php';
include_once $config['homedir'].'/include/class/TreeGroupEdition.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/TreePolicies.class.php');
enterprise_include_once('include/class/TreeGroupMeta.class.php'); enterprise_include_once('include/class/TreeGroupMeta.class.php');
include_once $config['homedir'].'/include/functions_reporting.php'; include_once $config['homedir'].'/include/functions_reporting.php';
@ -190,6 +191,18 @@ if (is_ajax() === true) {
); );
break; break;
case 'IPAM_supernets':
$tree = new TreeIPAMSupernet(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
break;
default: default:
// No error handler. // No error handler.
return; return;

View File

@ -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 { try {
var title = ""; var title = "";
@ -192,6 +207,12 @@ var TreeController = {
case "services": case "services":
title = serviceCounterTitles[counterType].totals; title = serviceCounterTitles[counterType].totals;
break; break;
case "IPAM_supernets":
title = IPAMSupernetCounterTitles[counterType].totals;
break;
case "IPAM_networks":
title = IPAMNetworkCounterTitles[counterType].totals;
break;
default: default:
if ( if (
typeof controller.counterTitles != "undefined" && typeof controller.counterTitles != "undefined" &&
@ -333,6 +354,113 @@ var TreeController = {
hasCounters = true; hasCounters = true;
} }
} else if (type == "IPAM_supernets") {
var $counters = $("<div></div>");
$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 = $("<div></div>");
$networksCounter
.addClass("tree-node-counter")
.addClass("total")
.html(counters.total_networks);
_processNodeCounterTitle(
$networksCounter,
type,
"total_networks"
);
$counters.append($networksCounter);
} else {
var $networksCounter = $("<div></div>");
$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 = $("<div></div>");
$counters.addClass("tree-node-counters");
// Open the parentheses
$counters.append(" (");
if (
typeof counters.alive_ips !== "undefined" &&
counters.alive_ips >= 0
) {
var $aliveCounter = $("<div></div>");
$aliveCounter
.addClass("tree-node-counter")
.addClass("total")
.html(counters.alive_ips);
_processNodeCounterTitle($aliveCounter, type, "alive_ips");
$counters.append($aliveCounter);
} else {
var $aliveCounter = $("<div></div>");
$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 = $("<div></div>");
$totalCounter
.addClass("tree-node-counter")
.addClass("total")
.html(counters.total_ips);
_processNodeCounterTitle($totalCounter, type, "total_ips");
$counters.append(" : ").append($totalCounter);
} else {
var $totalCounter = $("<div></div>");
$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 { } else {
var $counters = $("<div></div>"); var $counters = $("<div></div>");
$counters.addClass("tree-node-counters"); $counters.addClass("tree-node-counters");
@ -637,6 +765,87 @@ var TreeController = {
} }
$content.append(" " + element.alias); $content.append(" " + element.alias);
break;
case "IPAM_supernets":
var IPAMSupernetDetailImage = $(
'<img class="invert_filter" src="' +
(controller.baseURL.length > 0 ? controller.baseURL : "") +
'images/transactional_map.png" /> '
);
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("&nbsp;&nbsp;&nbsp;" + element.name);
}
break;
case "IPAM_networks":
$content.addClass("ipam-network");
var IPAMNetworkDetailImage = $(
'<img class="invert_filter" src="' +
(controller.baseURL.length > 0 ? controller.baseURL : "") +
'images/list.png" /> '
);
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("&nbsp;&nbsp;&nbsp;" + element.name);
}
break; break;
case "services": case "services":
if ( if (
@ -960,7 +1169,7 @@ var TreeController = {
return; return;
} }
} }
// If exist the detail container, show the data // If detail container exists, show the data.
if ( if (
typeof controller.detailRecipient !== "undefined" || typeof controller.detailRecipient !== "undefined" ||
disabled == false disabled == false

View File

@ -189,3 +189,7 @@ div#tree-controller-recipient {
.tree-node .disabled { .tree-node .disabled {
filter: opacity(0.3); filter: opacity(0.3);
} }
.ipam-network {
font-size: 9pt;
}