diff --git a/pandora_console/images/background_grid.png b/pandora_console/images/background_grid.png
new file mode 100644
index 0000000000..ad624e7761
Binary files /dev/null and b/pandora_console/images/background_grid.png differ
diff --git a/pandora_console/include/javascript/functions_pandora_networkmap.js b/pandora_console/include/javascript/functions_pandora_networkmap.js
new file mode 100644
index 0000000000..dbc9ee5f32
--- /dev/null
+++ b/pandora_console/include/javascript/functions_pandora_networkmap.js
@@ -0,0 +1,3124 @@
+
+function draw_minimap() {
+ //Clean the canvas
+ context_minimap.clearRect(0, 0, minimap_w, minimap_h);
+
+ context_minimap.beginPath();
+ context_minimap.globalAlpha = 0.8;
+ context_minimap.fillStyle = "#ddd";
+ context_minimap.fillRect(0, 0, minimap_w, minimap_h);
+
+
+ //Draw the items and lines
+ jQuery.each(graph.nodes, function (key, value) {
+ if (typeof(value) == 'undefined') return;
+
+ context_minimap.beginPath();
+ //Paint the item
+ center_orig_x = (value.x + value.image_width / 2) * minimap_relation;
+ center_orig_y = (value.y + value.image_height / 2) * minimap_relation;
+
+ context_minimap.arc(center_orig_x,
+ center_orig_y, 2, 0, Math.PI * 2, false);
+ //Check if the pandora point
+ if (value.id_agent == -1) {
+ context_minimap.fillStyle = "#364D1F";
+ }
+ else {
+ context_minimap.fillStyle = "#000";
+ }
+ context_minimap.fill();
+ });
+
+
+ //Draw the rect of viewport
+ context_minimap.beginPath();
+ context_minimap.strokeStyle = "#f00";
+ context_minimap.strokeRect(
+ (-translation[0] / scale) * minimap_relation,
+ (-translation[1] / scale) * minimap_relation,
+ width_svg * minimap_relation / scale,
+ height_svg * minimap_relation / scale);
+
+ context_minimap.beginPath();
+ context_minimap.strokeStyle = "#0f0";
+ context_minimap.strokeRect(
+ (networkmap_dimensions[0] + node_radius - holding_area_dimensions[0]) * minimap_relation,
+ (networkmap_dimensions[1] + node_radius - holding_area_dimensions[1]) * minimap_relation,
+ holding_area_dimensions[0] * minimap_relation,
+ holding_area_dimensions[1] * minimap_relation)
+
+ context_minimap.globalAlpha = 1;
+}
+
+function inner_minimap_box(param_x, param_y) {
+ if ((param_x + translation[0] * minimap_relation >= 0)
+ && (param_x + translation[0] * minimap_relation <= width_svg * minimap_relation)
+ && (param_y + translation[1] * minimap_relation >= 0)
+ && (param_y + translation[1] * minimap_relation <= height_svg * minimap_relation)) {
+ return true;
+ }
+
+ return false;
+}
+
+function set_center(id) {
+ pos_x = (width_svg / 2) - translation[0];
+ pos_y = (height_svg / 2) - translation[1];
+
+ var params = [];
+ params.push("set_center=1");
+ params.push("id=" + id);
+ params.push("x=" + pos_x);
+ params.push("y=" + pos_y);
+ params.push("page=operation/agentes/pandora_networkmap.view");
+ jQuery.ajax ({
+ data: params.join ("&"),
+ dataType: 'json',
+ type: 'POST',
+ url: action="ajax.php",
+ success: function (data) {
+ if (data['correct']) {
+ }
+ }
+ });
+}
+
+function get_relations(node_param) {
+ var return_links = [];
+ jQuery.each(graph.links, function(i, link_each) {
+ if (node_param.id == link_each.source.id) {
+ return_links.push(link_each);
+ }
+ else if (node_param.id == link_each.target.id) {
+ return_links.push(link_each);
+ }
+ });
+
+ return return_links;
+}
+
+function delete_link(source_id, source_module_id, target_id, target_module_id, id_link) {
+ var params = [];
+ params.push("delete_link=1");
+ params.push("networkmap_id=" + networkmap_id);
+ params.push("source_id=" + source_id);
+ params.push("source_module_id=" + source_module_id);
+ 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");
+ jQuery.ajax ({
+ data: params.join ("&"),
+ dataType: 'json',
+ type: 'POST',
+ url: action="ajax.php",
+ success: function (data) {
+ if (data['correct']) {
+
+ 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();
+ }
+
+ $("#dialog_node_edit").dialog("close");
+ }
+ });
+}
+
+function update_fictional_node(id_db_node) {
+ var name = $("input[name='edit_name_fictional_node']").val();
+ var networkmap_to_link = $("#edit_networkmap_to_link").val();
+
+ var params = [];
+ params.push("update_fictional_node=1");
+ params.push("networkmap_id=" + networkmap_id);
+ 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");
+
+ jQuery.ajax ({
+ data: params.join ("&"),
+ dataType: 'json',
+ type: 'POST',
+ url: action="ajax.php",
+ success: function (data) {
+ if (data['correct']) {
+ $("#dialog_node_edit").dialog("close");
+
+ jQuery.each(graph.nodes, function(i, element) {
+ if (element.id_db == id_db_node) {
+ graph.nodes[i].text = name;
+ graph.nodes[i].networkmap_id = networkmap_to_link;
+
+ $("#id_node_" + i + " title").html(name);
+ $("#id_node_" + i + " tspan").html(name);
+ }
+ });
+
+ draw_elements_graph();
+ set_positions_graph();
+ }
+ }
+ });
+}
+
+function change_shape(id_db_node) {
+ var shape = $("select[name='shape']").val();
+
+ var params = [];
+ params.push("change_shape=1");
+ params.push("networkmap_id=" + networkmap_id);
+ params.push("id=" + id_db_node);
+ params.push("shape=" + shape);
+ params.push("page=operation/agentes/pandora_networkmap.view");
+
+ $("#shape_icon_correct").css("display", "none");
+ $("#shape_icon_fail").css("display", "none");
+ $("#shape_icon_in_progress").css("display", "");
+
+ jQuery.ajax ({
+ data: params.join ("&"),
+ dataType: 'json',
+ type: 'POST',
+ url: action="ajax.php",
+ success: function (data) {
+ $("#shape_icon_in_progress").css("display", "none");
+ if (data['correct']) {
+ $("#shape_icon_correct").css("display", "");
+
+ count = graph.nodes.length;
+
+ jQuery.each(graph.nodes, function(i, element) {
+ if (element.id_db == id_db_node) {
+ graph.nodes[i].shape = shape;
+
+ $("#id_node_" + i + " rect").remove();
+ $("#id_node_" + i + " circle").remove();
+
+ if (shape == 'circle') {
+ d3.select("#id_node_" + element.id)
+ .insert("circle", "title")
+ .attr("r", node_radius)
+ .attr("class", "node_shape node_shape_circle")
+ .style("fill", function(d) {
+ return d.color;
+ })
+ .classed('dragable_node', true) //own dragable
+ .on("mouseover", over_node)
+ .on("mouseout", over_node)
+ .on("click", selected_node)
+ .on("dblclick", show_details_agent)
+ .on("contextmenu", function(d) { show_menu("node", d);});
+
+ }
+ else if (shape == 'square') {
+ d3.select("#id_node_" + element.id)
+ .insert("rect", "title")
+ .attr("width", node_radius * 2)
+ .attr("height", node_radius * 2)
+ .attr("class", "node_shape node_shape_square")
+ .style("fill", function(d) {
+ return d.color;
+ })
+ .classed('dragable_node', true) //own dragable
+ .on("mouseover", over_node)
+ .on("mouseout", over_node)
+ .on("click", selected_node)
+ .on("dblclick", show_details_agent)
+ .on("contextmenu", function(d) { show_menu("node", d);});
+
+ }
+ else if (shape == 'rhombus') {
+ d3.select("#id_node_" + element.id)
+ .insert("rect", "title")
+ .attr("transform",
+ "")
+ .attr("width", node_radius * 1.5)
+ .attr("height", node_radius * 1.5)
+ .attr("class", "node_shape node_shape_rhombus")
+ .style("fill", function(d) {
+ return d.color;
+ })
+ .classed('dragable_node', true) //own dragable
+ .on("mouseover", over_node)
+ .on("mouseout", over_node)
+ .on("click", selected_node)
+ .on("dblclick", show_details_agent)
+ .on("contextmenu", function(d) { show_menu("node", d);});
+
+ }
+
+ }
+
+ count = count - 1;
+ if (count == 0) {
+ draw_elements_graph();
+ set_positions_graph();
+ }
+ });
+ }
+ else {
+ $("#shape_icon_fail").css("display", "");
+ }
+ }
+ });
+}
+
+function update_link(row_index, id_link) {
+ var interface_source = parseInt(
+ $("select[name='interface_source_" + row_index + "']")
+ .val()
+ );
+
+ var text_source_interface = "";
+ if (interface_source != 0) {
+ text_source_interface = $("select[name='interface_source_" +
+ row_index + "'] option:selected").text();
+ }
+
+ var interface_target = parseInt(
+ $("select[name='interface_target_" + row_index + "']")
+ .val()
+ );
+
+ var text_target_interface = "";
+ if (interface_source != 0) {
+ text_source_interface = $("select[name='interface_source_" +
+ row_index + "'] option:selected").text();
+ }
+
+ $(".edit_icon_progress_" + row_index).css("display", "");
+ $(".edit_icon_" + row_index).css("display", "none");
+
+ var params = [];
+ params.push("update_link=1");
+ params.push("networkmap_id=" + networkmap_id);
+ params.push("id_link=" + id_link);
+ params.push("interface_source=" + interface_source);
+ params.push("interface_target=" + interface_target);
+ params.push("page=operation/agentes/pandora_networkmap.view");
+
+ jQuery.ajax ({
+ data: params.join ("&"),
+ dataType: 'json',
+ type: 'POST',
+ url: action="ajax.php",
+ success: function (data) {
+ $(".edit_icon_progress_" + row_index).css("display", "none");
+
+ if (data['correct']) {
+ $(".edit_icon_correct_" + row_index).css("display", "");
+
+ $("select[name='interface_source_" + row_index + "'] option[value='" + interface_source + "']")
+ .prop("selected", true);
+ $("select[name='interface_target_" + row_index + "'] option[value='" + interface_target + "']")
+ .prop("selected", true);
+
+
+
+ if (interface_source == 0) {
+ 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;
+
+ //Remove the arrow
+ $("#link_id_" + id_link)
+ .attr("marker-start", "");
+
+ $("tspan")
+ .filter(function() {
+ var textPath = $(this).parent();
+ if ($(textPath).attr('href') == "#link_id_" + id_link)
+ return true;
+ else return false;
+ })
+ .html(Array(25).join(" ") + text_source_interface);
+ }
+ });
+ }
+ else {
+ 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'];
+ }
+
+ graph.links[i].arrow_start = "module";
+ graph.links[i].id_module_start = interface_source;
+ graph.links[i].text_start = text_source_interface;
+
+ //Added th arrow
+ $("#link_id_" + id_link)
+ .attr("marker-start",
+ "url(#interface_start_1)");
+
+ $("tspan")
+ .filter(function() {
+ var textPath = $(this).parent();
+
+ if ($(textPath).attr('href') == "#link_id_" + id_link)
+ return true;
+ else return false;
+ })
+ .html(Array(25).join(" ") + text_source_interface);
+ }
+ });
+ }
+
+
+
+
+ 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;
+
+ //Remove the arrow
+ $("#link_id_" + id_link)
+ .attr("marker-end", "");
+
+
+ $("tspan")
+ .filter(function() {
+ var textPath = $(this).parent();
+
+ if ($(textPath).attr('href') == "#link_reverse_id_" + id_link)
+ return true;
+ else return false;
+ })
+ .html(Array(25).join(" ") + text_target_interface);
+ }
+ });
+ }
+ else {
+ jQuery.each(graph.links, function(i, link_each) {
+ if (link_each.id_db == id_link) {
+
+ //Found
+
+ if (link_each.arrow_end == "") {
+ graph.links[i].id_db = data['id_link_change'];
+ }
+
+ graph.links[i].arrow_end = "module";
+ graph.links[i].id_module_end = interface_target;
+ graph.links[i].text_end = text_target_interface;
+
+ //Added th arrow
+ $("#link_id_" + id_link)
+ .attr("marker-end",
+ "url(#interface_end_1)");
+
+ $("tspan")
+ .filter(function() {
+ var textPath = $(this).parent();
+
+ if ($(textPath).attr('href') == "#link_reverse_id_" + id_link)
+ return true;
+ else return false;
+ })
+ .html(Array(25).join(" ") + text_target_interface);
+ }
+ });
+ }
+
+
+
+
+ //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();
+ }
+ else {
+ $(".edit_icon_fail_" + row_index).css("display", "");
+ }
+ }
+ });
+}
+
+function edit_node(data) {
+ var flag_edit_node = true;
+ var edit_node = null
+
+ //Only select one node
+ var selection = d3.selectAll('.node_selected');
+
+ if (selection[0].length == 1) {
+ edit_node = selection[0].pop();
+ }
+ else if (selection[0].length > 1) {
+ edit_node = selection[0].pop();
+ }
+ else {
+ flag_edit_node = false;
+ }
+
+ if (flag_edit_node) {
+ d3.selectAll('.node_selected')
+ .classed("node_selected", false);
+ d3.select(edit_node)
+ .classed("node_selected", true);
+
+ id = d3.select(edit_node).attr("id").replace("id_node_", "");
+ node_selected = graph.nodes[id];
+
+ selected_links = get_relations(node_selected);
+
+ $("select[name='shape'] option[value='" + data.shape + "']")
+ .prop("selected", true);
+ $("select[name='shape']").attr("onchange",
+ "javascript: change_shape(" + data.id_db + ");");
+ $("#node_options-fictional_node_update_button-1 input")
+ .attr("onclick", "update_fictional_node(" + data.id_db + ");");
+
+
+ $("#dialog_node_edit" )
+ .dialog( "option", "title",
+ dialog_node_edit_title.replace("%s", data.text));
+ $("#dialog_node_edit").dialog("open");
+
+ if (data.id_agent == -2) {
+ //Fictional node
+ $("#node_options-fictional_node_name")
+ .css("display", "");
+ $("input[name='edit_name_fictional_node']")
+ .val(data.text);
+ $("#node_options-fictional_node_networkmap_link")
+ .css("display", "");
+ $("#edit_networkmap_to_link")
+ .val(data.networkmap_id);
+ $("#node_options-fictional_node_update_button")
+ .css("display", "");
+ }
+ else {
+ $("#node_options-fictional_node_name")
+ .css("display", "none");
+ $("#node_options-fictional_node_networkmap_link")
+ .css("display", "none");
+ $("#node_options-fictional_node_update_button")
+ .css("display", "none");
+ }
+
+ //Clean
+ $("#relations_table .relation_link_row").remove();
+ //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)
+ .attr('href', 'javascript: 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=operation/agentes/pandora_networkmap.view");
+
+ jQuery.ajax ({
+ data: params.join ("&"),
+ dataType: 'json',
+ type: 'POST',
+ url: action="ajax.php",
+ async: false,
+ success: function (data) {
+ if (data['correct']) {
+ jQuery.each(data['interfaces'], function(j, interface) {
+
+ $("select[name='interface_source_" + i + "']", template_relation_row)
+ .append($("');
+ $("#spinner_group").css('display', 'none');
+ }
+ else {
+ $("#group_for_show_agents").attr('disabled', true);
+
+ var params = [];
+ params.push("get_agents_in_group=1");
+ params.push("id=" + networkmap_id);
+ params.push("group=" + group);
+ params.push("page=operation/agentes/pandora_networkmap.view");
+ jQuery.ajax ({
+ data: params.join ("&"),
+ dataType: 'json',
+ type: 'POST',
+ url: action="ajax.php",
+ success: function (data) {
+ if (data['correct']) {
+ $("#agents_filter_group").html('');
+ jQuery.each(data['agents'], function (id, name) {
+ if (typeof(name) == 'undefined') return;
+
+ $("#agents_filter_group").append('');
+ });
+
+ $("#agents_filter_group").removeAttr('disabled');
+ $("#group_for_show_agents").removeAttr('disabled');
+ $("#spinner_group").css('display', 'none');
+ $("input[name=add_agent_group_button]").removeAttr('disabled');
+ }
+ else {
+ $("#group_for_show_agents").removeAttr('disabled');
+ $("#agents_filter_group").html('');
+ $("#spinner_group").css('display', 'none');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) {
+ document.body.style.cursor = "pointer";
+ }
+ 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;
+ });
+
+ $("#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;
+ drag_y = 0;
+ dirty_popup = true;
+
+ document.body.style.cursor = "default";
+
+ module_inner = null;
+
+ event.stopPropagation();
+ return false;
+ });
+
+ $("#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;
+ drag_y = 0;
+ dirty_popup = true;
+
+ document.body.style.cursor = "default";
+
+ module_inner = null;
+
+ event.stopPropagation();
+ return false;
+ });
+
+ $(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) {
+ document.body.style.cursor = "pointer";
+ }
+ 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;
+ });
+
+ $("#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;
+ drag_y = 0;
+ dirty_popup = true;
+
+ document.body.style.cursor = "default";
+
+ module_inner = null;
+
+ event.stopPropagation();
+ return false;
+ });
+
+ $("#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;
+ drag_y = 0;
+ dirty_popup = true;
+
+ document.body.style.cursor = "default";
+
+ module_inner = null;
+
+ event.stopPropagation();
+ return false;
+ });
+
+ $(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);
+
+ $("#content_node_info").scrollLeft(pos_scroll);
+
+ dirty_popup = true;
+ check_popup_modification();
+ });
+}
+ pos_scroll = Math.floor($("#content_node_info").width() / 2);
+
+ $("#content_node_info").scrollLeft(pos_scroll);
+
+ dirty_popup = true;
+ check_popup_modification();
+ });
+}
+ }
+ }
+ });
+ }
+}
+
+
+////////////////////////////////////////////////////////////////////////
+// Old code for the details node
+////////////////////////////////////////////////////////////////////////
+//PSEUDO-CONSTANTS
+var VERTICAL_SPACE_MODULES = 55;
+var HORIZONTAL_SPACE_MODULES = 150;
+var VERTICAL_SPACING_BETWEEN_MODULES = 10;
+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;
+var pos_x = 0;
+var box_height = 0;
+var box_width = 0;
+var count_no_snmp = 0;
+
+var drag = false;
+var drag_x = 0;
+var drag_y = 0;
+var drag_x_delta = 0;
+var drag_y_delta = 0;
+var offset_x = 0;
+var offset_y = 0;
+var module_inner = null;
+
+function get_status_node() {
+ var params = [];
+ params.push("get_status_node=1");
+ params.push("id=" + id_agent);
+ params.push("page=operation/agentes/pandora_networkmap.view");
+ jQuery.ajax ({
+ data: params.join ("&"),
+ dataType: 'json',
+ type: 'POST',
+ url: action="../../../ajax.php",
+ success: function (data) {
+ if (data['correct']) {
+ color_status_node = data['status_agent'];
+ dirty_popup = true;
+ }
+ }
+ });
+}
+
+function get_status_module() {
+ jQuery.each(modules, function (id, module) {
+ if (typeof(module) == 'undefined') return;
+
+
+ var params = [];
+ params.push("get_status_module=1");
+ params.push("id=" + id);
+ params.push("page=operation/agentes/pandora_networkmap.view");
+ jQuery.ajax ({
+ data: params.join ("&"),
+ dataType: 'json',
+ type: 'POST',
+ url: action="../../../ajax.php",
+ success: function (data) {
+ if (data['correct']) {
+ modules[data['id']].status_color = data['status_color'];
+ dirty_popup = true;
+ }
+ }
+ });
+
+
+ });
+}
+
+function check_changes_num_modules() {
+ var params = [];
+ params.push("check_changes_num_modules=1");
+ params.push("id=" + id_agent);
+ params.push("page=operation/agentes/pandora_networkmap.view");
+ jQuery.ajax ({
+ data: params.join ("&"),
+ dataType: 'json',
+ type: 'POST',
+ url: action="../../../ajax.php",
+ success: function (data) {
+ if (data['correct']) {
+ if (module_count != data['count']) {
+ //location.reload(true);
+ }
+ }
+ }
+ });
+}
+
+
+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) {
+ document.body.style.cursor = "pointer";
+ }
+ 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;
+ });
+
+ $("#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;
+ drag_y = 0;
+ dirty_popup = true;
+
+ document.body.style.cursor = "default";
+
+ module_inner = null;
+
+ event.stopPropagation();
+ return false;
+ });
+
+ $("#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;
+ drag_y = 0;
+ dirty_popup = true;
+
+ document.body.style.cursor = "default";
+
+ module_inner = null;
+
+ event.stopPropagation();
+ return false;
+ });
+
+ $(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);
+
+ $("#content_node_info").scrollLeft(pos_scroll);
+
+ dirty_popup = true;
+ check_popup_modification();
+ });
+}
+
+function show_tooltip_content(id) {
+ var params = [];
+ params.push("get_tooltip_content=1");
+ params.push("id=" + id);
+ params.push("page=operation/agentes/pandora_networkmap.view");
+ jQuery.ajax ({
+ data: params.join ("&"),
+ dataType: 'json',
+ type: 'POST',
+ url: action="../../../ajax.php",
+ success: function (data) {
+ if (data['correct']) {
+ $("#tooltip").html(data['content']);
+ }
+ }
+ });
+}
+
+function show_tooltip(id, x, y) {
+ $("#tooltip").css('top', y + 'px');
+ $("#tooltip").css('left', x + 'px');
+
+ var params1 = [];
+ params1.push("get_image_path=1");
+ params1.push("img_src=" + "images/spinner.gif");
+ params1.push("page=include/ajax/skins.ajax");
+ jQuery.ajax ({
+ data: params1.join ("&"),
+ type: 'POST',
+ url: action="../../../ajax.php",
+ success: function (data) {
+ $("#tooltip").html(data);
+ $("#tooltip").css('display', '');
+
+ show_tooltip_content(id);
+ }
+ });
+}
+
+function hide_tooltip() {
+ $("#tooltip").css('display', 'none');
+}
+
+function inner_module(x, y) {
+ var return_var = null;
+
+ jQuery.each(modules, function (key, module) {
+ if (typeof(module) == 'undefined') return;
+
+ if ((x >= module.pos_x) && (x < (module.pos_x + SIZE_MODULE)) &&
+ (y >= module.pos_y) && (y < (module.pos_y + SIZE_MODULE))) {
+
+ return_var = key;
+ }
+ });
+
+ return return_var;
+}
+
+function check_popup_modification() {
+ if (dirty_popup) {
+ draw_popup();
+ dirty_popup = false;
+ }
+}
+
+function draw_popup() {
+ //Calculate the size
+ count_no_snmp = module_count - count_snmp_modules;
+
+ if (count_no_snmp > count_snmp_modules) {
+ box_height = Math.ceil(count_no_snmp / 2) * VERTICAL_SPACE_MODULES
+ + VERTICAL_SPACING_BETWEEN_MODULES;
+ }
+ else {
+ box_height = Math.ceil(count_snmp_modules / 2) * VERTICAL_SPACE_MODULES
+ + VERTICAL_SPACING_BETWEEN_MODULES;
+ }
+
+ //Draw the agent box.
+ // 2 columns of HORIZONTAL_SPACE_MODULES px for each modules
+ // + 15 * 2 half each snmp module
+ box_width = HORIZONTAL_SPACE_MODULES * 2 + SIZE_MODULE;
+
+
+ //Resize the canvas if the box is bigger before of paint.
+ if ((box_height + 50) != $("#node_info").attr("height")) {
+ node_info_height = box_height + 50;
+ $("#node_info").attr("height", node_info_height);
+ //$("#node_info").attr("width", node_info_width);
+ }
+
+ if ((box_width + 400) != $("#node_info").attr("width")) {
+ node_info_width = box_width + 400;
+ $("#node_info").attr("width", node_info_width);
+ }
+
+ //Clean the canvas
+ context_popup.clearRect(0, 0, node_info_width, node_info_height);
+ context_popup.beginPath(); //Erase lines?
+
+
+
+ pos_x = (node_info_width - box_width) / 2 + offset_x;
+
+ context_popup.beginPath();
+ context_popup.rect(pos_x, VERTICAL_SPACING_BETWEEN_MODULES + offset_y, box_width, box_height);
+ context_popup.fillStyle = "#ccc";
+ context_popup.fill();
+
+ //Draw the global status of agent into the box's border color.
+ context_popup.lineWidth = BORDER_SIZE_AGENT_BOX;
+ context_popup.strokeStyle = color_status_node;
+ context_popup.stroke();
+
+ if (mode_show == 'all') {
+ draw_snmp_modules();
+ draw_modules();
+ }
+ else if (mode_show == 'status_module') {
+ draw_snmp_modules();
+ }
+}
+
+function draw_snmp_modules() {
+ module_pos_y = MARGIN_BETWEEN_AGENT_MODULE;
+
+ count = 0;
+ reset_column = true;
+
+ jQuery.each(modules, function (key, module) {
+ if (typeof(module) == 'undefined') return;
+
+ if (module.type != 18) return;
+
+ if (count < (count_snmp_modules / 2)) {
+ module_pos_x = pos_x - 15;
+ text_align = 'right';
+ margin_text = 5;
+ }
+ else {
+ if (reset_column) {
+ module_pos_y = MARGIN_BETWEEN_AGENT_MODULE;
+ reset_column = false;
+ }
+ module_pos_x = pos_x + box_width - 15;
+ text_align = 'left';
+ margin_text = SIZE_MODULE - 5;
+ }
+ count++;
+
+ context_popup.beginPath();
+ context_popup.rect(module_pos_x, module_pos_y + offset_y,
+ SIZE_MODULE, SIZE_MODULE);
+ context_popup.fillStyle = module.status_color;
+ context_popup.fill();
+ context_popup.lineWidth = 1;
+ context_popup.strokeStyle = "#000";
+ context_popup.stroke();
+
+ modules[key].pos_x = module_pos_x;
+ modules[key].pos_y = module_pos_y + offset_y;
+
+ context_popup.fillStyle = "rgb(0,0,0)";
+ context_popup.font = 'bold 10px sans-serif';
+ context_popup.textBaseline = 'middle';
+ context_popup.textAlign = text_align;
+ dimensions = context_popup.measureText(module.text);
+ text_pos_x = module_pos_x + margin_text;
+ text_pos_y = module_pos_y + 40 + offset_y;
+ context_popup.fillText(module.text, text_pos_x, text_pos_y);
+
+ module_pos_y = module_pos_y + VERTICAL_SPACE_MODULES;
+ });
+}
+
+function draw_modules() {
+ module_pos_y = MARGIN_BETWEEN_AGENT_MODULE;
+
+ count = 0;
+ reset_column = true;
+
+ jQuery.each(modules, function (key, module) {
+ if (typeof(module) == 'undefined') return;
+
+ if (module.type == 18) return;
+
+ if (count < (count_no_snmp / 2)) {
+ module_pos_x = pos_x + (HORIZONTAL_SPACE_MODULES - SIZE_MODULE) / 2;
+ text_pos_x = pos_x + (HORIZONTAL_SPACE_MODULES / 2);
+ }
+ else {
+ if (reset_column) {
+ module_pos_y = MARGIN_BETWEEN_AGENT_MODULE;
+ reset_column = false;
+ }
+ module_pos_x = pos_x + (box_width - HORIZONTAL_SPACE_MODULES)
+ + (HORIZONTAL_SPACE_MODULES - SIZE_MODULE) / 2;
+ text_pos_x = pos_x + (box_width - HORIZONTAL_SPACE_MODULES) +
+ (HORIZONTAL_SPACE_MODULES / 2)
+ }
+ count++;
+
+ context_popup.beginPath();
+ center_orig_x = module_pos_x + (SIZE_MODULE / 2);
+ center_orig_y = module_pos_y + offset_y + (SIZE_MODULE / 2);
+ radius = SIZE_MODULE / 2;
+ context_popup.arc(center_orig_x, center_orig_y, radius, 0, Math.PI * 2, false);
+ //context_popup.rect(module_pos_x, module_pos_y + offset_y, SIZE_MODULE, SIZE_MODULE);
+ context_popup.fillStyle = module.status_color;
+ context_popup.fill();
+ context_popup.lineWidth = 1;
+ context_popup.strokeStyle = "#000";
+ context_popup.stroke();
+
+
+ modules[key].pos_x = module_pos_x;
+ modules[key].pos_y = module_pos_y + offset_y;
+
+ context_popup.fillStyle = "rgb(0,0,0)";
+ context_popup.font = 'bold 10px sans-serif';
+ context_popup.textBaseline = 'middle';
+ context_popup.textAlign = 'center';
+ dimensions = context_popup.measureText(module.short_text);
+
+ text_pos_y = module_pos_y + 40 + offset_y;
+ context_popup.fillText(module.short_text, text_pos_x, text_pos_y);
+
+ module_pos_y = module_pos_y + VERTICAL_SPACE_MODULES;
+ });
+
+ paint_tooltip_module_one_time = false;
+}
+
+function update_fictional_node_popup(id) {
+ name = $("#text-fictional_name").val();
+ shape = $("#fictional_shape option:selected").val();
+ networmap = $("#networmaps_enterprise option:selected").val();
+ radious = $("#fictional_radious").val();
+ color = $("#fictional_color").val();
+
+ window.close();
+
+ window.opener.update_fictional_node(id, name, shape, networmap, radious, color);
+}
diff --git a/pandora_console/include/javascript/jquery.contextMenu.css b/pandora_console/include/javascript/jquery.contextMenu.css
new file mode 100644
index 0000000000..ee2341948c
--- /dev/null
+++ b/pandora_console/include/javascript/jquery.contextMenu.css
@@ -0,0 +1,158 @@
+/*!
+ * jQuery contextMenu - Plugin for simple contextMenu handling
+ *
+ * Version: 1.6.5
+ *
+ * Authors: Rodney Rehm, Addy Osmani (patches for FF)
+ * Web: http://medialize.github.com/jQuery-contextMenu/
+ *
+ * Licensed under
+ * MIT License http://www.opensource.org/licenses/mit-license
+ * GPL v3 http://opensource.org/licenses/GPL-3.0
+ *
+ */
+
+.context-menu-list {
+ margin:0;
+ padding:0;
+
+ min-width: 120px;
+ max-width: 250px;
+ display: inline-block;
+ position: absolute;
+ list-style-type: none;
+
+ border: 1px solid #DDD;
+ background: #EEE;
+
+ -webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
+ -moz-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
+ -ms-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
+ -o-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
+
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 11px;
+ text-align: left;
+}
+
+.context-menu-item {
+ padding: 2px 2px 2px 24px;
+ background-color: #EEE;
+ position: relative;
+ -webkit-user-select: none;
+ -moz-user-select: -moz-none;
+ -ms-user-select: none;
+ user-select: none;
+}
+
+.context-menu-item span {
+ padding-top: 10px;
+ padding-bottom: 10px;
+ padding-right: 10px;
+ padding-left: 10px;
+}
+
+.context-menu-separator {
+ padding-bottom:0;
+ border-bottom: 1px solid #DDD;
+}
+
+.context-menu-item > label > input,
+.context-menu-item > label > textarea {
+ -webkit-user-select: text;
+ -moz-user-select: text;
+ -ms-user-select: text;
+ user-select: text;
+}
+
+.context-menu-item.hover {
+ cursor: pointer;
+ background-color: #39F;
+}
+
+.context-menu-item.disabled {
+ color: #666 !important;
+}
+
+.context-menu-input.hover,
+.context-menu-item.disabled.hover {
+ cursor: default;
+ background-color: #EEE;
+}
+
+.context-menu-submenu:after {
+ content: ">";
+ color: #666;
+ position: absolute;
+ top: 0;
+ right: 3px;
+ z-index: 1;
+}
+
+/* icons
+ #protip:
+ In case you want to use sprites for icons (which I would suggest you do) have a look at
+ http://css-tricks.com/13224-pseudo-spriting/ to get an idea of how to implement
+ .context-menu-item.icon:before {}
+ */
+.context-menu-item.icon { min-height: 18px; background-repeat: no-repeat; background-position: 4px 2px; }
+.context-menu-item.icon-edit { background-image: url(images/page_white_edit.png); }
+.context-menu-item.icon-cut { background-image: url(images/cut.png); }
+.context-menu-item.icon-copy { background-image: url(images/page_white_copy.png); }
+.context-menu-item.icon-paste { background-image: url(images/page_white_paste.png); }
+.context-menu-item.icon-delete { background-image: url(images/page_white_delete.png); }
+.context-menu-item.icon-add { background-image: url(images/page_white_add.png); }
+.context-menu-item.icon-quit { background-image: url(images/door.png); }
+.context-menu-item.icon-refresh { background-image: url(../../../images/refresh.png); }
+.context-menu-item.icon-center { background-image: url(../../../images/star.png); }
+.context-menu-item.icon-details { background-image: url(../../../images/application.png); }
+.context-menu-item.icon-children { background-image: url(../../../images/link_add.png); }
+.context-menu-item.icon-cancel_set_parent { background-image: url(../../../images/link_delete.png); }
+.context-menu-item.icon-set_parent { background-image: url(../../../images/link_go.png); }
+.context-menu-item.icon-add_node { background-image: url(../../../images/add.png); }
+.context-menu-item.icon-refresh_holding_area { background-image: url(../../../images/category_col.png); }
+
+/* vertically align inside labels */
+.context-menu-input > label > * { vertical-align: top; }
+
+/* position checkboxes and radios as icons */
+.context-menu-input > label > input[type="checkbox"],
+.context-menu-input > label > input[type="radio"] {
+ margin-left: -17px;
+}
+.context-menu-input > label > span {
+ margin-left: 5px;
+}
+
+.context-menu-input > label,
+.context-menu-input > label > input[type="text"],
+.context-menu-input > label > textarea,
+.context-menu-input > label > select {
+ display: block;
+ width: 100%;
+
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -ms-box-sizing: border-box;
+ -o-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+.context-menu-input > label > textarea {
+ height: 100px;
+}
+.context-menu-item > .context-menu-list {
+ display: none;
+ /* re-positioned by js */
+ right: -5px;
+ top: 5px;
+}
+
+.context-menu-item.hover > .context-menu-list {
+ display: block;
+}
+
+.context-menu-accesskey {
+ text-decoration: underline;
+}
diff --git a/pandora_console/include/javascript/jquery.contextMenu.js b/pandora_console/include/javascript/jquery.contextMenu.js
new file mode 100644
index 0000000000..f591d98312
--- /dev/null
+++ b/pandora_console/include/javascript/jquery.contextMenu.js
@@ -0,0 +1,1686 @@
+/*!
+ * jQuery contextMenu - Plugin for simple contextMenu handling
+ *
+ * Version: 1.6.5
+ *
+ * Authors: Rodney Rehm, Addy Osmani (patches for FF)
+ * Web: http://medialize.github.com/jQuery-contextMenu/
+ *
+ * Licensed under
+ * MIT License http://www.opensource.org/licenses/mit-license
+ * GPL v3 http://opensource.org/licenses/GPL-3.0
+ *
+ */
+
+(function($, undefined){
+
+ // TODO: -
+ // ARIA stuff: menuitem, menuitemcheckbox und menuitemradio
+ // create