diff --git a/pandora_console/extras/mr/55.sql b/pandora_console/extras/mr/55.sql new file mode 100644 index 0000000000..2618a7512c --- /dev/null +++ b/pandora_console/extras/mr/55.sql @@ -0,0 +1,5 @@ +START TRANSACTION; + +ALTER TABLE `tservice` ADD COLUMN `enable_sunburst` tinyint(1) NOT NULL default 0; + +COMMIT; diff --git a/pandora_console/include/graphs/functions_d3.php b/pandora_console/include/graphs/functions_d3.php index 57cf3a1f43..8c4a1b6ade 100644 --- a/pandora_console/include/graphs/functions_d3.php +++ b/pandora_console/include/graphs/functions_d3.php @@ -150,7 +150,7 @@ function d3_tree_map_graph($data, $width=700, $height=700, $return=false) } -function d3_sunburst_graph($data, $width=700, $height=700, $return=false) +function d3_sunburst_graph($data, $width=700, $height=700, $return=false, $tooltip=true) { global $config; @@ -167,7 +167,7 @@ function d3_sunburst_graph($data, $width=700, $height=700, $return=false) } '; $output .= ""; if (!$return) { diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index 8495a8728b..aad0506f86 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -796,7 +796,7 @@ function treeMap(recipient, data, width, height) { // The area (or angle, depending on implementation) of each arc corresponds to its value. // Sunburst design by John Stasko. Data courtesy Jeff Heer. // http://bl.ocks.org/mbostock/4348373 -function sunburst(recipient, data, width, height) { +function sunburst(recipient, data, width, height, tooltip = true) { if (width === "auto") { width = $(recipient).innerWidth(); } @@ -858,11 +858,14 @@ function sunburst(recipient, data, width, height) { }) .style("cursor", "pointer") .on("click", click) - .on("mouseover", over_user) + .on("mouseover", tooltip === "1" ? over_user : "") .on("mouseout", out_user) .on("mousemove", move_tooltip); function computeTextRotation(d) { + if (d.type === "central_service") { + return 0; + } var ang = ((x(d.x + d.dx / 2) - Math.PI / 2) / Math.PI) * 180; return ang > 90 ? 180 + ang : ang; } @@ -882,9 +885,18 @@ function sunburst(recipient, data, width, height) { return computeTextRotation(d) > 180 ? -40 : -30; }) .attr("dx", "6") // margin - .attr("dy", ".35em") // vertical-align + .attr("dy", function(d) { + if (d.type === "central_service") { + return "-7em"; + } + return ".35em"; + }) // vertical-align .attr("opacity", function(d) { - if (typeof d.show_name != "undefined" && d.show_name) return 1; + if ( + (typeof d.show_name != "undefined" && d.show_name) || + d.type === "central_service" + ) + return 1; else return 0; }) .text(function(d) { @@ -899,7 +911,11 @@ function sunburst(recipient, data, width, height) { window.location.href = d.link; } else { // fade out all text elements - text.transition().attr("opacity", 0); + if (d.type === "central_service") { + text.transition().attr("opacity", 1); + } else { + text.transition().attr("opacity", 0); + } path .transition() @@ -965,8 +981,8 @@ function sunburst(recipient, data, width, height) { } function move_tooltip(d) { - var x = d3.event.pageX + 10; - var y = d3.event.pageY + 10; + var x = d3.event.pageX + 10 - $("#menu_full").width(); + var y = d3.event.pageY - 90; $("#tooltip").css("left", x + "px"); $("#tooltip").css("top", y + "px"); @@ -1017,10 +1033,10 @@ function sunburst(recipient, data, width, height) { "-moz-box-shadow: 7px 7px 5px rgba(50, 50, 50, 0.75);" + "box-shadow: 7px 7px 5px rgba(50, 50, 50, 0.75);" + "left: " + - x + + 100 + "px;" + "top: " + - y + + 100 + "px;" ); } diff --git a/pandora_console/include/lib/Dashboard/Widgets/service_map.php b/pandora_console/include/lib/Dashboard/Widgets/service_map.php index a2122c6dca..21a7edc82c 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/service_map.php +++ b/pandora_console/include/lib/Dashboard/Widgets/service_map.php @@ -235,6 +235,10 @@ class ServiceMapWidget extends Widget $values['showLegend'] = $decoder['showLegend']; } + if (isset($decoder['sunburst']) === true) { + $values['sunburst'] = $decoder['sunburst']; + } + return $values; } @@ -296,19 +300,16 @@ class ServiceMapWidget extends Widget ], ]; - // TODO refactoriced services: Hidden legend. - /* - // Show legend. - $inputs[] = [ - 'label' => __('Show legend'), + $inputs[] = [ + 'label' => __('Enable sunburst'), 'arguments' => [ - 'name' => 'showLegend', - 'id' => 'showLegend', - 'type' => 'switch', - 'value' => $values['showLegend'], + 'type' => 'switch', + 'name' => 'sunburst', + 'class' => 'event-widget-input', + 'value' => $values['sunburst'], + 'return' => true, ], - ]; - */ + ]; return $inputs; } @@ -325,7 +326,9 @@ class ServiceMapWidget extends Widget $values = parent::getPost(); $values['serviceId'] = \get_parameter('serviceId', 0); - // $values['showLegend'] = \get_parameter_switch('showLegend'); + + $values['sunburst'] = \get_parameter_switch('sunburst', 0); + return $values; } @@ -341,6 +344,7 @@ class ServiceMapWidget extends Widget $size = parent::getSize(); + $output = ''; if (check_acl($config['id_user'], 0, 'AR') === 0) { $output .= '
'; $output .= \ui_print_error_message( @@ -367,42 +371,6 @@ class ServiceMapWidget extends Widget $style = 'position: relative; text-align: center;'; $output .= "
"; - // TODO refactoriced services: Hidden legend. - /* - if ($this->values['showLegend'] === 1) { - $output .= "
cellId."'>"; - $output .= ''; - $output .= "'; - $output .= ""; - - $output .= "'; - - // Coulour legend. - $output .= "'; - - $output .= "'; - $output .= ''; - - $output .= "'; - $output .= ''; - $output .= '
".__('Legend').'
"; - $output .= ""; - $output .= ''.__('Services').'"; - $output .= ''; - $output .= "'; - $output .= "'; - $output .= "'; - $output .= "'; - $output .= '
".__('Critical').'
".__('Warning').'
".__('Ok').'
".__('Unknown').'
'; - $output .= '
"; - $output .= ""; - $output .= ''.__('Agents').'
"; - $output .= ""; - $output .= ''.__('Modules').'
'; - $output .= '
'; - } - */ - // TODO: removed refactoriced services. Only 1 widget Zoom. $sql = sprintf( 'SELECT COUNT(*) @@ -425,14 +393,21 @@ class ServiceMapWidget extends Widget ); // TODO:XXX fix draw service map. ob_start(); - servicemap_print_servicemap( - $this->values['serviceId'], - false, - $size['width'], - $size['height'], - $this->cellId, - $disableZoom - ); + + if ($this->values['sunburst'] === 0) { + servicemap_print_servicemap( + $this->values['serviceId'], + false, + $size['width'], + $size['height'], + $this->cellId, + $disableZoom + ); + } else { + include_once $config['homedir'].'/include/graphs/functions_d3.php'; + servicemap_print_sunburst($this->values['serviceId'], $size['width'], $size['height'], false); + } + $output .= ob_get_clean(); $output .= '
'; return $output; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 29ec6e572b..0cd5d07ac1 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -2817,6 +2817,7 @@ CREATE TABLE IF NOT EXISTS `tservice` ( `cascade_protection` TINYINT NOT NULL DEFAULT 0, `evaluate_sla` INT NOT NULL DEFAULT 0, `is_favourite` TINYINT NOT NULL DEFAULT 0, + `enable_sunburst` TINYINT NOT NULL DEFAULT 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB COMMENT = 'Table to define services to monitor'