diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 7531eea177..56fe4425eb 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2014-08-21 Alejandro Gallardo + + * include/functions_graph.php: Improved the function + "graph_monitor_wheel" to remove the html encoding. + + * include/graphs/pandora.d3.js: Mayor improvements + on the function "solarburst". + 2014-08-21 Junichi Satoh * include/functions_api.php: Added a function to add an event comment. diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 9da5dc28c2..a829791d66 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4135,20 +4135,21 @@ function graph_monitor_wheel ($width = 500, $height = 600) { $module_id = (int) $module['id_agente_modulo']; $agent_id = (int) $module['id_agente']; $module_group_id = (int) $module['id_module_group']; - $module_name = $module['nombre']; + $module_name = io_safe_output($module['nombre']); $module_status = modules_get_agentmodule_status($module_id); + $module_value = modules_get_last_value($module_id); if (!isset($data_agents[$agent_id])) { $data_agents[$agent_id] = array(); $data_agents[$agent_id]['id'] = $agent_id; - $data_agents[$agent_id]['name'] = $agents[$agent_id]['nombre']; + $data_agents[$agent_id]['name'] = io_safe_output($agents[$agent_id]['nombre']); $data_agents[$agent_id]['group'] = (int) $agents[$agent_id]['id_grupo']; $data_agents[$agent_id]['type'] = 'agent'; $data_agents[$agent_id]['size'] = 30; $data_agents[$agent_id]['children'] = array(); $tooltip_content = __('Agent') . ": " . $data_agents[$agent_id]['name'] . ""; - $data_agents[$agent_id]['tooltip_content'] = $tooltip_content; + $data_agents[$agent_id]['tooltip_content'] = io_safe_output($tooltip_content); $data_agents[$agent_id]['modules_critical'] = 0; $data_agents[$agent_id]['modules_warning'] = 0; @@ -4164,12 +4165,12 @@ function graph_monitor_wheel ($width = 500, $height = 600) { if (!isset($data_agents[$agent_id]['children'][$module_group_id])) { $data_agents[$agent_id]['children'][$module_group_id] = array(); $data_agents[$agent_id]['children'][$module_group_id]['id'] = $module_group_id; - $data_agents[$agent_id]['children'][$module_group_id]['name'] = $module_groups[$module_group_id]; + $data_agents[$agent_id]['children'][$module_group_id]['name'] = io_safe_output($module_groups[$module_group_id]); $data_agents[$agent_id]['children'][$module_group_id]['type'] = 'module_group'; $data_agents[$agent_id]['children'][$module_group_id]['size'] = 10; $data_agents[$agent_id]['children'][$module_group_id]['children'] = array(); - $tooltip_content = __('Module group') . ": " . $module_groups[$module_group_id] . ""; + $tooltip_content = __('Module group') . ": " . $data_agents[$agent_id]['children'][$module_group_id]['name'] . ""; $data_agents[$agent_id]['children'][$module_group_id]['tooltip_content'] = $tooltip_content; $data_agents[$agent_id]['children'][$module_group_id]['modules_critical'] = 0; @@ -4261,8 +4262,13 @@ function graph_monitor_wheel ($width = 500, $height = 600) { $data_module['name'] = $module_name; $data_module['type'] = 'module'; $data_module['size'] = 10; + $data_module['link'] = ui_get_full_url("index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$agent_id"); $tooltip_content = __('Module') . ": " . $module_name . ""; + if (isset($module_value) && $module_value !== false) { + $tooltip_content .= "
"; + $tooltip_content .= __('Value') . ": " . io_safe_output($module_value) . ""; + } $data_module['tooltip_content'] = $tooltip_content; switch ($module_status) { @@ -4309,7 +4315,7 @@ function graph_monitor_wheel ($width = 500, $height = 600) { if (!isset($data_agents[$id])) { $data_agents[$id] = array(); $data_agents[$id]['id'] = (int) $id; - $data_agents[$id]['name'] = $agent['nombre']; + $data_agents[$id]['name'] = io_safe_output($agent['nombre']); $data_agents[$id]['type'] = 'agent'; $data_agents[$id]['color'] = COL_NOTINIT; } @@ -4326,7 +4332,8 @@ function graph_monitor_wheel ($width = 500, $height = 600) { $group_aux = array(); $group_aux['id'] = (int) $id; - $group_aux['name'] = $group['nombre']; + $group_aux['name'] = io_safe_output($group['nombre']); + $group_aux['show_name'] = true; $group_aux['parent'] = (int) $group['parent']; $group_aux['type'] = 'group'; $group_aux['size'] = 100; diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index f4b9cb7175..6f5e987952 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -698,9 +698,7 @@ function sunburst (recipient, data, width, height) { var svg = d3.select(recipient).append("svg") .attr("width", width) - .attr("height", height) - .append("g") - .attr("transform", "translate(" + width / 2 + "," + (height / 2 + 10) + ")"); + .attr("height", height); var partition = d3.layout.partition() .value(function(d) { return d.size; }); @@ -711,20 +709,72 @@ function sunburst (recipient, data, width, height) { .innerRadius(function(d) { return Math.max(0, y(d.y)); }) .outerRadius(function(d) { return Math.max(0, y(d.y + d.dy)); }); - var path = svg.selectAll("path") + var g = svg.selectAll("g") .data(partition.nodes(data)) - .enter().append("path") + .enter().append("g") + .attr("transform", "translate(" + width / 2 + "," + (height / 2 + 10) + ")"); + + var path = g.append("path") .attr("d", arc) .style("fill", function(d) { return d.color ? d3.rgb(d.color) : color((d.children ? d : d.parent).name); }) + .style("cursor", "pointer") .on("click", click) .on("mouseover", over_user) .on("mouseout", out_user) .on("mousemove", move_tooltip); + function computeTextRotation(d) { + var angle = x(d.x + d.dx / 2) - Math.PI / 2; + return angle / Math.PI * 180; + } + + var text = g.append("text") + .attr("x", function(d) { return y(d.y); }) + .attr("dx", "6") // margin + .attr("dy", ".35em") // vertical-align + .attr("opacity", function(d) { + if (typeof d.show_name != "undefined" && d.show_name) + return 1; + else + return 0; + }) + .text(function(d) { + return d.name; + }) + .attr("transform", function(d) { return "rotate(" + computeTextRotation(d) + ")"; }) + .style("font-size", "10px") + // Makes svg elements invisible to events + .style("pointer-events", "none"); + function click(d) { - path.transition() - .duration(750) - .attrTween("d", arcTween(d)); + if (typeof d.link != "undefined") { + window.location.href = d.link; + } + else { + // fade out all text elements + text.transition().attr("opacity", 0); + + path.transition() + .duration(750) + .attrTween("d", arcTween(d)) + .each("end", function(e, i) { + // check if the animated element's data e lies within the visible angle span given in d + if ((typeof e.type != 'undefined' + && (e.type == "group" + || ( e.type == "agent" && (d.type == "group" || d.type == "agent" || d.type == "module_group" || d.type == "module") ) + || ( (e.type == "module_group" || e.type == "module") && (d.type == "agent" || d.type == "module_group") ) )) + && e.x >= d.x && e.x < (d.x + d.dx)) { + // get a selection of the associated text element + var arcText = d3.select(this.parentNode).select("text"); + // fade in the text element and recalculate positions + arcText + .attr("transform", function() { return "rotate(" + computeTextRotation(e) + ")" }) + .attr("x", function(d) { return y(d.y); }) + .transition().duration(250) + .attr("opacity", 1); + } + }); + } } d3.select(self.frameElement).style("height", height + "px");