diff --git a/pandora_console/images/reset.png b/pandora_console/images/reset.png new file mode 100644 index 0000000000..a3304f8263 Binary files /dev/null and b/pandora_console/images/reset.png differ diff --git a/pandora_console/include/functions_pandora_networkmap.php b/pandora_console/include/functions_pandora_networkmap.php index 0e0b9787b1..72f0805adf 100644 --- a/pandora_console/include/functions_pandora_networkmap.php +++ b/pandora_console/include/functions_pandora_networkmap.php @@ -477,6 +477,7 @@ function networkmap_db_node_to_js_node($node, &$count, &$count_item_holding_area $item['py'] = (int)$node['y']; $item['z'] = (int)$node['z']; $item['state'] = $node['state']; + $item['deleted'] = $node['deleted']; if ($item['state'] == 'holding_area') { //40 = DEFAULT NODE RADIUS //30 = for to align @@ -662,6 +663,7 @@ function networkmap_links_to_js_links($relations, $nodes_graph) { $item['id_agent_end'] = (int)$id_target_agent; $item['target'] = -1; $item['source'] = -1; + $item['deleted'] = $relation['deleted']; if (enterprise_installed()) { $target_and_source = array(); @@ -859,7 +861,9 @@ function networkmap_write_js_array($id, $nodes_and_relations = array(), $map_das $item = networkmap_db_node_to_js_node( $node, $count, $count_item_holding_area); - + if ($item['deleted']) { + continue; + } echo "networkmap.nodes.push(" . json_encode($item) . ");\n"; $nodes_graph[$item['id']] = $item; } @@ -875,6 +879,9 @@ function networkmap_write_js_array($id, $nodes_and_relations = array(), $map_das $links_js = networkmap_links_to_js_links($relations, $nodes_graph); foreach ($links_js as $link_js) { + if ($link_js['deleted']) { + continue; + } if ($link_js['target'] == -1) continue; if ($link_js['source'] == -1) @@ -932,6 +939,12 @@ function networkmap_write_js_array($id, $nodes_and_relations = array(), $map_das echo "var set_center_menu = '" . __('Set center') . "';\n"; echo "var refresh_menu = '" . __('Refresh') . "';\n"; echo "var refresh_holding_area_menu = '" . __('Refresh Holding area') . "';\n"; + echo "var ok_button = '" . __('Proceed') . "';\n"; + echo "var message_to_confirm = '" . __('Resetting the map will delete all customizations you have done, including manual relationships between elements, new items, etc.') . "';\n"; + echo "var warning_message = '" . __('WARNING') . "';\n"; + echo "var ok_button = '" . __('Proceed') . "';\n"; + echo "var cancel_button = '" . __('Cancel') . "';\n"; + echo "var restart_map_menu = '" . __('Restart map') . "';\n"; echo "var abort_relationship_interface = '" . __('Abort the interface relationship') . "';\n"; echo "var abort_relationship_menu = '" . __('Abort the action of set relationship') . "';\n"; diff --git a/pandora_console/include/javascript/functions_pandora_networkmap.js b/pandora_console/include/javascript/functions_pandora_networkmap.js index 6b4cd0d415..05ebe8e9d9 100644 --- a/pandora_console/include/javascript/functions_pandora_networkmap.js +++ b/pandora_console/include/javascript/functions_pandora_networkmap.js @@ -1900,6 +1900,21 @@ function show_menu(item, data) { refresh_holding_area(); } }; + items_list["restart_map"] = { + name: restart_map_menu, + icon: "restart_map", + disabled: function () { + if (enterprise_installed) { + return false; + } + else { + return true; + } + }, + "callback": function (key, options) { + restart_map(networkmap_id); + } + }; if (flag_setting_relationship_running) { items_list["cancel_set_parent"] = { @@ -2140,6 +2155,7 @@ function refresh_holding_area() { temp_node['image_url'] = node['image_url']; temp_node['image_width'] = node['image_width']; temp_node['image_height'] = node['image_width']; + temp_node['deleted'] = false; graph.nodes.push(temp_node); }); @@ -2210,6 +2226,123 @@ function refresh_holding_area() { } } +function restart_map (map_id) { + $("
").dialog ({ + resizable: true, + draggable: true, + modal: true, + overlay: { + opacity: 0.5, + background: 'black' + }, + width: 600, + height: 250, + buttons: [ + { + text: ok_button, + click: function () { + $(this).dialog("close"); + proceed_to_restart_map(map_id); + } + }, + { + text:cancel_button, + click: function () { + $(this).dialog("close"); + } + } + ] + }); + + var dialog_confirm_text = "
"; + dialog_confirm_text = dialog_confirm_text + "
"; + dialog_confirm_text = dialog_confirm_text + "

" + warning_message + "

"; + dialog_confirm_text = dialog_confirm_text + "

" + message_to_confirm + "

"; + dialog_confirm_text = dialog_confirm_text + "
"; + + $('#restart_map_confirm').html(dialog_confirm_text); + $('#restart_map_confirm').dialog('open'); +} + +function proceed_to_restart_map (map_id) { + $("
").dialog ({ + resizable: true, + draggable: true, + modal: true, + overlay: { + opacity: 0.5, + background: 'black' + }, + width: 600, + height: 450, + buttons: [ + { + text: ok_button, + click: function () { + $(this).dialog("close"); + var new_elements = []; + new_elements[0] = $("#text-name").val(); + new_elements[1] = $("#id_group").val(); + new_elements[2] = $("#text-node_radius").val(); + new_elements[3] = $("#textarea_description").val(); + new_elements[4] = $("input[name=source]:checked").val(); + if (new_elements[4] == 'group') { + new_elements[5] = $("#checkbox-dont_show_subgroups").is(':checked'); + } + else if (new_elements[4] == 'recon_task') { + new_elements[5] = $("#recon_task_id").val(); + } + else { + new_elements[5] = $("#text-ip_mask").val(); + } + new_elements[6] = $("#method").val(); + reset_map_from_form(map_id, new_elements); + } + }, + { + text:cancel_button, + click: function () { + $(this).dialog("close"); + } + } + ] + }); + + var params = []; + params.push("get_reset_map_form=1"); + params.push("map_id=" + map_id); + params.push("page=enterprise/operation/agentes/pandora_networkmap.view"); + jQuery.ajax({ + data: params.join("&"), + dataType: 'html', + type: 'POST', + url: action = "ajax.php", + success: function (data) { + $('#restart_map_form').html(data); + $('#restart_map_form').dialog('open'); + } + }); +} + +function reset_map_from_form (map_id, new_elements) { + var params = []; + params.push("reset_map=1"); + params.push("map_id=" + map_id); + params.push("elems[]=" + new_elements) + 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['error']) { + location.reload(true); + } + } + }); +} + function set_parent(parent_data) { if (enterprise_installed) { var selection = d3.selectAll('.node_children'); @@ -3017,9 +3150,18 @@ function myMouseoutRhombusFunction(node_id) { } function draw_elements_graph() { - link = link.data(force.links(), function (d) { - return d.source.id + networkmap_id + "-" + d.target.id + networkmap_id + Math.random(); + link = link.data(force.links().filter(function(d, i) { + if (d['deleted']) { + return false; + } + else { + return true; + } + }), + function (d) { + return d.source.id + networkmap_id + "-" + d.target.id + networkmap_id + Math.random(); }); + link_temp = link.enter() .append("g") @@ -3201,7 +3343,14 @@ function draw_elements_graph() { return (Array(25).join(" ")) + text_link; }); - node = node.data(force.nodes(), function (d) { return d.id; }); + node = node.data(force.nodes().filter(function(d, i) { + if (d['deleted']) { + return false; + } + else { + return true; + } + }), function (d) { return d.id; }); node_temp = node.enter() .append("g") diff --git a/pandora_console/include/javascript/jquery.contextMenu.css b/pandora_console/include/javascript/jquery.contextMenu.css index 3a844d4a7e..b0b04223bf 100644 --- a/pandora_console/include/javascript/jquery.contextMenu.css +++ b/pandora_console/include/javascript/jquery.contextMenu.css @@ -117,6 +117,7 @@ .context-menu-item.icon-set_parent { background-image: url(../../images/father.png); } .context-menu-item.icon-add_node { background-image: url(../../images/add.png); } .context-menu-item.icon-refresh_holding_area { background-image: url(../../images/refresh_holding_area.png); } +.context-menu-item.icon-restart_map { background-image: url(../../images/reset.png); } .context-menu-item.icon-interface_link_children { background-image: url(../../images/icono_link_hijo.png); } .context-menu-item.icon-interface_link_parent { background-image: url(../../images/icono_link_padre.png); } .context-menu-item.icon-interface_link_cancel { background-image: url(../../images/link_abortar.png); }