From eb9390cad645f1cb4820088488aad893f4cf00f7 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Mon, 10 Oct 2016 16:11:15 +0200 Subject: [PATCH] New networkmaps in progress... (Added new migration system and new design elements to js) --- .../include/functions_networkmap.php | 2 +- .../include/functions_pandora_networkmap.php | 92 +++++++++++-------- .../functions_pandora_networkmap.js | 20 +++- .../operation/agentes/pandora_networkmap.php | 55 ++++++----- 4 files changed, 101 insertions(+), 68 deletions(-) diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 62e38e81b4..6b15127e76 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -1468,7 +1468,7 @@ function networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, $head .= "ratio=fill;"; $head .= "root=0;"; - $head .= "nodesep=\"0.5\";"; + $head .= "nodesep=\"0.02\";"; $head .= "size=\"$size\";"; $head .= "\n"; diff --git a/pandora_console/include/functions_pandora_networkmap.php b/pandora_console/include/functions_pandora_networkmap.php index 4542d23077..eeafd6dd65 100644 --- a/pandora_console/include/functions_pandora_networkmap.php +++ b/pandora_console/include/functions_pandora_networkmap.php @@ -1152,48 +1152,62 @@ function is_in_rel_array ($relations, $relation) { return $is_in_array; } -function migrate_older_open_maps() { - global $config; +function map_migrated($id) { + $new_maps = db_get_all_rows_sql("SELECT filter FROM tmap"); + $new_map_filter = json_decode($new_maps, true); - $older_networkmaps = db_get_all_rows_sql("SELECT * FROM tnetwork_map"); - - foreach ($older_networkmaps as $old_networkmap) { - $map_values = array(); - $map_values['id_group'] = $old_networkmap['id_group']; - $map_values['id_user'] = $old_networkmap['id_user']; - $map_values['type'] = 0; - $map_values['subtype'] = 0; - $map_values['name'] = $old_networkmap['name']; - - $new_map_filter = array(); - $new_map_filter['dont_show_subgroups'] = $old_networkmap['dont_show_subgroups']; - $new_map_filter['node_radius'] = 40; - $map_values['filter'] = json_encode($new_map_filter); - - $map_values['description'] = "Mapa open migrado"; - $map_values['width'] = 4000; - $map_values['height'] = 4000; - $map_values['center_x'] = 2000; - $map_values['center_y'] = 2000; - $map_values['background'] = ""; - $map_values['background_options'] = 0; - $map_values['source_period'] = 60; - $map_values['source'] = 0; - $map_values['source_data'] = $old_networkmap['id_group']; - if ($old_networkmap['type'] == 'radial_dinamic') { - $map_values['generation_method'] = 6; - } - else { - $map_values['generation_method'] = 4; - } - $map_values['generated'] = 0; - - $id_new_map = db_process_sql_insert('tmap', $map_values); - - if (!$id_new_map) { - return false; + foreach ($new_map_filter as $filter) { + if ((isset($filter['id_migrate_map'])) && ($filter['id_migrate_map'] == $id)) { + return true; } } + + return false; +} + +function migrate_older_open_maps($id) { + global $config; + + $old_networkmap = db_get_row_filter('tnetwork_map', + array('id_networkmap' => $id)); + + $map_values = array(); + $map_values['id_group'] = $old_networkmap['id_group']; + $map_values['id_user'] = $old_networkmap['id_user']; + $map_values['type'] = 0; + $map_values['subtype'] = 0; + $map_values['name'] = $old_networkmap['name']; + + $new_map_filter = array(); + $new_map_filter['dont_show_subgroups'] = $old_networkmap['dont_show_subgroups']; + $new_map_filter['node_radius'] = 40; + $new_map_filter['id_migrate_map'] = $id; + $map_values['filter'] = json_encode($new_map_filter); + + $map_values['description'] = "Mapa open migrado"; + $map_values['width'] = 4000; + $map_values['height'] = 4000; + $map_values['center_x'] = 2000; + $map_values['center_y'] = 2000; + $map_values['background'] = ""; + $map_values['background_options'] = 0; + $map_values['source_period'] = 60; + $map_values['source'] = 0; + $map_values['source_data'] = $old_networkmap['id_group']; + if ($old_networkmap['type'] == 'radial_dinamic') { + $map_values['generation_method'] = 6; + } + else { + $map_values['generation_method'] = 4; + } + $map_values['generated'] = 0; + + $id_new_map = db_process_sql_insert('tmap', $map_values); + + if (!$id_new_map) { + return false; + } + return true; } diff --git a/pandora_console/include/javascript/functions_pandora_networkmap.js b/pandora_console/include/javascript/functions_pandora_networkmap.js index 638200af69..e7e02c72fb 100644 --- a/pandora_console/include/javascript/functions_pandora_networkmap.js +++ b/pandora_console/include/javascript/functions_pandora_networkmap.js @@ -1049,13 +1049,18 @@ function set_positions_graph() { .attr("y", function(d) { return d.y - (d.image_height / 2); }); - + + var position_text = 40; + if (node_radius > 100) { + position_text = 60; + } + node.selectAll(".node_text") .attr("x", function(d) { return d.x; }) .attr("y", function(d) { - return d.y + node_radius + 24; + return d.y + node_radius + position_text; }); draw_minimap(); @@ -2661,10 +2666,15 @@ function draw_elements_graph() { node_temp.append("title") .text(function(d) {return d.text; }); - + + var font_size = "32px"; + if (node_radius > 100) { + font_size = "64px"; + } + node_temp.append("text") .attr("class", "node_text") - .attr("style", "font-size: 32px; font-style:normal; font-weight:normal; line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Verdana") + .attr("style", "font-style:normal; font-weight:normal; line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;") .attr("x", function(d) { return d.x; }) @@ -2672,7 +2682,7 @@ function draw_elements_graph() { return d.y + node_radius + 12; }) .append("tspan") - .attr("style", "text-align:center; text-anchor:middle; fill:#000000") + .attr("style", "font-size: " + font_size + " !important; font-family:Verdana; text-align:center; text-anchor:middle; fill:#000000") .text(function(d) { return d.text; }) diff --git a/pandora_console/operation/agentes/pandora_networkmap.php b/pandora_console/operation/agentes/pandora_networkmap.php index 16a7dbc317..f764cef1a9 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.php +++ b/pandora_console/operation/agentes/pandora_networkmap.php @@ -37,7 +37,6 @@ $update_networkmap = (bool) get_parameter('update_networkmap', false); $copy_networkmap = (bool) get_parameter('copy_networkmap', false); $delete = (bool) get_parameter('delete', false); $tab = (string) get_parameter('tab', 'list'); -$migrate_networkmap = (string) get_parameter('migrate_networkmap', false); $result_txt = ''; // The networkmap doesn't exist yet @@ -271,19 +270,6 @@ else if ($update_networkmap || $copy_networkmap || $delete) { true); } } -else if ($migrate_networkmap) { - $result = migrate_older_open_maps(); - - if (enterprise_installed()) { - enterprise_include_once ('include/functions_pandora_networkmap.php'); - - $result = migrate_older_networkmap_enterprise(); - } - - $result_txt = ui_print_result_message($result, - __('Succesfully migrated (New map, I AM YOUR FATHER)'), __('Could not be migrated'), '', - true); -} switch ($tab) { case 'edit': @@ -293,6 +279,38 @@ switch ($tab) { require('pandora_networkmap.view.php'); break; case 'list': + $old_networkmaps_enterprise = array(); + $old_networkmaps_open = array(); + + if (enterprise_installed()) { + $old_networkmaps_enterprise = db_get_all_rows_sql("SELECT id FROM tnetworkmap_enterprise"); + } + $old_networkmaps_open = db_get_all_rows_sql("SELECT id_networkmap FROM tnetwork_map"); + + foreach ($old_networkmaps_enterprise as $old_map_ent) { + if (!map_migrated($old_map_ent['id'])) { + if (enterprise_installed()) { + enterprise_include_once ('include/functions_pandora_networkmap.php'); + + $return = migrate_older_networkmap_enterprise($old_map_ent['id']); + + if (!$return) { + break; + } + } + } + } + + foreach ($old_networkmaps_enterprise as $old_map_ent) { + if (!map_migrated($old_map_ent['id'])) { + $return = migrate_older_open_maps($old_map_ent['id']); + } + + if (!$return) { + break; + } + } + ui_print_page_header(__('Networkmap'), "images/op_network.png", false, "network_map_enterprise", false); @@ -376,7 +394,6 @@ switch ($tab) { $network_map['name'] . ''; } - if ($network_map['id_group'] > 0) { $nodes = db_get_all_rows_sql("SELECT style FROM titem WHERE id_map = " . $network_map['id'] . " AND deleted = 0"); $count = 0; @@ -394,7 +411,6 @@ switch ($tab) { WHERE id_map = ' . $network_map['id'] . ' AND deleted = 0'); } - if (empty($count)) $count = 0; @@ -445,13 +461,6 @@ switch ($tab) { html_print_submit_button (__('Create networkmap'), 'crt', false, 'class="sub next" style="float: right;"'); echo ""; echo ""; - - echo "
"; - echo '
'; - html_print_input_hidden ('migrate_networkmap', 1); - html_print_submit_button (__('Migrate older networkmaps'), 'crt', false, 'class="sub next" style="float: left;"'); - echo "
"; - echo "
"; } break;