diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index c588548957..9038e1ed13 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -1546,6 +1546,15 @@ function hiddenFields(item) { $("#percentile_item_row_4").css('display', 'none'); $("#percentile_item_row_4." + item).css('display', ''); + $("#percentile_item_row_5").css('display', 'none'); + $("#percentile_item_row_5." + item).css('display', ''); + + $("#percentile_item_row_6").css('display', 'none'); + $("#percentile_item_row_6." + item).css('display', ''); + + $("#percentile_bar_row_7").css('display', 'none'); + $("#percentile_bar_row_7." + item).css('display', ''); + $("#period_row").css('display', 'none'); $("#period_row." + item).css('display', ''); @@ -1638,6 +1647,11 @@ function cleanFields(item) { $("input[name='fill_color']").val('#ffffff'); $("input[name='line_width']").val(3); $("input[name='line_color']").val('#000000'); + $("select[name=type_percentile]").val(''); + $("input[name=percentile_color]").val(''); + $("input[name=percentile_label_color]").val(''); + $("input[name=percentile_label]").val(''); + $(".ColorPickerDivSample").css('background-color', '#FFF'); $("#preview").empty(); @@ -2230,7 +2244,7 @@ function setDonutsGraph (id_data, values) { parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); parameter.push ({name: "action", value: "get_module_type_string"}); parameter.push ({name: "id_agent", value: values['id_agent']}); - parameter.push ({name: "id_agent_module", value: values['module']}); + parameter.push ({name: "module", value: values['module']}); parameter.push ({name: "id_element", value: id_data}); parameter.push ({name: "id_visual_console", value: id_visual_console}); jQuery.ajax({ diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index 88bcd45898..b4bdc4f0fb 100755 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -589,6 +589,14 @@ switch ($action) { if ($height !== null) { $values['height'] = $height; } + break; + case 'donut_graph': + if ($width_percentile !== null) { + $values['width'] = $width_percentile; + $values['height'] = $width_percentile; + } + $values['type'] = DONUT_GRAPH; + break; case 'box_item': $values['border_width'] = $border_width; @@ -776,6 +784,7 @@ switch ($action) { case 'label': case 'icon': case 'auto_sla_graph': + case 'donut_graph': $elementFields = db_get_row_filter('tlayout_data', array('id' => $id_element)); @@ -856,6 +865,9 @@ switch ($action) { $elementFields['percentile_label_color'] = $elementFields['fill_color']; $elementFields['percentile_label'] = $elementFields['label']; break; + case 'donut_graph': + $elementFields['width_percentile'] = $elementFields['width']; + break; case 'module_graph': $elementFields['width_module_graph'] = $elementFields['width']; @@ -969,6 +981,11 @@ switch ($action) { $values['width'] = $width_box; $values['height'] = $height_box; break; + case 'donut_graph': + $values['type'] = DONUT_GRAPH; + $values['width'] = $width; + $values['height'] = $height; + break; case 'module_graph': $values['type'] = MODULE_GRAPH; diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index e22c3f90dd..7cdb64041e 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -385,6 +385,9 @@ function visual_map_print_item($mode = "read", $layoutData, case AUTO_SLA_GRAPH: $link = true; break; + case DONUT_GRAPH: + $link = true; + break; default: if (!empty($element_enterprise)) { $link = $element_enterprise['link']; @@ -1367,6 +1370,88 @@ function visual_map_print_item($mode = "read", $layoutData, break; + case DONUT_GRAPH: + if (!empty($id_metaconsole)) { + $connection = db_get_row_filter ('tmetaconsole_setup', $id_metaconsole); + if (metaconsole_load_external_db($connection) != NOERR) { + continue; + } + } + + + $is_string = db_get_value_filter ('id_tipo_modulo', 'tagente_modulo', + array ('id_agente' => $layoutData['id_agent'], + 'id_agente_modulo' => $id_module)); + + if (!empty($id_metaconsole)) { + metaconsole_restore_db(); + } + + if (($is_string == 17) || ($is_string == 23) || ($is_string == 3) || + ($is_string == 10) || ($is_string == 33)) { + $no_data = false; + } + else { + $no_data = true; + } + + if ($no_data) { + if($width == 0){ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } + } + else{ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } + } + } + else { + $donut_data = get_donut_module_data($layoutData['id_agente_modulo']); + + if ((get_parameter('action') == 'edit') || (get_parameter('operation') == 'edit_visualmap')) { + if($width == 0){ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } + } + else{ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } + } + } + else { + if ($width == 0) { + $img = d3_donut_graph ($layoutData['id'], 400, 400, $donut_data); + } + else{ + $img = d3_donut_graph ($layoutData['id'], $width, $width, $donut_data); + } + } + } + + //Restore db connection + if ($layoutData['id_metaconsole'] != 0) { + metaconsole_restore_db(); + } + + $z_index = 2 + 1; + break; + case LABEL: $z_index = 4 + 1; break; @@ -1437,6 +1522,9 @@ function visual_map_print_item($mode = "read", $layoutData, case GROUP_ITEM: $class .= "group_item"; break; + case DONUT_GRAPH: + $class .= "donut_graph"; + break; case PERCENTILE_BAR: case PERCENTILE_BUBBLE: case CIRCULAR_PROGRESS_BAR: @@ -1923,6 +2011,10 @@ function visual_map_print_item($mode = "read", $layoutData, echo io_safe_output($text); } break; + case DONUT_GRAPH: + echo $img; + break; + case SIMPLE_VALUE: case SIMPLE_VALUE_MAX: case SIMPLE_VALUE_MIN: @@ -2465,6 +2557,55 @@ function visual_map_process_wizard_add_modules ($id_modules, $image, return $return; } +function get_donut_module_data ($id_module) { + $mod_values = db_get_value_filter('datos', 'tagente_estado', array('id_agente_modulo' => $id_module)); + + if (preg_match("/\r\n/", $mod_values)) { + $values = explode("\r\n", $mod_values); + } + elseif (preg_match("/\n/", $mod_values)) { + $values = explode("\n", $mod_values); + } + + $colors = array(); + $colors[] = "#aa3333"; + $colors[] = "#045FB4"; + $colors[] = "#8181F7"; + $colors[] = "#F78181"; + $colors[] = "#D0A9F5"; + $colors[] = "#BDBDBD"; + $colors[] = "#6AB277"; + + $max_elements = 6; + $values_to_return = array(); + $index = 0; + $total = 0; + foreach ($values as $val) { + if ($index < $max_elements) { + $data = explode(":", $val); + $values_to_return[$index]['tag_name'] = $data[0] . ", " . $data[1]; + $values_to_return[$index]['color'] = $colors[$index]; + $values_to_return[$index]['value'] = (int)$data[1]; + $total += (int)$data[1]; + $index++; + } + else { + $data = explode(":", $val); + $values_to_return[$index]['tag_name'] = __('Others') . ", " . $data[1]; + $values_to_return[$index]['color'] = $colors[$index]; + $values_to_return[$index]['value'] += (int)$data[1]; + $total += (int)$data[1]; + } + } + + foreach ($values_to_return as $ind => $donut_data) { + $values_to_return[$ind]['percent'] = ($donut_data['value'] * 100) / $total; + } + + return $values_to_return; +} + + /** * The function to save the new elements of agents make as wizard. *