New networkmaps in progress... (Moved E code to E section and removed nun dependences)
This commit is contained in:
parent
249f81da7e
commit
5d987ed066
|
@ -372,12 +372,14 @@ function networkmap_get_nodes_and_links($pandora_name, $group = 0,
|
|||
|
||||
// Get policy data
|
||||
if ($show_policies) {
|
||||
if (enterprise_installed()) {
|
||||
enterprise_include_once("include/functions_pandora_networkmap.php");
|
||||
|
||||
$policies = networkmap_get_policies(array($group));
|
||||
|
||||
$agents = networkmap_filter_agents_policies(array($policies, $agents));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Get groups data
|
||||
if ($show_groups) {
|
||||
|
|
|
@ -10,40 +10,6 @@
|
|||
// You cannnot redistribute it without written permission of copyright holder.
|
||||
// ============================================================================
|
||||
|
||||
function networkmap_get_policies($id_group) {
|
||||
enterprise_include_once("include/functions_policies.php");
|
||||
|
||||
$filter_policy = array();
|
||||
$filter_policy['id_group'] = $id_group;
|
||||
|
||||
$policies = policies_get_policies($filter_policy);
|
||||
if ($policies === false) {
|
||||
$policies = array();
|
||||
}
|
||||
|
||||
return $policies;
|
||||
}
|
||||
|
||||
function networkmap_filter_agents_policies($policies, $agents) {
|
||||
enterprise_include_once("include/functions_policies.php");
|
||||
|
||||
$temp = array();
|
||||
foreach ($policies as $policy) {
|
||||
foreach ($agents as $i => $agent) {
|
||||
$exists = (bool)db_get_value_filter(
|
||||
'id', 'tpolicy_agents',
|
||||
array('id_agent' => $agent['id_agente'],
|
||||
'id_policy' => $policy['id']));
|
||||
|
||||
if ($exists) {
|
||||
$temp[] = $agent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $temp;
|
||||
}
|
||||
|
||||
function networkmap_delete_networkmap($id = 0) {
|
||||
// Relations
|
||||
$result = db_process_sql_delete('trel_item', array('id_map' => $id));
|
||||
|
@ -109,14 +75,6 @@ function networkmap_process_networkmap($id = 0) {
|
|||
if (isset($options['l2_network_interfaces']))
|
||||
$l2_network_interfaces = (bool)$options['l2_network_interfaces'];
|
||||
*/
|
||||
// --------- DEPRECATED --------------------------------------------
|
||||
// NO CONTEMPLADO
|
||||
$old_mode = false;
|
||||
/*
|
||||
if (isset($options['old_mode']))
|
||||
$old_mode = (bool)$options['old_mode'];
|
||||
*/
|
||||
// --------- END DEPRECATED ----------------------------------------
|
||||
|
||||
// NO CONTEMPLADO
|
||||
$dont_show_subgroups = false;
|
||||
|
@ -210,72 +168,9 @@ function networkmap_process_networkmap($id = 0) {
|
|||
|
||||
$nodes_and_relations = array();
|
||||
if (enterprise_installed()) {
|
||||
$array_key_to_db_id = array();
|
||||
foreach ($nodes as $key => $node) {
|
||||
$values = array();
|
||||
$values['id_map'] = $id;
|
||||
$values['x'] = (int)$node['coords'][0];
|
||||
$values['y'] = (int)$node['coords'][1];
|
||||
//$values['parent'] = 0;
|
||||
$style = array();
|
||||
if ($l2_network_interfaces) {
|
||||
$values['type'] = $node['type'];
|
||||
if ($node['type'] == 'agent') {
|
||||
switch (os_get_name(agents_get_os($node['id_agent']))) {
|
||||
case 'Router':
|
||||
$style['shape'] = 'circle';
|
||||
break;
|
||||
case 'Switch':
|
||||
$style['shape'] = 'circle';
|
||||
break;
|
||||
default:
|
||||
$style['shape'] = 'circle';
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$style['shape'] = 'arrowhead';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$style['shape'] = 'circle';
|
||||
}
|
||||
$style['image'] = $node['image'];
|
||||
$style['width'] = $node['width'];
|
||||
$style['height'] = $node['height'];
|
||||
$style['label'] = $node['text'];
|
||||
enterprise_include_once("include/functions_pandora_networkmap.php");
|
||||
|
||||
$values['style'] = json_encode($style);
|
||||
if ($node['type'] == 'agent') {
|
||||
$values['source_data'] = $node['id_agent'];
|
||||
}
|
||||
else {
|
||||
$values['source_data'] = $node['id_module'];
|
||||
}
|
||||
|
||||
$id_or_result = db_process_sql_insert(
|
||||
'titem', $values);
|
||||
|
||||
if ($id_or_result !== false) {
|
||||
$id_node = $id_or_result;
|
||||
$array_key_to_db_id[$key] = $id_node;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($relation_nodes as $relation) {
|
||||
$values = array();
|
||||
|
||||
$values['id_map'] = $id;
|
||||
$values['id_parent'] = $array_key_to_db_id[$relation['id_parent']];
|
||||
$values['id_child'] = $array_key_to_db_id[$relation['id_child']];
|
||||
$values['parent_type'] = $relation['parent_type'];
|
||||
$values['child_type'] = $relation['child_type'];
|
||||
db_process_sql_insert('trel_item', $values);
|
||||
}
|
||||
|
||||
//-------Set center map---------------------------------------------
|
||||
$center = db_get_row('titem', 'id_map', $id);
|
||||
$center = save_generate_nodes($id, $nodes, $relation_nodes);
|
||||
}
|
||||
else {
|
||||
$nodes_and_relations['nodes'] = array();
|
||||
|
@ -438,6 +333,34 @@ function networkmap_db_node_to_js_node($node, &$count, &$count_item_holding_area
|
|||
return $item;
|
||||
}
|
||||
|
||||
function get_status_color_networkmap($id, $color = true) {
|
||||
$status = agents_get_status($id);
|
||||
|
||||
if (!$color) {
|
||||
return $status;
|
||||
}
|
||||
// Set node status
|
||||
switch($status) {
|
||||
case 0:
|
||||
$status_color = COL_NORMAL; // Normal monitor
|
||||
break;
|
||||
case 1:
|
||||
$status_color = COL_CRITICAL; // Critical monitor
|
||||
break;
|
||||
case 2:
|
||||
$status_color = COL_WARNING; // Warning monitor
|
||||
break;
|
||||
case 4:
|
||||
$status_color = COL_ALERTFIRED; // Alert fired
|
||||
break;
|
||||
default:
|
||||
$status_color = COL_UNKNOWN; // Unknown monitor
|
||||
break;
|
||||
}
|
||||
|
||||
return $status_color;
|
||||
}
|
||||
|
||||
function networkmap_clean_relations_for_js(&$relations) {
|
||||
do {
|
||||
$cleaned = true;
|
||||
|
@ -564,8 +487,9 @@ function networkmap_write_js_array($id, $nodes_and_relations = array()) {
|
|||
echo "var networkmap = {'nodes': [], 'links': []};\n";
|
||||
|
||||
if (enterprise_installed()) {
|
||||
$nodes = db_get_all_rows_filter('titem',
|
||||
array('id_map' => $id, 'deleted' => 0));
|
||||
enterprise_include_once("include/functions_pandora_networkmap.php");
|
||||
|
||||
$nodes = get_nodes_from_db($id);
|
||||
}
|
||||
else {
|
||||
$nodes = $nodes_and_relations['nodes'];
|
||||
|
@ -597,19 +521,9 @@ function networkmap_write_js_array($id, $nodes_and_relations = array()) {
|
|||
}
|
||||
|
||||
if (enterprise_installed()) {
|
||||
$relations = db_get_all_rows_sql("
|
||||
SELECT t1.*,
|
||||
(SELECT t2.source_data
|
||||
FROM titem t2
|
||||
WHERE t2.id_map = " . $id . "
|
||||
AND t2.id = t1.id_parent) AS id_agent_parent,
|
||||
enterprise_include_once("include/functions_pandora_networkmap.php");
|
||||
|
||||
(SELECT t2.source_data
|
||||
FROM titem t2
|
||||
WHERE t2.id_map = " . $id . "
|
||||
AND t2.id = t1.id_child) AS id_agent_child
|
||||
FROM trel_item t1
|
||||
WHERE t1.deleted = 0 AND t1.id_map = " . $id);
|
||||
$relations = get_relations_from_db($id);
|
||||
}
|
||||
else {
|
||||
$relations = $nodes_and_relations['relations'];
|
||||
|
@ -870,44 +784,6 @@ function update_node($node) {
|
|||
return $return;
|
||||
}
|
||||
|
||||
function erase_node($id) {
|
||||
$node = db_get_row('titem', 'id', $id['id']);
|
||||
|
||||
//For networkmaps of Level 2
|
||||
$nodes = db_get_all_rows_filter('titem',
|
||||
array(
|
||||
'id_map' => $node['id_map'],
|
||||
'source_data' => $node['source_data'],
|
||||
'type' => $node['type'],
|
||||
'id' => $id['id']
|
||||
));
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
db_process_sql_update('titem',
|
||||
array('deleted' => 1), array('id' => (int)$node['id'], 'type' => (int)$node['type']));
|
||||
|
||||
db_process_sql_update('trel_item',
|
||||
array('deleted' => 1), array('id_parent' => (int)$node['id']));
|
||||
db_process_sql_update('trel_item',
|
||||
array('deleted' => 1), array('id_child' => (int)$node['id']));
|
||||
}
|
||||
|
||||
db_process_sql_update('trel_item',
|
||||
array('deleted' => 1), array('id_parent' => (int)$node['id']));
|
||||
db_process_sql_update('trel_item',
|
||||
array('deleted' => 1), array('id_child' => (int)$node['id']));
|
||||
|
||||
$return = db_process_sql_update('titem',
|
||||
array('deleted' => 1), array('id' => (int)$node['id'], 'type' => (int)$node['type']));
|
||||
|
||||
if ($return === false) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function networkmap_delete_nodes_by_agent($id_agent) {
|
||||
$rows = db_get_all_rows_filter('titem',
|
||||
array('source_data' => $id_agent));
|
||||
|
@ -925,272 +801,6 @@ function networkmap_delete_nodes_by_agent($id_agent) {
|
|||
array('source_data' => $id_agent));
|
||||
}
|
||||
|
||||
function get_status_color_networkmap_fictional_point($id_networkmap, $parent = null) {
|
||||
$last_status = 0;
|
||||
|
||||
if ($id_networkmap != 0) {
|
||||
$agents = db_get_all_rows_filter('titem',
|
||||
array('id_map' => $id_networkmap));
|
||||
if ($agents == false)
|
||||
$agents = array();
|
||||
|
||||
$exit = false;
|
||||
foreach ($agents as $agent) {
|
||||
if ($agent['source_data'] == -1) continue;
|
||||
if ($agent['source_data'] == -2) {
|
||||
if (empty($parent)) {
|
||||
$option = json_decode($agent, true);
|
||||
if ($option['networkmap'] == 0) {
|
||||
$status = 0;
|
||||
}
|
||||
else {
|
||||
$status = get_status_color_networkmap($option['networkmap'], true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//TODO Calculate next levels.
|
||||
$status = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$status = get_status_color_networkmap($agent['source_data'], false);
|
||||
}
|
||||
|
||||
switch($status) {
|
||||
case 0:
|
||||
// Normal monitor
|
||||
break;
|
||||
case 1:
|
||||
// Critical monitor
|
||||
$last_status = 1;
|
||||
$exit = true;
|
||||
break;
|
||||
case 2:
|
||||
// Warning monitor
|
||||
$last_status = 2;
|
||||
break;
|
||||
case 4:
|
||||
if ($last_status != 2) {
|
||||
$last_status = 4;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Unknown monitor
|
||||
if (($last_status != 2) && ($last_status != 4)) {
|
||||
$last_status = $status;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ($exit) break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($parent)) {
|
||||
switch($last_status) {
|
||||
case 0:
|
||||
$status_color = COL_NORMAL; // Normal monitor
|
||||
break;
|
||||
case 1:
|
||||
$status_color = COL_CRITICAL; // Critical monitor
|
||||
break;
|
||||
case 2:
|
||||
$status_color = COL_WARNING; // Warning monitor
|
||||
break;
|
||||
case 4:
|
||||
$status_color = COL_ALERTFIRED; // Alert fired
|
||||
break;
|
||||
default:
|
||||
$status_color = COL_UNKNOWN; // Unknown monitor
|
||||
break;
|
||||
}
|
||||
|
||||
return $status_color;
|
||||
}
|
||||
else {
|
||||
return $last_status;
|
||||
}
|
||||
}
|
||||
|
||||
function get_status_color_networkmap($id, $color = true) {
|
||||
$status = agents_get_status($id);
|
||||
|
||||
if (!$color) {
|
||||
return $status;
|
||||
}
|
||||
// Set node status
|
||||
switch($status) {
|
||||
case 0:
|
||||
$status_color = COL_NORMAL; // Normal monitor
|
||||
break;
|
||||
case 1:
|
||||
$status_color = COL_CRITICAL; // Critical monitor
|
||||
break;
|
||||
case 2:
|
||||
$status_color = COL_WARNING; // Warning monitor
|
||||
break;
|
||||
case 4:
|
||||
$status_color = COL_ALERTFIRED; // Alert fired
|
||||
break;
|
||||
default:
|
||||
$status_color = COL_UNKNOWN; // Unknown monitor
|
||||
break;
|
||||
}
|
||||
|
||||
return $status_color;
|
||||
}
|
||||
|
||||
function add_agent_networkmap($id, $agent_name_param, $x, $y,
|
||||
$id_agent_param = false, $other_values = array()) {
|
||||
|
||||
global $config;
|
||||
|
||||
if ($id_agent_param !== false) {
|
||||
$agent_name = io_safe_output(agents_get_name($id_agent_param));
|
||||
|
||||
$id_agent = $id_agent_param;
|
||||
}
|
||||
else {
|
||||
$id_agent = agents_get_agent_id($agent_name_param);
|
||||
$agent_name = io_safe_output($agent_name_param);
|
||||
}
|
||||
|
||||
if ($id_agent == false)
|
||||
return false;
|
||||
|
||||
$agent = db_get_row('tagente', 'id_agente', $id_agent);
|
||||
|
||||
$img_node = ui_print_os_icon ($agent['id_os'], false, true, true,
|
||||
true, true, true);
|
||||
$img_node_dir = str_replace($config['homeurl'], $config['homedir'],
|
||||
$img_node);
|
||||
|
||||
$size = getimagesize($img_node_dir);
|
||||
$width = $size[0];
|
||||
$height = $size[1];
|
||||
|
||||
$data = array();
|
||||
$data['id_map'] = $id;
|
||||
$data['x'] = $x;
|
||||
$data['y'] = $y;
|
||||
$data['source_data'] = $id_agent;
|
||||
$style = array();
|
||||
$style['shape'] = 'circle';
|
||||
$style['image'] = $img_node;
|
||||
$style['width'] = $width;
|
||||
$style['height'] = $height;
|
||||
$data['type'] = 0;
|
||||
//WORK AROUND FOR THE JSON ENCODE WITH FOR EXAMPLE Ñ OR Á
|
||||
$style['label'] = 'json_encode_crash_with_ut8_chars';
|
||||
|
||||
if (isset($other_values['state'])) {
|
||||
$data['state'] = $other_values['state'];
|
||||
}
|
||||
|
||||
if (isset($other_values['label'])) {
|
||||
$agent_name = $other_values['label'];
|
||||
}
|
||||
|
||||
if (isset($other_values['id_module'])) {
|
||||
$data['source_data'] = $other_values['id_module'];
|
||||
$style['shape'] = 'arrowhead';
|
||||
}
|
||||
|
||||
if (isset($other_values['type'])) {
|
||||
$data['type'] = $other_values['type'];
|
||||
}
|
||||
|
||||
$data['style'] = json_encode($style);
|
||||
$data['style'] = str_replace('json_encode_crash_with_ut8_chars',
|
||||
$agent_name, $data['style']);
|
||||
|
||||
$id_node = db_process_sql_insert('titem', $data);
|
||||
|
||||
$node = db_get_all_rows_filter('titem', array('id' => $id_node));
|
||||
$node = $node[0];
|
||||
|
||||
|
||||
$rel = array();
|
||||
/* FLECHAS EMPEZADO PARA MEJORAR
|
||||
$index = 0;
|
||||
if ($agent['id_parent'] != 0) {
|
||||
$values = array();
|
||||
$values['id_child'] = $agent['id_agente'];
|
||||
$values['id_parent'] = $agent['id_parent'];
|
||||
$values['parent_type'] = 0;
|
||||
$values['child_type'] = 0;
|
||||
$values['id_item'] = 0;
|
||||
$values['deleted'] = 0;
|
||||
$values['id_map'] = $id;
|
||||
|
||||
$parent = db_get_row('tagente', 'id_agente', $agent['id_parent']);
|
||||
$parent_item = db_get_all_rows_filter('titem', array('source_data' => $agent['id_parent'], 'type' => 0));
|
||||
$parent_item = $parent_item[0];
|
||||
|
||||
$rel[$index]['id_db'] = db_process_sql_insert('trel_item', $values);
|
||||
$rel[$index]['id_agent_end'] = $parent['id_agente'];
|
||||
$rel[$index]['id_agent_start'] = $agent['id_agente'];
|
||||
$rel[$index]['id_module_end'] = 0;
|
||||
$rel[$index]['id_module_start'] = 0;
|
||||
$rel[$index]['source'] = $id_node;
|
||||
$rel[$index]['target'] = $parent_item['id'];
|
||||
$rel[$index]['source_in_db'] = $id_node;
|
||||
$rel[$index]['target_in_db'] = $parent_item['id'];
|
||||
$rel[$index]['arrow_end'] = "";
|
||||
$rel[$index]['arrow_start'] = "";
|
||||
$rel[$index]['status_end'] = "";
|
||||
$rel[$index]['status_start'] = "";
|
||||
$rel[$index]['text_end'] = "";
|
||||
$rel[$index]['text_start'] = "";
|
||||
$index++;
|
||||
|
||||
$childs_of_new_agent = db_get_all_rows_filter('tagente', array('id_parent' => $agent['id_agente']));
|
||||
|
||||
foreach ($childs_of_new_agent as $child) {
|
||||
$values = array();
|
||||
$values['id_child'] = $child['id_agente'];
|
||||
$values['id_parent'] = $agent['id_agente'];
|
||||
$values['parent_type'] = 0;
|
||||
$values['child_type'] = 0;
|
||||
$values['id_item'] = 0;
|
||||
$values['deleted'] = 0;
|
||||
$values['id_map'] = $id;
|
||||
|
||||
$child_item = db_get_all_rows_filter('titem', array('source_data' => $child['id_agente'], 'type' => 0));
|
||||
$child_item = $child_item[0];
|
||||
|
||||
$rel[$index]['id_db'] = db_process_sql_insert('trel_item', $values);
|
||||
$rel[$index]['id_agent_end'] = $agent['id_agente'];
|
||||
$rel[$index]['id_agent_start'] = $child['id_agente'];
|
||||
$rel[$index]['id_module_end'] = 0;
|
||||
$rel[$index]['id_module_start'] = 0;
|
||||
$rel[$index]['source'] = $child_item['id'];
|
||||
$rel[$index]['target'] = $id_node;
|
||||
$rel[$index]['source_in_db'] = $child_item['id'];
|
||||
$rel[$index]['target_in_db'] = $id_node;
|
||||
$rel[$index]['arrow_end'] = "";
|
||||
$rel[$index]['arrow_start'] = "";
|
||||
$rel[$index]['status_end'] = "";
|
||||
$rel[$index]['status_start'] = "";
|
||||
$rel[$index]['text_end'] = "";
|
||||
$rel[$index]['text_start'] = "";
|
||||
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
$return_data = array();
|
||||
if ($id_node !== false) {
|
||||
$return_data['id_node'] = $id_node;
|
||||
$return_data['rel'] = $rel;
|
||||
return $return_data;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function show_node_info($id_node, $refresh_state, $user_readonly) {
|
||||
global $config;
|
||||
|
||||
|
@ -1464,99 +1074,11 @@ function duplicate_networkmap($id) {
|
|||
}
|
||||
}
|
||||
|
||||
function networkmap_clean_duplicate_links($id) {
|
||||
global $config;
|
||||
|
||||
//Clean (for migrations of older Pandoras)
|
||||
// - duplicated links
|
||||
// - duplicate links
|
||||
// (parent) node 1 - (child) node 2
|
||||
// (parent) node 2 - (child) node 1
|
||||
//
|
||||
// and erase the last, only the first row alive
|
||||
|
||||
$sql_duplicate_links = "SELECT id, id_parent, id_child
|
||||
FROM trel_item t1
|
||||
WHERE t1.id_child IN (
|
||||
SELECT t2.id_child
|
||||
FROM trel_item t2
|
||||
WHERE t1.id != t2.id
|
||||
AND t1.id_child = t2.id_child
|
||||
AND t1.id_parent = t2.id_parent
|
||||
AND t2.id_map = " . $id . ")
|
||||
AND t1.id_map = " . $id . "
|
||||
ORDER BY id_parent, id_child";
|
||||
|
||||
$rows = db_get_all_rows_sql($sql_duplicate_links);
|
||||
if (empty($rows))
|
||||
$rows = array();
|
||||
|
||||
$pre_parent = -1;
|
||||
$pre_child = -1;
|
||||
foreach ($rows as $row) {
|
||||
if (($pre_parent == $row['id_parent']) &&
|
||||
($pre_child == $row['id_child'])) {
|
||||
|
||||
//Delete the duplicate row
|
||||
db_process_sql_delete('trel_item',
|
||||
array('id' => $row['id']));
|
||||
|
||||
}
|
||||
else {
|
||||
$pre_parent = $row['id_parent'];
|
||||
$pre_child = $row['id_child'];
|
||||
}
|
||||
}
|
||||
|
||||
db_process_sql($sql_duplicate_links);
|
||||
|
||||
do {
|
||||
db_clean_cache();
|
||||
|
||||
$sql_duplicate_links_parent_as_children = "
|
||||
SELECT id, id_parent, id_child
|
||||
FROM trel_item t1
|
||||
WHERE t1.id_child IN (
|
||||
SELECT t2.id_parent
|
||||
FROM trel_item t2
|
||||
WHERE t1.id_parent = t2.id_child
|
||||
AND t1.id_child = t2.id_parent
|
||||
AND t2.id_map = " . $id . ")
|
||||
AND t1.id_map = " . $id . "
|
||||
ORDER BY id_parent, id_child";
|
||||
$rows = db_get_all_rows_sql($sql_duplicate_links_parent_as_children);
|
||||
|
||||
if (empty($rows))
|
||||
$rows = array();
|
||||
|
||||
$found = false;
|
||||
|
||||
foreach ($rows as $row) {
|
||||
foreach ($rows as $row2) {
|
||||
if (($row['id'] != $row2['id'])
|
||||
&& ($row['id_child'] == $row2['id_parent'])
|
||||
&& ($row['id_parent'] == $row2['id_child'])
|
||||
) {
|
||||
|
||||
db_process_sql_delete('trel_item',
|
||||
array('id' => $row2['id']));
|
||||
|
||||
$found = true;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($found)
|
||||
break;
|
||||
}
|
||||
}
|
||||
while ($found);
|
||||
}
|
||||
|
||||
function show_networkmap($id = 0, $user_readonly = false, $nodes_and_relations = array()) {
|
||||
global $config;
|
||||
|
||||
if (enterprise_installed()) {
|
||||
enterprise_include_once("include/functions_pandora_networkmap.php");
|
||||
//Clean (for migrations of older Pandoras)
|
||||
// - duplicated links
|
||||
// - duplicate links
|
||||
|
@ -1565,6 +1087,7 @@ function show_networkmap($id = 0, $user_readonly = false, $nodes_and_relations =
|
|||
//
|
||||
// and erase the last, only the first row alive
|
||||
networkmap_clean_duplicate_links($id);
|
||||
}
|
||||
|
||||
$networkmap = db_get_row('tmap', 'id', $id);
|
||||
$networkmap['filter'] = json_decode($networkmap['filter'], true);
|
||||
|
@ -2066,90 +1589,6 @@ function networkmap_update_link($networkmap_id, $id_link, $interface_source, $in
|
|||
return array('correct' => true, 'id_link_change' => $id_link_change);
|
||||
}
|
||||
|
||||
function networkmap_delete_link($networkmap_id, $source_id,
|
||||
$source_module_id, $target_id, $target_module_id, $id_link) {
|
||||
|
||||
$flag_delete_level2 = false;
|
||||
|
||||
if ($source_module_id != 0) {
|
||||
$flag_delete_level2 = true;
|
||||
}
|
||||
|
||||
if ($target_module_id != 0) {
|
||||
$flag_delete_level2 = true;
|
||||
}
|
||||
|
||||
if ($flag_delete_level2) {
|
||||
$link = db_get_row_filter('trel_item',
|
||||
array('id_map' => $networkmap_id,
|
||||
'id' => $id_link));
|
||||
|
||||
if (($link['parent_type'] == 0) &&
|
||||
($link['child_type'] == 0)) {
|
||||
|
||||
//Delete normaly
|
||||
|
||||
$result = db_process_sql_update(
|
||||
'trel_item',
|
||||
array('deleted' => 1),
|
||||
array('id' => $link['id']));
|
||||
}
|
||||
else {
|
||||
|
||||
//Delete modules nodes and the relation module node with agent node
|
||||
|
||||
if ($link['parent_type'] == 1) {
|
||||
$result = db_process_sql_update(
|
||||
'titem',
|
||||
array('deleted' => 1),
|
||||
array('id' => $link['id_parent']));
|
||||
|
||||
db_process_sql_update(
|
||||
'trel_item',
|
||||
array('deleted' => 1),
|
||||
array('id_parent' => $link['id_parent']));
|
||||
|
||||
db_process_sql_update(
|
||||
'trel_item',
|
||||
array('deleted' => 1),
|
||||
array('id_child' => $link['id_parent']));
|
||||
}
|
||||
|
||||
if (!empty($result)) {
|
||||
if (!$result)
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($link['child_type'] == 1) {
|
||||
$result = db_process_sql_update(
|
||||
'titem',
|
||||
array('deleted' => 1),
|
||||
array('id' => $link['id_child']));
|
||||
|
||||
db_process_sql_update(
|
||||
'trel_item',
|
||||
array('deleted' => 1),
|
||||
array('id_parent' => $link['id_child']));
|
||||
|
||||
db_process_sql_update(
|
||||
'trel_item',
|
||||
array('deleted' => 1),
|
||||
array('id_child' => $link['id_child']));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$result = db_process_sql_update(
|
||||
'trel_item',
|
||||
array('deleted' => 1),
|
||||
array('id_map' => $networkmap_id,
|
||||
'id_parent' => $target_id,
|
||||
'id_child' => $source_id));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function networkmap_get_new_nodes_and_links($id_networkmap) {
|
||||
$networkmap = db_get_row_filter('tmap',
|
||||
array('id' => $id_networkmap));
|
||||
|
@ -2539,82 +1978,6 @@ function networkmap_get_new_nodes_and_links($id_networkmap) {
|
|||
}
|
||||
}
|
||||
|
||||
function networkmap_refresh_holding_area($id_networkmap) {
|
||||
networkmap_get_new_nodes_and_links($id_networkmap);
|
||||
networkmap_clean_duplicate_links($id_networkmap);
|
||||
|
||||
$rows = db_get_all_rows_filter('titem',
|
||||
array('id_map' => $id_networkmap,
|
||||
'state' => 'pending_holding_area', 'deleted' => 0));
|
||||
if (empty($rows))
|
||||
$rows = array();
|
||||
|
||||
$nodes = array();
|
||||
|
||||
$count = 0;
|
||||
$count_item_holding_area = 0;
|
||||
foreach ($rows as $row) {
|
||||
if (isset($row['type'])) {
|
||||
if ($row['type'] == 1)
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
$row['type'] = '';
|
||||
}
|
||||
|
||||
$row['state'] = 'holding_area';
|
||||
db_process_sql_update('titem',
|
||||
array('state' => $row['state']),
|
||||
array('id' => $row['id']));
|
||||
|
||||
$row['style'] = json_decode($row['style'], true);
|
||||
|
||||
$node = networkmap_db_node_to_js_node($row, $count,
|
||||
$count_item_holding_area);
|
||||
|
||||
$nodes[$node['id']] = $node;
|
||||
}
|
||||
|
||||
//Get all links of actual nodes
|
||||
//but in the javascript code filter the links and only add the
|
||||
//new links
|
||||
$relations = db_get_all_rows_sql("
|
||||
SELECT t1.*,
|
||||
|
||||
(SELECT t2.source_data
|
||||
FROM titem t2
|
||||
WHERE t2.id_map = " . $id_networkmap . "
|
||||
AND t2.type = 0
|
||||
AND t2.id = t1.id_parent) AS id_agent_parent,
|
||||
|
||||
(SELECT t2.source_data
|
||||
FROM titem t2
|
||||
WHERE t2.id_map = " . $id_networkmap . "
|
||||
AND t2.type = 0
|
||||
AND t2.id = t1.id_child) AS id_agent_child,
|
||||
|
||||
(SELECT t2.source_data
|
||||
FROM titem t2
|
||||
WHERE t2.id_map = " . $id_networkmap . "
|
||||
AND t2.type = 1
|
||||
AND t2.id = t1.id_parent) AS id_module_parent,
|
||||
|
||||
(SELECT t2.source_data
|
||||
FROM titem t2
|
||||
WHERE t2.id_map = " . $id_networkmap . "
|
||||
AND t2.type = 1
|
||||
AND t2.id = t1.id_child) AS id_module_child
|
||||
|
||||
FROM trel_item t1
|
||||
WHERE t1.id_map = " . $id_networkmap . "
|
||||
AND t1.deleted = 0");
|
||||
if ($relations === false) $relations = array();
|
||||
networkmap_clean_relations_for_js($relations);
|
||||
|
||||
$links_js = networkmap_links_to_js_links(
|
||||
$relations, $nodes);
|
||||
|
||||
return array('nodes' => $nodes, 'links' => $links_js);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -99,6 +99,7 @@ function get_relations(node_param) {
|
|||
}
|
||||
|
||||
function delete_link(source_id, source_module_id, target_id, target_module_id, id_link) {
|
||||
if (enterprise_installed) {
|
||||
var params = [];
|
||||
params.push("delete_link=1");
|
||||
params.push("networkmap_id=" + networkmap_id);
|
||||
|
@ -107,7 +108,7 @@ function delete_link(source_id, source_module_id, target_id, target_module_id, i
|
|||
params.push("target_id=" + target_id);
|
||||
params.push("target_module_id=" + target_module_id);
|
||||
params.push("id_link=" + id_link);
|
||||
params.push("page=operation/agentes/pandora_networkmap.view");
|
||||
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
dataType: 'json',
|
||||
|
@ -137,9 +138,30 @@ function delete_link(source_id, source_module_id, target_id, target_module_id, i
|
|||
$("#dialog_node_edit").dialog("close");
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
do {
|
||||
found = -1;
|
||||
|
||||
jQuery.each(graph.links, function(i, element) {
|
||||
if ((element.source.id_db == source_id)
|
||||
&& (element.target.id_db == target_id)) {
|
||||
found = i;
|
||||
}
|
||||
});
|
||||
if (found != -1)
|
||||
graph.links.splice(found, 1);
|
||||
}
|
||||
while (found != -1);
|
||||
|
||||
draw_elements_graph();
|
||||
set_positions_graph();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update_fictional_node(id_db_node) {
|
||||
if (enterprise_installed) {
|
||||
var name = $("input[name='edit_name_fictional_node']").val();
|
||||
var networkmap_to_link = $("#edit_networkmap_to_link").val();
|
||||
|
||||
|
@ -149,7 +171,7 @@ function update_fictional_node(id_db_node) {
|
|||
params.push("node_id=" + id_db_node);
|
||||
params.push("name=" + name);
|
||||
params.push("networkmap_to_link=" + networkmap_to_link);
|
||||
params.push("page=operation/agentes/pandora_networkmap.view");
|
||||
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
|
||||
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
|
@ -175,9 +197,11 @@ function update_fictional_node(id_db_node) {
|
|||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function change_shape(id_db_node) {
|
||||
if (enterprise_installed) {
|
||||
var shape = $("select[name='shape']").val();
|
||||
|
||||
var params = [];
|
||||
|
@ -185,7 +209,7 @@ function change_shape(id_db_node) {
|
|||
params.push("networkmap_id=" + networkmap_id);
|
||||
params.push("id=" + id_db_node);
|
||||
params.push("shape=" + shape);
|
||||
params.push("page=operation/agentes/pandora_networkmap.view");
|
||||
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
|
||||
|
||||
$("#shape_icon_correct").css("display", "none");
|
||||
$("#shape_icon_fail").css("display", "none");
|
||||
|
@ -277,6 +301,7 @@ function change_shape(id_db_node) {
|
|||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function update_link(row_index, id_link) {
|
||||
|
@ -335,7 +360,6 @@ function update_link(row_index, id_link) {
|
|||
jQuery.each(graph.links, function(i, link_each) {
|
||||
if (link_each.id_db == id_link) {
|
||||
//Found
|
||||
|
||||
graph.links[i].arrow_start = "";
|
||||
graph.links[i].arrow_start = "";
|
||||
graph.links[i].text_start = text_source_interface;
|
||||
|
@ -359,7 +383,6 @@ function update_link(row_index, id_link) {
|
|||
jQuery.each(graph.links, function(i, link_each) {
|
||||
if (link_each.id_db == id_link) {
|
||||
//Found
|
||||
|
||||
if (link_each.arrow_start == "") {
|
||||
graph.links[i].id_db = data['id_link_change'];
|
||||
}
|
||||
|
@ -386,15 +409,10 @@ function update_link(row_index, id_link) {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (interface_target == 0) {
|
||||
jQuery.each(graph.links, function(i, link_each) {
|
||||
if (link_each.id_db == id_link) {
|
||||
|
||||
//Found
|
||||
|
||||
graph.links[i].arrow_end = "";
|
||||
graph.links[i].id_module_end = 0;
|
||||
graph.links[i].text_end = text_target_interface;
|
||||
|
@ -403,7 +421,6 @@ function update_link(row_index, id_link) {
|
|||
$("#link_id_" + id_link)
|
||||
.attr("marker-end", "");
|
||||
|
||||
|
||||
$("tspan")
|
||||
.filter(function() {
|
||||
var textPath = $(this).parent();
|
||||
|
@ -448,14 +465,6 @@ function update_link(row_index, id_link) {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//for to test
|
||||
//jQuery.each(graph.links, function(i, link_each) {graph.links[i].arrow_start = ""; graph.links[i].arrow_end = "";});
|
||||
|
||||
//
|
||||
|
||||
draw_elements_graph();
|
||||
set_positions_graph();
|
||||
}
|
||||
|
@ -467,6 +476,7 @@ function update_link(row_index, id_link) {
|
|||
}
|
||||
|
||||
function edit_node(data) {
|
||||
if (enterprise_installed) {
|
||||
var flag_edit_node = true;
|
||||
var edit_node = null
|
||||
|
||||
|
@ -569,7 +579,7 @@ function edit_node(data) {
|
|||
var params = [];
|
||||
params.push("get_intefaces=1");
|
||||
params.push("id_agent=" + link_each.source.id_agent);
|
||||
params.push("page=operation/agentes/pandora_networkmap.view");
|
||||
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
|
||||
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
|
@ -595,11 +605,10 @@ function edit_node(data) {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
var params = [];
|
||||
params.push("get_intefaces=1");
|
||||
params.push("id_agent=" + link_each.target.id_agent);
|
||||
params.push("page=operation/agentes/pandora_networkmap.view");
|
||||
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
|
||||
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
|
@ -626,8 +635,6 @@ function edit_node(data) {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
$("#relations_table-template_row-node_source", template_relation_row)
|
||||
.html(link_each.source.text);
|
||||
$("#relations_table-template_row-node_target", template_relation_row)
|
||||
|
@ -648,8 +655,7 @@ function edit_node(data) {
|
|||
});
|
||||
|
||||
$("#relations_table-loading").css('display', 'none');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -700,7 +706,7 @@ function add_agent_node(agents) {
|
|||
var x = (click_menu_position_svg[0] - translation[0]) / scale;
|
||||
var y = (click_menu_position_svg[1] - translation[1]) / scale;
|
||||
|
||||
|
||||
if (enterprise_installed) {
|
||||
jQuery.each(id_agents, function(i, id_agent) {
|
||||
x = x + (i * 20);
|
||||
y = y + (i * 20);
|
||||
|
@ -711,7 +717,7 @@ function add_agent_node(agents) {
|
|||
params.push("id_agent=" + id_agent);
|
||||
params.push("x=" + x);
|
||||
params.push("y=" + y);
|
||||
params.push("page=operation/agentes/pandora_networkmap.view");
|
||||
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
dataType: 'json',
|
||||
|
@ -774,6 +780,34 @@ function add_agent_node(agents) {
|
|||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
$("#agent_name").val('');
|
||||
$("#dialog_node_add").dialog("close");
|
||||
|
||||
var temp_node = {};
|
||||
temp_node['id'] = graph.nodes.length;
|
||||
temp_node['id_db'] = data['id_node'];
|
||||
temp_node['id_agent'] = data['id_agent'];
|
||||
temp_node['id_module'] = "";
|
||||
temp_node['px'] = data['x'];
|
||||
temp_node['py'] = data['y'];
|
||||
temp_node['x'] = data['x'];
|
||||
temp_node['y'] = data['y'];
|
||||
temp_node['z'] = 0;
|
||||
temp_node['fixed'] = true;
|
||||
temp_node['type'] = 0;
|
||||
temp_node['color'] = data['status'];
|
||||
temp_node['shape'] = data['shape'];
|
||||
temp_node['text'] = data['text'];
|
||||
temp_node['image_url'] = data['image_url'];
|
||||
temp_node['image_width'] = data['width'];
|
||||
temp_node['image_height'] = data['height'];
|
||||
temp_node['map_id'] = data['map_id'];
|
||||
temp_node['state'] = data['state'];
|
||||
|
||||
graph.nodes.push(temp_node);
|
||||
}
|
||||
}
|
||||
|
||||
function show_details_agent(d) {
|
||||
|
@ -836,6 +870,7 @@ function function_close_minimap() {
|
|||
}
|
||||
|
||||
function delete_nodes() {
|
||||
if (enterprise_installed) {
|
||||
var selection = d3.selectAll('.node_selected');
|
||||
|
||||
selection
|
||||
|
@ -848,7 +883,7 @@ function delete_nodes() {
|
|||
var params = [];
|
||||
params.push("id=" + d.id_db);
|
||||
params.push("delete_node=1");
|
||||
params.push("page=operation/agentes/pandora_networkmap.view");
|
||||
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
dataType: 'json',
|
||||
|
@ -894,6 +929,7 @@ function delete_nodes() {
|
|||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function zoom(manual) {
|
||||
|
@ -932,7 +968,6 @@ function zoom(manual) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
function set_positions_graph() {
|
||||
link.selectAll("path.link")
|
||||
.attr("d", function(d) {
|
||||
|
@ -1043,6 +1078,7 @@ function clear_selection() {
|
|||
}
|
||||
|
||||
function update_networkmap() {
|
||||
if (enterprise_installed) {
|
||||
node
|
||||
.each(function(d) {
|
||||
if (d.id_agent != -1 ) {
|
||||
|
@ -1050,7 +1086,7 @@ function update_networkmap() {
|
|||
var params = [];
|
||||
params.push("update_node_color=1");
|
||||
params.push("id=" + d.id_db);
|
||||
params.push("page=operation/agentes/pandora_networkmap.view");
|
||||
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
|
||||
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
|
@ -1116,8 +1152,7 @@ function update_networkmap() {
|
|||
});
|
||||
|
||||
draw_minimap();
|
||||
|
||||
//window.clearInterval(interval_obj);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1193,7 +1228,6 @@ function init_minimap() {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Context menu
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1343,14 +1377,6 @@ function show_menu(item, data) {
|
|||
items_list["add_node"] = {
|
||||
name: add_node_menu,
|
||||
icon: "add_node",
|
||||
disabled : function() {
|
||||
if (enterprise_installed) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
"callback": function(key, options) {
|
||||
add_node();
|
||||
}
|
||||
|
@ -1365,6 +1391,14 @@ function show_menu(item, data) {
|
|||
items_list["refresh"] = {
|
||||
name: refresh_menu,
|
||||
icon: "refresh",
|
||||
disabled : function() {
|
||||
if (enterprise_installed) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
"callback": function(key, options) {
|
||||
update_networkmap();
|
||||
}
|
||||
|
@ -1372,6 +1406,14 @@ function show_menu(item, data) {
|
|||
items_list["refresh_holding_area"] = {
|
||||
name: refresh_holding_area_menu,
|
||||
icon: "refresh_holding_area",
|
||||
disabled : function() {
|
||||
if (enterprise_installed) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
"callback": function(key, options) {
|
||||
refresh_holding_area();
|
||||
}
|
||||
|
@ -1381,6 +1423,14 @@ function show_menu(item, data) {
|
|||
items_list["cancel_set_parent"] = {
|
||||
name: abort_relationship_menu,
|
||||
icon: "cancel_set_parent",
|
||||
disabled : function() {
|
||||
if (enterprise_installed) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
"callback": function(key, options) {
|
||||
cancel_set_parent();
|
||||
}
|
||||
|
@ -1406,10 +1456,11 @@ function show_menu(item, data) {
|
|||
}
|
||||
|
||||
function refresh_holding_area() {
|
||||
if (enterprise_installed) {
|
||||
var params = [];
|
||||
params.push("refresh_holding_area=1");
|
||||
params.push("id=" + networkmap_id);
|
||||
params.push("page=operation/agentes/pandora_networkmap.view");
|
||||
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
dataType: 'json',
|
||||
|
@ -1488,9 +1539,11 @@ function refresh_holding_area() {
|
|||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function set_parent(parent_data) {
|
||||
if (enterprise_installed) {
|
||||
var selection = d3.selectAll('.node_children');
|
||||
|
||||
count = selection.size();
|
||||
|
@ -1540,7 +1593,7 @@ function set_parent(parent_data) {
|
|||
params.push("id=" + networkmap_id);
|
||||
params.push("child=" + child_data.id_db);
|
||||
params.push("parent=" + parent_data.id_db);
|
||||
params.push("page=operation/agentes/pandora_networkmap.view");
|
||||
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
dataType: 'json',
|
||||
|
@ -1580,6 +1633,7 @@ function set_parent(parent_data) {
|
|||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function cancel_set_parent() {
|
||||
|
@ -1695,6 +1749,7 @@ function add_fictional_node() {
|
|||
var x = (click_menu_position_svg[0] - translation[0]) / scale;
|
||||
var y = (click_menu_position_svg[1] - translation[1]) / scale;
|
||||
|
||||
if (enterprise_installed) {
|
||||
var params = [];
|
||||
params.push("create_fictional_point=1");
|
||||
params.push("id=" + networkmap_id);
|
||||
|
@ -1705,7 +1760,7 @@ function add_fictional_node() {
|
|||
params.push("shape=circle");
|
||||
params.push("x=" + x);
|
||||
params.push("y=" + y);
|
||||
params.push("page=operation/agentes/pandora_networkmap.view");
|
||||
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
dataType: 'json',
|
||||
|
@ -1741,9 +1796,38 @@ function add_fictional_node() {
|
|||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
$("#dialog_node_add").dialog("close");
|
||||
|
||||
var temp_node = {};
|
||||
temp_node['id'] = graph.nodes.length;
|
||||
temp_node['id_db'] = data['id_node'];
|
||||
temp_node['id_agent'] = data['id_agent'];
|
||||
temp_node['id_module'] = 0;
|
||||
temp_node['x'] = x;
|
||||
temp_node['y'] = y;
|
||||
temp_node['z'] = 0;
|
||||
temp_node['fixed'] = true;
|
||||
temp_node['type'] = 3;
|
||||
temp_node['color'] = data['color'];
|
||||
temp_node['shape'] = data['shape'];
|
||||
temp_node['text'] = data['text'];
|
||||
temp_node['image_url'] = "";
|
||||
temp_node['image_width'] = 0;
|
||||
temp_node['image_height'] = 0;
|
||||
temp_node['networkmap_id'] = networkmap_to_link;
|
||||
|
||||
graph.nodes.push(temp_node);
|
||||
|
||||
draw_elements_graph();
|
||||
init_drag_and_drop();
|
||||
set_positions_graph();
|
||||
}
|
||||
}
|
||||
|
||||
function init_graph(parameter_object) {
|
||||
console.log(parameter_object);
|
||||
|
||||
window.width_svg = $("#networkconsole").width();
|
||||
if ($("#main").height()) {
|
||||
|
@ -2439,41 +2523,14 @@ function choose_group_for_show_agents() {
|
|||
|
||||
canvas = $("#node_info");
|
||||
context_popup = canvas[0].getContext('2d');
|
||||
//Changed, now the popup is frozen as pussy nun.
|
||||
//get_status_node();
|
||||
//get_status_module();
|
||||
|
||||
dirty_popup = true;
|
||||
self.setInterval("check_popup_modification()", 1000/30);
|
||||
//Changed, now the popup is frozen as pussy nun.
|
||||
/*
|
||||
self.setInterval("check_changes_num_modules()", refresh_state * 1000);
|
||||
self.setInterval("get_status_node()", refresh_state * 1000);
|
||||
self.setInterval("get_status_module()", refresh_state * 1000);
|
||||
*/
|
||||
|
||||
$("#node_info").mousemove(function(event) {
|
||||
var x = event.pageX - $("#node_info").offset().left;
|
||||
var y = event.pageY - $("#node_info").offset().top;
|
||||
//var x = event.clientX;
|
||||
//var y = event.clientY;
|
||||
|
||||
//DISABLED THE DRAG AND DROP, NOW IT IS SCROLLBAR
|
||||
/*
|
||||
if (drag) {
|
||||
drag_x_delta = drag_x - x;
|
||||
drag_y_delta = drag_y - y;
|
||||
|
||||
offset_x = offset_x - drag_x_delta;
|
||||
offset_y = offset_y - drag_y_delta;
|
||||
|
||||
drag_x = x;
|
||||
drag_y = y;
|
||||
|
||||
dirty_popup = true;
|
||||
}
|
||||
else {
|
||||
*/
|
||||
module_inner = inner_module(x, y);
|
||||
|
||||
if (module_inner != null) {
|
||||
|
@ -2482,30 +2539,15 @@ function choose_group_for_show_agents() {
|
|||
else {
|
||||
document.body.style.cursor = "default";
|
||||
}
|
||||
/*
|
||||
}
|
||||
*/
|
||||
});
|
||||
|
||||
$("#node_info").mousedown(function(event) {
|
||||
var x = event.pageX - $("#node_info").offset().left;
|
||||
var y = event.pageY - $("#node_info").offset().top;
|
||||
//var x = event.clientX;
|
||||
//var y = event.clientY;
|
||||
|
||||
if (module_inner != null) {
|
||||
show_tooltip(module_inner, x, y);
|
||||
}
|
||||
//DISABLED THE DRAG AND DROP, NOW IT IS SCROLLBAR
|
||||
/*
|
||||
else {
|
||||
drag = true;
|
||||
drag_x = x;
|
||||
drag_y = y;
|
||||
|
||||
document.body.style.cursor = "pointer";
|
||||
}
|
||||
*/
|
||||
|
||||
event.stopPropagation();
|
||||
return false;
|
||||
|
@ -2514,8 +2556,6 @@ function choose_group_for_show_agents() {
|
|||
$("#node_info").mouseup(function(event) {
|
||||
var x = event.pageX - $("#node_info").offset().left;
|
||||
var y = event.pageY - $("#node_info").offset().top;
|
||||
//var x = event.clientX;
|
||||
//var y = event.clientY;
|
||||
|
||||
drag = false;
|
||||
drag_x = 0;
|
||||
|
@ -2533,8 +2573,6 @@ function choose_group_for_show_agents() {
|
|||
$("#node_info").mouseout(function(event) {
|
||||
var x = event.pageX - $("#node_info").offset().left;
|
||||
var y = event.pageY - $("#node_info").offset().top;
|
||||
//var x = event.clientX;
|
||||
//var y = event.clientY;
|
||||
|
||||
drag = false;
|
||||
drag_x = 0;
|
||||
|
@ -2550,49 +2588,19 @@ function choose_group_for_show_agents() {
|
|||
});
|
||||
|
||||
$(window).resize(function() {
|
||||
//$("#node_info").attr('width', $(window).width());
|
||||
//node_info_height = $("#content_node_info").height();
|
||||
//node_info_width = $("#content_node_info").width();
|
||||
function show_networkmap_node(id_agent_param, refresh_state) {
|
||||
id_agent = id_agent_param;
|
||||
|
||||
canvas = $("#node_info");
|
||||
context_popup = canvas[0].getContext('2d');
|
||||
//Changed, now the popup is frozen as pussy nun.
|
||||
//get_status_node();
|
||||
//get_status_module();
|
||||
|
||||
dirty_popup = true;
|
||||
self.setInterval("check_popup_modification()", 1000/30);
|
||||
//Changed, now the popup is frozen as pussy nun.
|
||||
/*
|
||||
self.setInterval("check_changes_num_modules()", refresh_state * 1000);
|
||||
self.setInterval("get_status_node()", refresh_state * 1000);
|
||||
self.setInterval("get_status_module()", refresh_state * 1000);
|
||||
*/
|
||||
|
||||
$("#node_info").mousemove(function(event) {
|
||||
var x = event.pageX - $("#node_info").offset().left;
|
||||
var y = event.pageY - $("#node_info").offset().top;
|
||||
//var x = event.clientX;
|
||||
//var y = event.clientY;
|
||||
|
||||
//DISABLED THE DRAG AND DROP, NOW IT IS SCROLLBAR
|
||||
/*
|
||||
if (drag) {
|
||||
drag_x_delta = drag_x - x;
|
||||
drag_y_delta = drag_y - y;
|
||||
|
||||
offset_x = offset_x - drag_x_delta;
|
||||
offset_y = offset_y - drag_y_delta;
|
||||
|
||||
drag_x = x;
|
||||
drag_y = y;
|
||||
|
||||
dirty_popup = true;
|
||||
}
|
||||
else {
|
||||
*/
|
||||
module_inner = inner_module(x, y);
|
||||
|
||||
if (module_inner != null) {
|
||||
|
@ -2601,30 +2609,15 @@ function choose_group_for_show_agents() {
|
|||
else {
|
||||
document.body.style.cursor = "default";
|
||||
}
|
||||
/*
|
||||
}
|
||||
*/
|
||||
});
|
||||
|
||||
$("#node_info").mousedown(function(event) {
|
||||
var x = event.pageX - $("#node_info").offset().left;
|
||||
var y = event.pageY - $("#node_info").offset().top;
|
||||
//var x = event.clientX;
|
||||
//var y = event.clientY;
|
||||
|
||||
if (module_inner != null) {
|
||||
show_tooltip(module_inner, x, y);
|
||||
}
|
||||
//DISABLED THE DRAG AND DROP, NOW IT IS SCROLLBAR
|
||||
/*
|
||||
else {
|
||||
drag = true;
|
||||
drag_x = x;
|
||||
drag_y = y;
|
||||
|
||||
document.body.style.cursor = "pointer";
|
||||
}
|
||||
*/
|
||||
|
||||
event.stopPropagation();
|
||||
return false;
|
||||
|
@ -2633,8 +2626,6 @@ function choose_group_for_show_agents() {
|
|||
$("#node_info").mouseup(function(event) {
|
||||
var x = event.pageX - $("#node_info").offset().left;
|
||||
var y = event.pageY - $("#node_info").offset().top;
|
||||
//var x = event.clientX;
|
||||
//var y = event.clientY;
|
||||
|
||||
drag = false;
|
||||
drag_x = 0;
|
||||
|
@ -2652,8 +2643,6 @@ function choose_group_for_show_agents() {
|
|||
$("#node_info").mouseout(function(event) {
|
||||
var x = event.pageX - $("#node_info").offset().left;
|
||||
var y = event.pageY - $("#node_info").offset().top;
|
||||
//var x = event.clientX;
|
||||
//var y = event.clientY;
|
||||
|
||||
drag = false;
|
||||
drag_x = 0;
|
||||
|
@ -2669,9 +2658,6 @@ function choose_group_for_show_agents() {
|
|||
});
|
||||
|
||||
$(window).resize(function() {
|
||||
//$("#node_info").attr('width', $(window).width());
|
||||
//node_info_height = $("#content_node_info").height();
|
||||
//node_info_width = $("#content_node_info").width();
|
||||
|
||||
pos_scroll = Math.floor($("#content_node_info").width() / 2);
|
||||
|
||||
|
@ -2707,8 +2693,6 @@ var BORDER_SIZE_AGENT_BOX = 5;
|
|||
var SIZE_MODULE = 30;
|
||||
var MARGIN_BETWEEN_AGENT_MODULE = 20;
|
||||
|
||||
|
||||
|
||||
var context_popup = null;
|
||||
var dirty_popup = false;
|
||||
var id_agent = 0;
|
||||
|
@ -2791,47 +2775,19 @@ function check_changes_num_modules() {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
function show_networkmap_node(id_agent_param, refresh_state) {
|
||||
id_agent = id_agent_param;
|
||||
|
||||
canvas = $("#node_info");
|
||||
context_popup = canvas[0].getContext('2d');
|
||||
//Changed, now the popup is frozen as pussy nun.
|
||||
//get_status_node();
|
||||
//get_status_module();
|
||||
|
||||
dirty_popup = true;
|
||||
self.setInterval("check_popup_modification()", 1000/30);
|
||||
//Changed, now the popup is frozen as pussy nun.
|
||||
/*
|
||||
self.setInterval("check_changes_num_modules()", refresh_state * 1000);
|
||||
self.setInterval("get_status_node()", refresh_state * 1000);
|
||||
self.setInterval("get_status_module()", refresh_state * 1000);
|
||||
*/
|
||||
|
||||
$("#node_info").mousemove(function(event) {
|
||||
var x = event.pageX - $("#node_info").offset().left;
|
||||
var y = event.pageY - $("#node_info").offset().top;
|
||||
//var x = event.clientX;
|
||||
//var y = event.clientY;
|
||||
|
||||
//DISABLED THE DRAG AND DROP, NOW IT IS SCROLLBAR
|
||||
/*
|
||||
if (drag) {
|
||||
drag_x_delta = drag_x - x;
|
||||
drag_y_delta = drag_y - y;
|
||||
|
||||
offset_x = offset_x - drag_x_delta;
|
||||
offset_y = offset_y - drag_y_delta;
|
||||
|
||||
drag_x = x;
|
||||
drag_y = y;
|
||||
|
||||
dirty_popup = true;
|
||||
}
|
||||
else {
|
||||
*/
|
||||
module_inner = inner_module(x, y);
|
||||
|
||||
if (module_inner != null) {
|
||||
|
@ -2840,30 +2796,15 @@ function show_networkmap_node(id_agent_param, refresh_state) {
|
|||
else {
|
||||
document.body.style.cursor = "default";
|
||||
}
|
||||
/*
|
||||
}
|
||||
*/
|
||||
});
|
||||
|
||||
$("#node_info").mousedown(function(event) {
|
||||
var x = event.pageX - $("#node_info").offset().left;
|
||||
var y = event.pageY - $("#node_info").offset().top;
|
||||
//var x = event.clientX;
|
||||
//var y = event.clientY;
|
||||
|
||||
if (module_inner != null) {
|
||||
show_tooltip(module_inner, x, y);
|
||||
}
|
||||
//DISABLED THE DRAG AND DROP, NOW IT IS SCROLLBAR
|
||||
/*
|
||||
else {
|
||||
drag = true;
|
||||
drag_x = x;
|
||||
drag_y = y;
|
||||
|
||||
document.body.style.cursor = "pointer";
|
||||
}
|
||||
*/
|
||||
|
||||
event.stopPropagation();
|
||||
return false;
|
||||
|
@ -2872,8 +2813,6 @@ function show_networkmap_node(id_agent_param, refresh_state) {
|
|||
$("#node_info").mouseup(function(event) {
|
||||
var x = event.pageX - $("#node_info").offset().left;
|
||||
var y = event.pageY - $("#node_info").offset().top;
|
||||
//var x = event.clientX;
|
||||
//var y = event.clientY;
|
||||
|
||||
drag = false;
|
||||
drag_x = 0;
|
||||
|
@ -2891,8 +2830,6 @@ function show_networkmap_node(id_agent_param, refresh_state) {
|
|||
$("#node_info").mouseout(function(event) {
|
||||
var x = event.pageX - $("#node_info").offset().left;
|
||||
var y = event.pageY - $("#node_info").offset().top;
|
||||
//var x = event.clientX;
|
||||
//var y = event.clientY;
|
||||
|
||||
drag = false;
|
||||
drag_x = 0;
|
||||
|
@ -2908,9 +2845,6 @@ function show_networkmap_node(id_agent_param, refresh_state) {
|
|||
});
|
||||
|
||||
$(window).resize(function() {
|
||||
//$("#node_info").attr('width', $(window).width());
|
||||
//node_info_height = $("#content_node_info").height();
|
||||
//node_info_width = $("#content_node_info").width();
|
||||
|
||||
pos_scroll = Math.floor($("#content_node_info").width() / 2);
|
||||
|
||||
|
|
|
@ -24,12 +24,10 @@ require_once ('include/functions_modules.php');
|
|||
if (is_ajax ()) {
|
||||
$update_node = (bool)get_parameter('update_node', false);
|
||||
$erase_node = (bool)get_parameter('erase_node', false);
|
||||
$update_node_color = (bool)get_parameter('update_node_color',
|
||||
false);
|
||||
$set_relationship = (bool)get_parameter('set_relationship', false);
|
||||
|
||||
$update_refresh_state = (bool)get_parameter('update_refresh_state',
|
||||
false);
|
||||
$add_agent = (bool)get_parameter('add_agent', false);
|
||||
|
||||
$set_center = (bool)get_parameter('set_center', false);
|
||||
$erase_relation = (bool)get_parameter('erase_relation', false);
|
||||
$search_agents = (bool) get_parameter ('search_agents');
|
||||
|
@ -44,88 +42,13 @@ if (is_ajax ()) {
|
|||
false);
|
||||
$add_several_agents = (bool)get_parameter('add_several_agents',
|
||||
false);
|
||||
$create_fictional_point = (bool)get_parameter(
|
||||
'create_fictional_point', false);
|
||||
|
||||
$update_fictional_point = (bool)get_parameter(
|
||||
'update_fictional_point', false);
|
||||
$update_z = (bool)get_parameter('update_z', false);
|
||||
$module_get_status = (bool)get_parameter('module_get_status', false);
|
||||
$delete_node = (bool)get_parameter('delete_node', false);
|
||||
$delete_link = (bool)get_parameter('delete_link', false);
|
||||
$change_shape = (bool)get_parameter('change_shape', false);
|
||||
$get_intefaces = (bool)get_parameter('get_intefaces', false);
|
||||
|
||||
$update_link = (bool)get_parameter('update_link', false);
|
||||
$update_fictional_node = (bool)get_parameter('update_fictional_node', false);
|
||||
$refresh_holding_area = (bool)get_parameter('refresh_holding_area', false);
|
||||
|
||||
if ($refresh_holding_area) {
|
||||
$networkmap_id = (int)get_parameter('id', 0);
|
||||
|
||||
$return = array();
|
||||
$return['correct'] = false;
|
||||
$return['holding_area'] = array();
|
||||
|
||||
// ACL for the network map
|
||||
$id_group = db_get_value('id_group', 'tmap', 'id', $networkmap_id);
|
||||
// $networkmap_read = check_acl ($config['id_user'], $id_group, "MR");
|
||||
$networkmap_write = check_acl ($config['id_user'], $id_group, "MW");
|
||||
$networkmap_manage = check_acl ($config['id_user'], $id_group, "MM");
|
||||
|
||||
if (!$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap");
|
||||
echo json_encode($return);
|
||||
return;
|
||||
}
|
||||
|
||||
$data = networkmap_refresh_holding_area($networkmap_id);
|
||||
|
||||
if (!empty($data)) {
|
||||
$return['correct'] = true;
|
||||
$return['holding_area'] = $data;
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($update_fictional_node) {
|
||||
$networkmap_id = (int)get_parameter('networkmap_id', 0);
|
||||
$node_id = (int)get_parameter('node_id', 0);
|
||||
$name = get_parameter('name', "");
|
||||
$networkmap_to_link = (int)get_parameter('networkmap_to_link', 0);
|
||||
|
||||
$return = array();
|
||||
$return['correct'] = false;
|
||||
|
||||
// ACL for the network map
|
||||
$id_group = db_get_value('id_group', 'tmap', 'id', $networkmap_id);
|
||||
// $networkmap_read = check_acl ($config['id_user'], $id_group, "MR");
|
||||
$networkmap_write = check_acl ($config['id_user'], $id_group, "MW");
|
||||
$networkmap_manage = check_acl ($config['id_user'], $id_group, "MM");
|
||||
|
||||
if (!$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap");
|
||||
echo json_encode($return);
|
||||
return;
|
||||
}
|
||||
|
||||
$node = db_get_row('titem', 'id',
|
||||
$node_id);
|
||||
$node['style'] = json_decode($node['style'], true);
|
||||
$node['style']['label'] = $name;
|
||||
$node['style']['networkmap'] = $networkmap_to_link;
|
||||
$node['style'] = json_encode($node['style']);
|
||||
|
||||
$return['correct'] = (bool)db_process_sql_update(
|
||||
'titem', $node,
|
||||
array('id' => $node_id));
|
||||
echo json_encode($return);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($update_link) {
|
||||
$networkmap_id = (int)get_parameter('networkmap_id', 0);
|
||||
|
@ -163,111 +86,6 @@ if (is_ajax ()) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($get_intefaces) {
|
||||
$id_agent = (int)get_parameter('id_agent', 0);
|
||||
|
||||
$return = array();
|
||||
$return['correct'] = true;
|
||||
$return['interfaces'] = array();
|
||||
|
||||
$return['interfaces'] = modules_get_interfaces($id_agent,
|
||||
array('id_agente_modulo', 'nombre'));
|
||||
|
||||
echo json_encode($return);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($change_shape) {
|
||||
$networkmap_id = (int)get_parameter('networkmap_id', 0);
|
||||
$id = (int)get_parameter('id', 0);
|
||||
$shape = get_parameter('shape', 'circle');
|
||||
|
||||
$return = array();
|
||||
$return['correct'] = false;
|
||||
|
||||
// ACL for the network map
|
||||
$id_group = db_get_value('id_group', 'tmap', 'id', $networkmap_id);
|
||||
// $networkmap_read = check_acl ($config['id_user'], $id_group, "MR");
|
||||
$networkmap_write = check_acl ($config['id_user'], $id_group, "MW");
|
||||
$networkmap_manage = check_acl ($config['id_user'], $id_group, "MM");
|
||||
|
||||
if (!$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap");
|
||||
echo json_encode($return);
|
||||
return;
|
||||
}
|
||||
|
||||
$node = db_get_row_filter('titem',
|
||||
array('id_map' => $networkmap_id,
|
||||
'id' => $id));
|
||||
|
||||
$node['style'] = json_decode($node['style'], true);
|
||||
$node['style']['shape'] = $shape;
|
||||
$node['style'] = json_encode($node['style']);
|
||||
|
||||
$return['correct'] = db_process_sql_update('titem',
|
||||
$node, array('id_map' => $networkmap_id,
|
||||
'id' => $id));
|
||||
|
||||
echo json_encode($return);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($delete_link) {
|
||||
$source_id = (int)get_parameter('source_id', 0);
|
||||
$source_module_id = (int)get_parameter('source_module_id', 0);
|
||||
$target_id = (int)get_parameter('target_id', 0);
|
||||
$target_module_id = (int)get_parameter('target_module_id', 0);
|
||||
$networkmap_id = (int)get_parameter('networkmap_id', 0);
|
||||
$id_link = (int)get_parameter('id_link', 0);
|
||||
|
||||
|
||||
$return = array();
|
||||
$return['correct'] = false;
|
||||
|
||||
// ACL for the network map
|
||||
$id_group = db_get_value('id_group', 'tmap', 'id', $networkmap_id);
|
||||
// $networkmap_read = check_acl ($config['id_user'], $id_group, "MR");
|
||||
$networkmap_write = check_acl ($config['id_user'], $id_group, "MW");
|
||||
$networkmap_manage = check_acl ($config['id_user'], $id_group, "MM");
|
||||
|
||||
if (!$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap");
|
||||
echo json_encode($return);
|
||||
return;
|
||||
}
|
||||
|
||||
$return['correct'] = networkmap_delete_link(
|
||||
$networkmap_id,
|
||||
$source_id,
|
||||
$source_module_id,
|
||||
$target_id,
|
||||
$target_module_id,
|
||||
$id_link
|
||||
);
|
||||
|
||||
echo json_encode($return);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($delete_node) {
|
||||
$id = (int)get_parameter('id', 0);
|
||||
|
||||
$return = array();
|
||||
$return['correct'] = false;
|
||||
|
||||
$return['correct'] = erase_node(array('id' => $id));
|
||||
|
||||
echo json_encode($return);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($module_get_status) {
|
||||
$id = (int)get_parameter('id', 0);
|
||||
|
||||
|
@ -349,65 +167,6 @@ if (is_ajax ()) {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
if ($create_fictional_point) {
|
||||
$id = (int)get_parameter('id', 0);
|
||||
$x = (int)get_parameter('x', 0);
|
||||
$y = (int)get_parameter('y', 0);
|
||||
$name = io_safe_output(get_parameter('name', ''));
|
||||
$shape = get_parameter('shape', 0);
|
||||
$radious = (int)get_parameter('radious', 20);
|
||||
$color = get_parameter('color', 0);
|
||||
$networkmap = (int)get_parameter('networkmap', 0);
|
||||
|
||||
$return = array();
|
||||
$return['correct'] = false;
|
||||
|
||||
$data = array();
|
||||
$data['id_map'] = $id;
|
||||
$data['x'] = $x;
|
||||
$data['y'] = $y;
|
||||
$data['source_data'] = -2; //The id for the fictional points.
|
||||
$data['deleted'] = 0;
|
||||
//Type in db to fictional nodes
|
||||
$data['type'] = 3;
|
||||
$data['state'] = "";
|
||||
$style = array();
|
||||
$style['shape'] = $shape;
|
||||
$style['image'] = '';
|
||||
$style['width'] = $radious * 2;
|
||||
$style['height'] = $radious * 2;
|
||||
//WORK AROUND FOR THE JSON ENCODE WITH FOR EXAMPLE Ñ OR Á
|
||||
$style['label'] = 'json_encode_crash_with_ut8_chars';
|
||||
$style['color'] = $color;
|
||||
$style['networkmap'] = $networkmap;
|
||||
$data['style'] = json_encode($style);
|
||||
$data['style'] = str_replace(
|
||||
'json_encode_crash_with_ut8_chars', $name,
|
||||
$data['style']);
|
||||
|
||||
$id_node = db_process_sql_insert('titem',
|
||||
$data);
|
||||
|
||||
$return['correct'] = (bool)$id_node;
|
||||
|
||||
if ($return['correct']) {
|
||||
$return['id_node'] = $id_node;
|
||||
$return['id_agent'] = -2; //The finctional point id
|
||||
$return['shape'] = $shape;
|
||||
$return['image'] = '';
|
||||
$return['width'] = $radious * 2;
|
||||
$return['height'] = $radious * 2;
|
||||
$return['text'] = $name;
|
||||
$return['color'] = $color;
|
||||
$return['networkmap'] = $networkmap;
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($add_several_agents) {
|
||||
$id = (int)get_parameter('id', 0);
|
||||
$x = (int)get_parameter('x', 0);
|
||||
|
@ -507,7 +266,6 @@ if (is_ajax ()) {
|
|||
if ($get_tooltip_content) {
|
||||
$id = (int)get_parameter('id', 0);
|
||||
|
||||
|
||||
// Get all module from agent
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
|
@ -833,62 +591,6 @@ if (is_ajax ()) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($update_node_color) {
|
||||
$id = (int)get_parameter('id', 0);
|
||||
|
||||
$id_agent = db_get_value('source_data',
|
||||
'titem', 'id', $id);
|
||||
|
||||
$return = array();
|
||||
$return['correct'] = true;
|
||||
if ($id_agent != -2) {
|
||||
$return['color'] = get_status_color_networkmap($id_agent);
|
||||
}
|
||||
else {
|
||||
$style = db_get_value('style',
|
||||
'titem', 'id', $id);
|
||||
$style = json_decode($style, true);
|
||||
if ($style['networkmap'] == 0) {
|
||||
$return['color'] = $style['color'];
|
||||
}
|
||||
else {
|
||||
$return['color'] =
|
||||
get_status_color_networkmap_fictional_point(
|
||||
$style['networkmap']);
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($set_relationship) {
|
||||
$id = (int)get_parameter('id');
|
||||
$child = (int)get_parameter('child');
|
||||
$parent = (int)get_parameter('parent');
|
||||
|
||||
$correct = db_process_sql_insert(
|
||||
'trel_item',
|
||||
array('id_map' => $id,
|
||||
'id_parent' => $parent,
|
||||
'id_child' => $child));
|
||||
|
||||
$return = array();
|
||||
$return['correct'] = false;
|
||||
|
||||
if ($correct) {
|
||||
$return['correct'] = true;
|
||||
$return['id'] = $correct;
|
||||
$return['id_child'] = $child;
|
||||
$return['id_parent'] = $parent;
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($update_refresh_state) {
|
||||
$refresh_state = (int)get_parameter('refresh_state', 60);
|
||||
$id = (int)get_parameter('id', 0);
|
||||
|
@ -913,54 +615,6 @@ if (is_ajax ()) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($add_agent) {
|
||||
$id = (int)get_parameter('id', 0);
|
||||
$agent = get_parameter('agent', '');
|
||||
$x = (int)get_parameter('x', 0);
|
||||
$y = (int)get_parameter('y', 0);
|
||||
$id_agent = (int)get_parameter('id_agent', -1);
|
||||
if ($id_agent == -1)
|
||||
$id_agent = agents_get_agent_id($agent);
|
||||
|
||||
$return = array();
|
||||
$return['correct'] = false;
|
||||
|
||||
$return_data = add_agent_networkmap($id, $agent, $x, $y, $id_agent);
|
||||
|
||||
if ($return_data['id_node'] !== false) {
|
||||
$id_node = $return_data['id_node'];
|
||||
$return['correct'] = true;
|
||||
|
||||
$node = db_get_row('titem', 'id',
|
||||
$id_node);
|
||||
$style = json_decode($node['style'], true);
|
||||
|
||||
$return['id_node'] = $id_node;
|
||||
$return['id_agent'] = $node['source_data'];
|
||||
$return['parent'] = $node['parent'];
|
||||
$return['shape'] = $style['shape'];
|
||||
$return['image'] = $style['image'];
|
||||
$return['image_url'] = html_print_image(
|
||||
$style['image'], true, false, true);
|
||||
$return['width'] = $style['width'];
|
||||
$return['height'] = $style['height'];
|
||||
$return['text'] = $style['label'];
|
||||
$return['x'] = $x;
|
||||
$return['y'] = $y;
|
||||
$return['map_id'] = $node['id_map'];
|
||||
$return['state'] = $node['state'];
|
||||
$return['status'] = get_status_color_networkmap($id_agent);
|
||||
}
|
||||
|
||||
if (!empty($return_data['rel'])) {
|
||||
$return['rel'] = $return_data['rel'];
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($set_center) {
|
||||
$id = (int)get_parameter('id', 0);
|
||||
$x = (int)get_parameter('x', 0);
|
||||
|
@ -1063,8 +717,6 @@ if (is_ajax ()) {
|
|||
}
|
||||
//--------------END AJAX------------------------------------------------
|
||||
|
||||
|
||||
|
||||
$id = (int) get_parameter('id_networkmap', 0);
|
||||
|
||||
$networkmap = db_get_row('tmap', 'id', $id);
|
||||
|
|
Loading…
Reference in New Issue