mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
New networkmaps in progress... (Fixed problems in Open part)
This commit is contained in:
parent
c643e2bce0
commit
cbef0f3dfd
@ -1127,6 +1127,38 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||||||
$graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom,
|
$graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom,
|
||||||
$ranksep, $font_size, $size_canvas);
|
$ranksep, $font_size, $size_canvas);
|
||||||
|
|
||||||
|
//The orphans
|
||||||
|
if ($l2_network || $old_mode) {
|
||||||
|
$count = 0;
|
||||||
|
$group_nodes = 10;
|
||||||
|
$graph .= networkmap_create_transparent_node($count);
|
||||||
|
foreach (array_keys($networkmap_data['orphans']) as $node) {
|
||||||
|
if ($group_nodes == 0) {
|
||||||
|
$count++;
|
||||||
|
$graph .= networkmap_create_transparent_node($count);
|
||||||
|
|
||||||
|
$group_nodes = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
$graph .= networkmap_create_transparent_edge('transp_' . $count,
|
||||||
|
$node);
|
||||||
|
|
||||||
|
$group_nodes--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Create a central node if orphan nodes exist
|
||||||
|
if (count ($networkmap_data['$orphans']) || empty ($nodes)) {
|
||||||
|
$graph .= networkmap_create_pandora_node ($pandora_name, $font_size, $simple, $stats);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Define edges for orphan nodes
|
||||||
|
foreach (array_keys($networkmap_data['orphans']) as $node) {
|
||||||
|
$graph .= networkmap_create_edge ('0', $node, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'topology', $id_networkmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Create nodes
|
// Create nodes
|
||||||
foreach ($networkmap_data['nodes'] as $node_id => $node) {
|
foreach ($networkmap_data['nodes'] as $node_id => $node) {
|
||||||
switch ($node['type']) {
|
switch ($node['type']) {
|
||||||
@ -1183,37 +1215,6 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//The orphans
|
|
||||||
if ($l2_network || $old_mode) {
|
|
||||||
$count = 0;
|
|
||||||
$group_nodes = 10;
|
|
||||||
$graph .= networkmap_create_transparent_node($count);
|
|
||||||
foreach (array_keys($networkmap_data['orphans']) as $node) {
|
|
||||||
if ($group_nodes == 0) {
|
|
||||||
$count++;
|
|
||||||
$graph .= networkmap_create_transparent_node($count);
|
|
||||||
|
|
||||||
$group_nodes = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
$graph .= networkmap_create_transparent_edge('transp_' . $count,
|
|
||||||
$node);
|
|
||||||
|
|
||||||
$group_nodes--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Create a central node if orphan nodes exist
|
|
||||||
if (count ($networkmap_data['$orphans']) || empty ($nodes)) {
|
|
||||||
$graph .= networkmap_create_pandora_node ($pandora_name, $font_size, $simple, $stats);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define edges for orphan nodes
|
|
||||||
foreach (array_keys($networkmap_data['orphans']) as $node) {
|
|
||||||
$graph .= networkmap_create_edge ('0', $node, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'topology', $id_networkmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
// Close graph
|
// Close graph
|
||||||
$graph .= networkmap_close_graph ();
|
$graph .= networkmap_close_graph ();
|
||||||
|
|
||||||
|
@ -178,32 +178,36 @@ function networkmap_process_networkmap($id = 0) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$nodes_and_relations['nodes'] = array();
|
$nodes_and_relations['nodes'] = array();
|
||||||
|
$index = 0;
|
||||||
foreach ($nodes as $key => $node) {
|
foreach ($nodes as $key => $node) {
|
||||||
$nodes_and_relations['nodes'][]['id_map'] = $id;
|
$nodes_and_relations['nodes'][$index]['id_map'] = $id;
|
||||||
$nodes_and_relations['nodes'][]['x'] = (int)$node['coords'][0];
|
$nodes_and_relations['nodes'][$index]['x'] = (int)$node['coords'][0];
|
||||||
$nodes_and_relations['nodes'][]['y'] = (int)$node['coords'][1];
|
$nodes_and_relations['nodes'][$index]['y'] = (int)$node['coords'][1];
|
||||||
$nodes_and_relations['nodes'][]['type'] = $node['type'];
|
$nodes_and_relations['nodes'][$index]['type'] = $node['type'];
|
||||||
$style['shape'] = 'circle';
|
$style['shape'] = 'circle';
|
||||||
$style['image'] = $node['image'];
|
$style['image'] = $node['image'];
|
||||||
$style['width'] = $node['width'];
|
$style['width'] = $node['width'];
|
||||||
$style['height'] = $node['height'];
|
$style['height'] = $node['height'];
|
||||||
$style['label'] = $node['text'];
|
$style['label'] = $node['text'];
|
||||||
$nodes_and_relations['nodes'][]['style'] = json_encode($style);
|
$nodes_and_relations['nodes'][$index]['style'] = json_encode($style);
|
||||||
if ($node['type'] == 'agent') {
|
if ($node['type'] == 'agent') {
|
||||||
$nodes_and_relations['nodes'][]['source_data'] = $node['id_agent'];
|
$nodes_and_relations['nodes'][$index]['source_data'] = $node['id_agent'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$nodes_and_relations['nodes'][]['source_data'] = $node['id_module'];
|
$nodes_and_relations['nodes'][$index]['source_data'] = $node['id_module'];
|
||||||
}
|
}
|
||||||
|
$index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$index = 0;
|
||||||
$nodes_and_relations['relations'] = array();
|
$nodes_and_relations['relations'] = array();
|
||||||
foreach ($relation_nodes as $relation) {
|
foreach ($relation_nodes as $relation) {
|
||||||
$nodes_and_relations['relations'][]['id_map'] = $id;
|
$nodes_and_relations['relations'][$index]['id_map'] = $id;
|
||||||
$nodes_and_relations['relations'][]['id_parent'] = $array_key_to_db_id[$relation['parent']];
|
$nodes_and_relations['relations'][$index]['id_parent'] = $relation['id_parent'];
|
||||||
$nodes_and_relations['relations'][]['id_child'] = $array_key_to_db_id[$relation['child']];
|
$nodes_and_relations['relations'][$index]['id_child'] = $relation['id_child'];
|
||||||
$nodes_and_relations['relations'][]['parent_type'] = $relation['parent_type'];
|
$nodes_and_relations['relations'][$index]['parent_type'] = $relation['parent_type'];
|
||||||
$nodes_and_relations['relations'][]['child_type'] = $relation['child_type'];
|
$nodes_and_relations['relations'][$index]['child_type'] = $relation['child_type'];
|
||||||
|
$index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$center = array('x' => 500, 'y' => 500);
|
$center = array('x' => 500, 'y' => 500);
|
||||||
@ -450,8 +454,8 @@ function networkmap_links_to_js_links($relations, $nodes_graph) {
|
|||||||
$item['id_module_start'] = $id_source;
|
$item['id_module_start'] = $id_source;
|
||||||
$item['text_start'] = io_safe_output(modules_get_agentmodule_name($item['id_module_start']));
|
$item['text_start'] = io_safe_output(modules_get_agentmodule_name($item['id_module_start']));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($nodes_graph as $node) {
|
foreach ($nodes_graph as $node) {
|
||||||
|
if (enterprise_installed()) {
|
||||||
if ($node['id_db'] == $relation['id_parent']) {
|
if ($node['id_db'] == $relation['id_parent']) {
|
||||||
$item['target'] = $node['id'];
|
$item['target'] = $node['id'];
|
||||||
}
|
}
|
||||||
@ -459,6 +463,15 @@ function networkmap_links_to_js_links($relations, $nodes_graph) {
|
|||||||
$item['source'] = $node['id'];
|
$item['source'] = $node['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if ($node['id'] == $relation['id_parent']) {
|
||||||
|
$item['target'] = $node['id'];
|
||||||
|
}
|
||||||
|
else if ($node['id'] == $relation['id_child']) {
|
||||||
|
$item['source'] = $node['id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$return[] = $item;
|
$return[] = $item;
|
||||||
}
|
}
|
||||||
@ -471,6 +484,8 @@ function networkmap_write_js_array($id, $nodes_and_relations = array()) {
|
|||||||
|
|
||||||
db_clean_cache();
|
db_clean_cache();
|
||||||
|
|
||||||
|
$ent_installed = (int)enterprise_installed();
|
||||||
|
|
||||||
$networkmap = db_get_row('tmap', 'id', $id);
|
$networkmap = db_get_row('tmap', 'id', $id);
|
||||||
|
|
||||||
$networkmap['filter'] = json_decode($networkmap['filter'], true);
|
$networkmap['filter'] = json_decode($networkmap['filter'], true);
|
||||||
@ -497,7 +512,7 @@ function networkmap_write_js_array($id, $nodes_and_relations = array()) {
|
|||||||
$networkmap['width'] . ", " .
|
$networkmap['width'] . ", " .
|
||||||
$networkmap['height'] . "];\n";
|
$networkmap['height'] . "];\n";
|
||||||
|
|
||||||
echo "var enterprise_installed = " . enterprise_installed() . ";\n";
|
echo "var enterprise_installed = " . $ent_installed . ";\n";
|
||||||
|
|
||||||
echo "var networkmap_holding_area_dimensions = " .
|
echo "var networkmap_holding_area_dimensions = " .
|
||||||
json_encode($networkmap['filter']['holding_area']) . ";\n";
|
json_encode($networkmap['filter']['holding_area']) . ";\n";
|
||||||
@ -519,6 +534,7 @@ function networkmap_write_js_array($id, $nodes_and_relations = array()) {
|
|||||||
$count_item_holding_area = 0;
|
$count_item_holding_area = 0;
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$nodes_graph = array();
|
$nodes_graph = array();
|
||||||
|
|
||||||
foreach ($nodes as $key => $node) {
|
foreach ($nodes as $key => $node) {
|
||||||
$style = json_decode($node['style'], true);
|
$style = json_decode($node['style'], true);
|
||||||
$node['style'] = json_decode($node['style'], true);
|
$node['style'] = json_decode($node['style'], true);
|
||||||
@ -1070,7 +1086,6 @@ function show_networkmap($id = 0, $user_readonly = false, $nodes_and_relations =
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
<?php
|
<?php
|
||||||
networkmap_write_js_array($id, $nodes_and_relations);
|
networkmap_write_js_array($id, $nodes_and_relations);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// document ready
|
// document ready
|
||||||
|
@ -30,7 +30,6 @@ function draw_minimap() {
|
|||||||
context_minimap.fill();
|
context_minimap.fill();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//Draw the rect of viewport
|
//Draw the rect of viewport
|
||||||
context_minimap.beginPath();
|
context_minimap.beginPath();
|
||||||
context_minimap.strokeStyle = "#f00";
|
context_minimap.strokeStyle = "#f00";
|
||||||
@ -1375,6 +1374,14 @@ function show_menu(item, data) {
|
|||||||
items_list["add_node"] = {
|
items_list["add_node"] = {
|
||||||
name: add_node_menu,
|
name: add_node_menu,
|
||||||
icon: "add_node",
|
icon: "add_node",
|
||||||
|
disabled : function() {
|
||||||
|
if (enterprise_installed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
},
|
||||||
"callback": function(key, options) {
|
"callback": function(key, options) {
|
||||||
add_node();
|
add_node();
|
||||||
}
|
}
|
||||||
@ -1825,8 +1832,6 @@ function add_fictional_node() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init_graph(parameter_object) {
|
function init_graph(parameter_object) {
|
||||||
console.log(parameter_object);
|
|
||||||
|
|
||||||
window.width_svg = $("#networkconsole").width();
|
window.width_svg = $("#networkconsole").width();
|
||||||
if ($("#main").height()) {
|
if ($("#main").height()) {
|
||||||
window.height_svg = $("#main").height();
|
window.height_svg = $("#main").height();
|
||||||
@ -2142,7 +2147,7 @@ function init_graph(parameter_object) {
|
|||||||
"stroke-dasharray: none;")
|
"stroke-dasharray: none;")
|
||||||
.on("contextmenu", function(d) { show_menu("background", d);});
|
.on("contextmenu", function(d) { show_menu("background", d);});
|
||||||
|
|
||||||
|
if (enterprise_installed) {
|
||||||
window.layer_graph.append("rect")
|
window.layer_graph.append("rect")
|
||||||
.attr("id", "holding_area")
|
.attr("id", "holding_area")
|
||||||
.attr("width", holding_area_dimensions[0])
|
.attr("width", holding_area_dimensions[0])
|
||||||
@ -2179,6 +2184,7 @@ function init_graph(parameter_object) {
|
|||||||
.attr("x", networkmap_dimensions[0] + node_radius - holding_area_dimensions[0])
|
.attr("x", networkmap_dimensions[0] + node_radius - holding_area_dimensions[0])
|
||||||
.attr("y", networkmap_dimensions[1] + node_radius - holding_area_dimensions[1])
|
.attr("y", networkmap_dimensions[1] + node_radius - holding_area_dimensions[1])
|
||||||
.text(holding_area_title);
|
.text(holding_area_title);
|
||||||
|
}
|
||||||
|
|
||||||
window.layer_graph_links = window.layer_graph
|
window.layer_graph_links = window.layer_graph
|
||||||
.append("g")
|
.append("g")
|
||||||
|
@ -17,7 +17,7 @@ global $config;
|
|||||||
check_login();
|
check_login();
|
||||||
|
|
||||||
require_once ('include/functions_pandora_networkmap.php');
|
require_once ('include/functions_pandora_networkmap.php');
|
||||||
require_once ('enterprise/include/functions_policies.php');
|
enterprise_include_once('include/functions_policies.php');
|
||||||
require_once ('include/functions_modules.php');
|
require_once ('include/functions_modules.php');
|
||||||
|
|
||||||
//--------------INIT AJAX-----------------------------------------------
|
//--------------INIT AJAX-----------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user