From 12203f9c2b13127ec466a80c309a105263002633 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Mon, 3 Apr 2017 14:20:11 +0200 Subject: [PATCH] Added time improvements to networkmaps --- .../include/functions_pandora_networkmap.php | 3 - .../functions_pandora_networkmap.js | 337 +++++++++--------- 2 files changed, 167 insertions(+), 173 deletions(-) diff --git a/pandora_console/include/functions_pandora_networkmap.php b/pandora_console/include/functions_pandora_networkmap.php index beaf806953..a0897f0602 100644 --- a/pandora_console/include/functions_pandora_networkmap.php +++ b/pandora_console/include/functions_pandora_networkmap.php @@ -1335,7 +1335,6 @@ function show_networkmap($id = 0, $user_readonly = false, $nodes_and_relations = //////////////////////////////////////////////////////////////////////// $(document).ready(function() { init_graph({ - refesh_period: networkmap_refresh_time, graph: networkmap, networkmap_center: networkmap_center, networkmap_dimensions: networkmap_dimensions, @@ -1348,8 +1347,6 @@ function show_networkmap($id = 0, $user_readonly = false, $nodes_and_relations = init_minimap(); function_open_minimap(); - window.interval_obj = setInterval(update_networkmap, networkmap_refresh_time); - $(document.body).on("mouseleave", ".context-menu-list", function(e) { diff --git a/pandora_console/include/javascript/functions_pandora_networkmap.js b/pandora_console/include/javascript/functions_pandora_networkmap.js index 767e637fa2..86ab6bd914 100644 --- a/pandora_console/include/javascript/functions_pandora_networkmap.js +++ b/pandora_console/include/javascript/functions_pandora_networkmap.js @@ -618,7 +618,7 @@ function add_new_link (new_link) { graph.links.push(new_link); } -function edit_node(data, dblClick) { +function edit_node(data_node, dblClick) { if (enterprise_installed) { var flag_edit_node = true; var edit_node = null @@ -633,7 +633,7 @@ function edit_node(data, dblClick) { edit_node = selection[0].pop(); } else if (dblClick){ - edit_node = d3.select("#id_node_" + data['id'] + networkmap_id); + edit_node = d3.select("#id_node_" + data_node['id'] + networkmap_id); edit_node = edit_node[0][0]; } else { @@ -654,21 +654,22 @@ function edit_node(data, dblClick) { selected_links = get_relations(node_selected); - $("select[name='shape'] option[value='" + data.shape + "']") + $("select[name='shape'] option[value='" + node_selected.shape + "']") .prop("selected", true); $("select[name='shape']").attr("onchange", - "javascript: change_shape(" + data.id_db + ");"); + "javascript: change_shape(" + node_selected.id_db + ");"); $("#node_options-fictional_node_update_button-1 input") - .attr("onclick", "update_fictional_node(" + data.id_db + ");"); + .attr("onclick", "update_fictional_node(" + node_selected.id_db + ");"); $("#node_options-node_name-2 input") - .attr("onclick", "update_node_name(" + data.id_db + ");"); + .attr("onclick", "update_node_name(" + node_selected.id_db + ");"); - $("#node_details-0-1").html('' + data["text"] + ''); + $("#node_details-0-1").html('' + node_selected["text"] + ''); var params = []; params.push("get_agent_info=1"); - params.push("id_agent=" + data["id_agent"]); + params.push("id_agent=" + node_selected["id_agent"]); params.push("page=enterprise/operation/agentes/pandora_networkmap.view"); + jQuery.ajax ({ data: params.join ("&"), dataType: 'json', @@ -682,69 +683,29 @@ function edit_node(data, dblClick) { $("#node_details-1-1").html(adressess); $("#node_details-2-1").html(data["os"]); $("#node_details-3-1").html(data["group"]); - }, - success: function(){ + $('[aria-describedby=dialog_node_edit]').css({'top':'200px'}); $('#foot').css({'top':parseInt($("[aria-describedby=dialog_node_edit]").css('height')+$("[aria-describedby=dialog_node_edit]").css('top')),'position':'relative'}); - } - }); - - $("#interface_information").find("tr:gt(0)").remove(); - - var params = []; - params.push("get_interface_info=1"); - params.push("id_agent=" + data["id_agent"]); - params.push("page=enterprise/operation/agentes/pandora_networkmap.view"); - jQuery.ajax ({ - data: params.join ("&"), - dataType: 'json', - type: 'POST', - url: action="ajax.php", - success: function (data) { - if (data.length == 0) { - $("#interface_information").find('tbody') - .append($('').html("

It has no interface to display

")); - } - else { - jQuery.each(data, function(j, interface) { - $("#interface_information").find('tbody') - .append($('') - .append($('') - .html(interface['name']) - ) - .append($('') - .html(interface['status']) - ) - .append($('') - .html(interface['graph']) - ) - .append($('') - .html(interface['ip']) - ) - .append($('') - .html(interface['mac']) - ) - ); - }); - } + + get_interface_data_to_table(node_selected, selected_links); } }); $("#dialog_node_edit" ) .dialog( "option", "title", - dialog_node_edit_title.replace("%s", data.text)); + dialog_node_edit_title.replace("%s", node_selected.text)); $("#dialog_node_edit").dialog("open"); - if (data.id_agent == undefined || data.id_agent == -2) { + if (node_selected.id_agent == undefined || node_selected.id_agent == -2) { //Fictional node $("#node_options-fictional_node_name") .css("display", ""); $("input[name='edit_name_fictional_node']") - .val(data.text); + .val(node_selected.text); $("#node_options-fictional_node_networkmap_link") .css("display", ""); $("#edit_networkmap_to_link") - .val(data.networkmap_id); + .val(node_selected.networkmap_id); $("#node_options-fictional_node_update_button") .css("display", ""); $("#node_options-node_name") @@ -754,7 +715,7 @@ function edit_node(data, dblClick) { } else { $("input[name='edit_name_node']") - .val(data.text); + .val(node_selected.text); $("#node_options-fictional_node_name") .css("display", "none"); $("#node_options-fictional_node_networkmap_link") @@ -770,124 +731,160 @@ function edit_node(data, dblClick) { //Show the no relations $("#relations_table-loading").css('display', 'none'); $("#relations_table-no_relations").css('display', ''); - - - jQuery.each(selected_links, function(i, link_each) { - - $("#relations_table-no_relations").css('display', 'none'); - $("#relations_table-loading").css('display', ''); - - var template_relation_row = $("#relations_table-template_row") - .clone(); - - $(template_relation_row).css('display', ''); - $(template_relation_row).attr('class', 'relation_link_row'); - - $("select[name='interface_source']", template_relation_row) - .attr('name', "interface_source_" + i) - .attr('id', "interface_source_" + i); - $("select[name='interface_target']", template_relation_row) - .attr('name', "interface_target_" + i) - .attr('id', "interface_target_" + i); - $(".edit_icon_progress", template_relation_row) - .attr('class', "edit_icon_progress_" + i); - $(".edit_icon", template_relation_row) - .attr('class', "edit_icon_" + i); - $(".edit_icon_correct", template_relation_row) - .attr('class', "edit_icon_correct_" + i); - $(".edit_icon_fail", template_relation_row) - .attr('class', "edit_icon_fail_" + i); - $(".edit_icon_link", template_relation_row) - .attr('class', "edit_icon_link_" + i) - .click(function() { - update_link(i, link_each.id_db); - } - ); - - var params = []; - params.push("get_intefaces=1"); - params.push("id_agent=" + link_each.source.id_agent); - params.push("page=enterprise/operation/agentes/pandora_networkmap.view"); - - jQuery.ajax ({ - data: params.join ("&"), - dataType: 'json', - type: 'POST', - url: action="ajax.php", - success: function (data) { - if (data['correct']) { - $("select[name='interface_source_" + i + "']", template_relation_row).empty(); - $("select[name='interface_source_" + i + "']", template_relation_row).append(''); - jQuery.each(data['interfaces'], function(j, interface) { - - $("select[name='interface_source_" + i + "']", template_relation_row) - .append($("'); - jQuery.each(data['interfaces'], function(j, interface) { - $("select[name='interface_target_" + i + "']", template_relation_row) - .append($("'); + + $("select[name='interface_source_" + i + "']", template_relation_row).empty(); + $("select[name='interface_source_" + i + "']", template_relation_row).append(''); + jQuery.each(data['target_interfaces'], function(j, interface) { + $("select[name='interface_target_" + i + "']", template_relation_row) + .append($("