From 56a2970755e1a9e3d24e96c2585626e5bce0525e Mon Sep 17 00:00:00 2001 From: Luis Date: Thu, 6 Feb 2020 14:32:43 +0100 Subject: [PATCH] Ent 5112 error nodos ficticios widget mapa red --- .../include/class/NetworkMap.class.php | 10 +++ .../functions_pandora_networkmap.js | 82 ++++++++++++++----- 2 files changed, 73 insertions(+), 19 deletions(-) diff --git a/pandora_console/include/class/NetworkMap.class.php b/pandora_console/include/class/NetworkMap.class.php index 43fb9138c7..c4952ae58d 100644 --- a/pandora_console/include/class/NetworkMap.class.php +++ b/pandora_console/include/class/NetworkMap.class.php @@ -226,6 +226,13 @@ class NetworkMap */ public $tooltipParams; + /** + * Defines if map is widget or not for JS + * + * @var boolean; + */ + public $widget; + /** * Shows the map using 100% of height and width if is a widget. * @@ -406,8 +413,10 @@ class NetworkMap // Initialize as widget? if (isset($options['widget'])) { $this->fullSize = (bool) $options['widget']; + $this->widget = true; } else { $this->fullSize = true; + $this->widget = false; } // Use a custom parser. @@ -2689,6 +2698,7 @@ class NetworkMap $this->cleanGraphRelations(); // Print some params to handle it in js. + html_print_input_hidden('widget', $this->widget); html_print_input_hidden('product_name', get_product_name()); html_print_input_hidden('center_logo', ui_get_full_url(ui_get_logo_to_center_networkmap())); diff --git a/pandora_console/include/javascript/functions_pandora_networkmap.js b/pandora_console/include/javascript/functions_pandora_networkmap.js index f45ebe3463..539eeb1cea 100644 --- a/pandora_console/include/javascript/functions_pandora_networkmap.js +++ b/pandora_console/include/javascript/functions_pandora_networkmap.js @@ -738,27 +738,36 @@ function add_new_link(new_link) { } function move_to_networkmap(node) { - var params = []; - params.push("get_networkmap_from_fictional=1"); - params.push("id=" + node.id_db); - params.push("id_map=" + node.map_id); - params.push("page=enterprise/operation/agentes/pandora_networkmap.view"); + // Checks if is widget or not + var widget = false; + widget = $("#hidden-widget").val(); - jQuery.ajax({ - data: params.join("&"), - dataType: "json", - type: "POST", - url: "ajax.php", - success: function(data) { - if (data["correct"]) { - window.location = - "index.php?sec=network&sec2=operation/agentes/pandora_networkmap&tab=view&id_networkmap=" + - data["id_networkmap"]; - } else { - edit_node(node, true); + if (widget == true) { + var id_cell = $(".widget_content").data("id_cell"); + move_to_networkmap_widget(node.networkmap_id, id_cell); + } else { + var params = []; + params.push("get_networkmap_from_fictional=1"); + params.push("id=" + node.id_db); + params.push("id_map=" + node.map_id); + params.push("page=enterprise/operation/agentes/pandora_networkmap.view"); + + jQuery.ajax({ + data: params.join("&"), + dataType: "json", + type: "POST", + url: "ajax.php", + success: function(data) { + if (data["correct"]) { + window.location = + "index.php?sec=network&sec2=operation/agentes/pandora_networkmap&tab=view&id_networkmap=" + + data["id_networkmap"]; + } else { + edit_node(node, true); + } } - } - }); + }); + } } function edit_node(data_node, dblClick) { @@ -4516,3 +4525,38 @@ function update_fictional_node_popup(id) { color ); } + +function move_to_networkmap_widget(networkmap_id, id_cell) { + var params = []; + + $(".widget_content").each(function(i) { + $("#body_cell").empty(); + }); + + var pathname = window.location.pathname; + var path; + + if ( + pathname == "/pandora_console/enterprise/dashboard/public_dashboard.php" + ) { + path = "../../ajax.php"; + } else { + path = "ajax.php"; + } + + params.push("networkmap=true"); + params.push("networkmap_id=" + networkmap_id); + + params.push("page=enterprise/include/ajax/map_enterprise.ajax"); + jQuery.ajax({ + data: params.join("&"), + dataType: "html", + type: "POST", + url: path, + success: function(data) { + $(".widget_content").each(function(i) { + $("#body_cell").append(data); + }); + } + }); +}