From 96d7aca5bf80d9f8a1da7519d5a4aea3d1c8b2b0 Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Thu, 21 Jul 2016 14:48:56 +0200 Subject: [PATCH 1/2] Fixed problems qith html editor in textareas in visual console (cherry picked from commit 06e37132a8cd8b2329a6dcc5a82522869e7f21fb) --- .../reporting/visual_console_builder.editor.js | 14 +++++++------- .../reporting/visual_console_builder.editor.php | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index fbe5da6276..feea36ca01 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -1068,13 +1068,13 @@ function hiddenFields(item) { enterprise_hiddenFields(item); } - var code_control = tinyMCE.activeEditor.controlManager.controls['text-label_code']; - if (item == 'label') { - code_control.setDisabled(false); - } - else { - code_control.setDisabled(true); - } + //~ var code_control = tinyMCE.activeEditor.controlManager.controls['text-label_code']; + //~ if (item == 'label') { + //~ code_control.setDisabled(false); + //~ } + //~ else { + //~ code_control.setDisabled(true); + //~ } } function cleanFields(item) { diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.php b/pandora_console/godmode/reporting/visual_console_builder.editor.php index c9732c6cd4..74582d46e7 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.php +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.php @@ -208,7 +208,7 @@ ui_require_javascript_file ('encode_decode_base64'); width: "400", height: "200", nowrap: true, - plugins : "noneditable", + plugins : "bbcode", inline_styles : true, valid_children : "+body[style]", element_format : "html", From 2f462370e89f18e165a193c448bdc646b5e6736d Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Thu, 21 Jul 2016 14:57:06 +0200 Subject: [PATCH 2/2] Added new checkbox to hide agents that its first data time is less than report final time. Ticket 2 Gitlab --- .../reporting_builder.item_editor.php | 20 +- .../godmode/reporting/reporting_builder.php | 2 + .../include/functions_reporting.php | 4 +- .../include/functions_reporting_html.php | 203 ++++++++++++------ 4 files changed, 161 insertions(+), 68 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 1339d965a1..1bda6fc7c8 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -124,6 +124,7 @@ switch ($action) { $sql = null; $show_in_two_columns = 0; $show_in_landscape = 0; + $hide_notinit_agents = 0; $server_name = ''; $server_id = 0; break; @@ -156,6 +157,7 @@ switch ($action) { $sql = null; $show_in_two_columns = 0; $show_in_landscape = 0; + $hide_notinit_agents = 0; $server_name = ''; $server_id = 0; $get_data_editor = false; @@ -177,8 +179,10 @@ switch ($action) { } $style = json_decode(io_safe_output($item['style']), true); + $show_in_two_columns = $style['show_in_two_columns']; $show_in_landscape = $style['show_in_landscape']; + $hide_notinit_agents = $style['hide_notinit_agents']; $type = $item['type']; $name = $item['name']; @@ -1302,6 +1306,16 @@ $class = 'databox filters'; + + + + + + + @@ -1395,6 +1409,7 @@ function print_SLA_list($width, $action, $idItem = null) { 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); $nameAgent = agents_get_name ($idAgent); + $nameModule = db_get_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); @@ -2139,7 +2154,7 @@ function addGeneralRow() { params.push("id_module=" + idModule); params.push("id_server=" + serverId); params.push("operation=" + operation); - + params.push("id_agent=" + idAgent); params.push("page=include/ajax/reporting.ajax"); jQuery.ajax ({ data: params.join ("&"), @@ -2212,6 +2227,7 @@ function chooseType() { $("#row_exception_condition").hide(); $("#row_show_in_two_columns").hide(); $("#row_show_in_landscape").hide(); + $('#row_hide_notinit_agents').hide(); $("#row_module_group").hide(); $("#row_servers").hide(); $("#row_sort").hide(); @@ -2313,6 +2329,7 @@ function chooseType() { $("#row_show_graph").show(); $("#row_show_in_two_columns").show(); $("#row_sort").show(); + $('#row_hide_notinit_agents').show(); break; case 'SLA_monthly': @@ -2564,6 +2581,7 @@ function chooseType() { $("#row_show_in_two_columns").show(); $("#row_show_resume").show(); $("#row_working_time").show(); + $('#row_hide_notinit_agents').show(); break; case 'group_report': diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 9a74d60757..f35c50bbb0 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1101,6 +1101,7 @@ switch ($action) { $style = array(); $style['show_in_two_columns'] = get_parameter('show_in_two_columns', 0); $style['show_in_landscape'] = get_parameter('show_in_landscape', 0); + $style['hide_notinit_agents'] = get_parameter('hide_notinit_agents', 0); switch ($values['type']) { case 'event_report_agent': @@ -1362,6 +1363,7 @@ switch ($action) { $style = array(); $style['show_in_two_columns'] = get_parameter('show_in_two_columns', 0); $style['show_in_landscape'] = get_parameter('show_in_landscape', 0); + $style['hide_notinit_agents'] = get_parameter('hide_notinit_agents', 0); switch ($values['type']) { case 'event_report_agent': diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index d6c0498311..84624d6a77 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -484,6 +484,7 @@ function reporting_SLA($report, $content, $type = 'dinamic', $height = $force_height_chart; } + $return["id_rc"] = $content['id_rc']; $edge_interval = 10; @@ -3749,7 +3750,6 @@ function reporting_sql($report, $content) { } function reporting_availability($report, $content) { - global $config; $return = array(); @@ -3767,6 +3767,8 @@ function reporting_availability($report, $content) { $report, $content); + $return['id_rc'] = $content['id_rc']; + if ($content['show_graph']) { $return['kind_availability'] = "address"; } diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index e4aa0c5a87..292f3438e2 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -281,6 +281,11 @@ function reporting_html_print_report($report, $mini = false) { } function reporting_html_SLA($table, $item, $mini) { + $style = db_get_value('style', 'treport_content', 'id_rc', $item['id_rc']); + $style = json_decode(io_safe_output($style), true); + $hide_notinit_agent = $style['hide_notinit_agents']; + $same_agent_in_resume = ""; + if ($mini) { $font_size = '1.5'; } @@ -331,29 +336,60 @@ function reporting_html_SLA($table, $item, $mini) { $table1->headstyle[5] = 'text-align: right'; foreach ($item['data'] as $sla) { - $row = array(); - $row[] = $sla['agent']; - $row[] = $sla['module']; - $row[] = $sla['max'] . " / " . $sla['min']; - $row[] = round($sla['sla_limit'], 2) . "%"; - - if ($sla['sla_value_unknown']) { - $row[] = '' . - __('N/A') . ''; - $row[] = '' . - __('Unknown') . ''; - } - elseif ($sla['sla_status']) { - $row[] = '' . - round($sla['sla_value'], 2) . "%" . ''; - $row[] = '' . - __('OK') . ''; + $the_first_men_time = get_agent_first_time(io_safe_output($sla['agent'])); + if (!$hide_notinit_agent) { + $row = array(); + $row[] = $sla['agent']; + $row[] = $sla['module']; + $row[] = $sla['max'] . " / " . $sla['min']; + $row[] = round($sla['sla_limit'], 2) . "%"; + + if ($sla['sla_value_unknown']) { + $row[] = '' . + __('N/A') . ''; + $row[] = '' . + __('Unknown') . ''; + } + elseif ($sla['sla_status']) { + $row[] = '' . + round($sla['sla_value'], 2) . "%" . ''; + $row[] = '' . + __('OK') . ''; + } + else { + $row[] = '' . + round($sla['sla_value'], 2) . "%" . ''; + $row[] = '' . + __('Fail') . ''; + } } else { - $row[] = '' . - round($sla['sla_value'], 2) . "%" . ''; - $row[] = '' . - __('Fail') . ''; + if ($item['date']['to'] > $the_first_men_time) { + $row = array(); + $row[] = $sla['agent']; + $row[] = $sla['module']; + $row[] = $sla['max'] . " / " . $sla['min']; + $row[] = round($sla['sla_limit'], 2) . "%"; + + if ($sla['sla_value_unknown']) { + $row[] = '' . + __('N/A') . ''; + $row[] = '' . + __('Unknown') . ''; + } + elseif ($sla['sla_status']) { + $row[] = '' . + round($sla['sla_value'], 2) . "%" . ''; + $row[] = '' . + __('OK') . ''; + } + else { + $row[] = '' . + round($sla['sla_value'], 2) . "%" . ''; + $row[] = '' . + __('Fail') . ''; + } + } } $table1->data[] = $row; @@ -1639,6 +1675,10 @@ function reporting_html_text(&$table, $item) { } function reporting_html_availability(&$table, $item) { + $style = db_get_value('style', 'treport_content', 'id_rc', $item['id_rc']); + $style = json_decode(io_safe_output($style), true); + $hide_notinit_agent = $style['hide_notinit_agents']; + $same_agent_in_resume = ""; if (!empty($item["data"])) { $table1 = new stdClass(); @@ -1680,15 +1720,35 @@ function reporting_html_availability(&$table, $item) { $table1->style[7] = 'text-align: right'; foreach ($item['data'] as $row) { - $table_row = array(); - $table_row[] = $row['agent']; - $table_row[] = $row['availability_item']; - $table_row[] = $row['checks']; - $table_row[] = $row['failed']; - $table_row[] = $row['fail']; - $table_row[] = $row['poling_time']; - $table_row[] = $row['time_unavaliable']; - $table_row[] = $row['ok']; + $the_first_men_time = get_agent_first_time(io_safe_output($row['agent'])); + + if (!$hide_notinit_agent) { + $table_row = array(); + $table_row[] = $row['agent']; + $table_row[] = $row['availability_item']; + $table_row[] = $row['checks']; + $table_row[] = $row['failed']; + $table_row[] = $row['fail']; + $table_row[] = $row['poling_time']; + $table_row[] = $row['time_unavaliable']; + $table_row[] = $row['ok']; + } + else { + if ($item['date']['to'] > $the_first_men_time) { + $table_row = array(); + $table_row[] = $row['agent']; + $table_row[] = $row['availability_item']; + $table_row[] = $row['checks']; + $table_row[] = $row['failed']; + $table_row[] = $row['fail']; + $table_row[] = $row['poling_time']; + $table_row[] = $row['time_unavaliable']; + $table_row[] = $row['ok']; + } + else { + $same_agent_in_resume = $row['agent']; + } + } $table1->data[] = $table_row; } @@ -1708,45 +1768,56 @@ function reporting_html_availability(&$table, $item) { $table1->width = '99%'; $table1->data = array (); - - - $table1->head = array (); - $table1->head['min_text'] = __('Agent max'); - $table1->head['min'] = __('Min Value'); - $table1->head['avg'] = __('Average Value'); - $table1->head['max_text'] = __('Agent min'); - $table1->head['max'] = __('Max Value'); - - $table1->headstyle = array(); - $table1->headstyle['min_text'] = 'text-align: left'; - $table1->headstyle['min'] = 'text-align: right'; - $table1->headstyle['avg'] = 'text-align: right'; - $table1->headstyle['max_text'] = 'text-align: left'; - $table1->headstyle['max'] = 'text-align: right'; - - - $table1->style = array(); - $table1->style['min_text'] = 'text-align: left'; - $table1->style['min'] = 'text-align: right'; - $table1->style['avg'] = 'text-align: right'; - $table1->style['max_text'] = 'text-align: left'; - $table1->style['max'] = 'text-align: right'; - - $table1->data[] = array( - 'min_text' => $item['resume']['min_text'], - 'min' => format_numeric($item['resume']['min'], 2) . "%", - 'avg' => format_numeric($item['resume']['avg'], 2) . "%", - 'max_text' => $item['resume']['max_text'], - 'max' => format_numeric($item['resume']['max'], 2) . "%" - ); - - $table->colspan[2][0] = 3; - $data = array(); - $data[0] = html_print_table($table1, true); - array_push ($table->data, $data); + if (($same_agent_in_resume == "") && (strpos($item['resume']['min_text'], $same_agent_in_resume) === false)) { + $table1->head = array (); + $table1->head['min_text'] = __('Agent max'); + $table1->head['min'] = __('Min Value'); + $table1->head['avg'] = __('Average Value'); + $table1->head['max_text'] = __('Agent min'); + $table1->head['max'] = __('Max Value'); + + $table1->headstyle = array(); + $table1->headstyle['min_text'] = 'text-align: left'; + $table1->headstyle['min'] = 'text-align: right'; + $table1->headstyle['avg'] = 'text-align: right'; + $table1->headstyle['max_text'] = 'text-align: left'; + $table1->headstyle['max'] = 'text-align: right'; + + + $table1->style = array(); + $table1->style['min_text'] = 'text-align: left'; + $table1->style['min'] = 'text-align: right'; + $table1->style['avg'] = 'text-align: right'; + $table1->style['max_text'] = 'text-align: left'; + $table1->style['max'] = 'text-align: right'; + + $table1->data[] = array( + 'min_text' => $item['resume']['min_text'], + 'min' => format_numeric($item['resume']['min'], 2) . "%", + 'avg' => format_numeric($item['resume']['avg'], 2) . "%", + 'max_text' => $item['resume']['max_text'], + 'max' => format_numeric($item['resume']['max'], 2) . "%" + ); + + $table->colspan[2][0] = 3; + $data = array(); + $data[0] = html_print_table($table1, true); + array_push ($table->data, $data); + } } } +function get_agent_first_time ($agent_name) { + $id = agents_get_agent_id($agent_name, true); + + $utimestamp = db_get_all_rows_sql("SELECT utimestamp FROM tagente_datos WHERE id_agente_modulo IN + (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = " . $id . ") + ORDER BY utimestamp ASC LIMIT 1"); + $utimestamp = $utimestamp[0]['utimestamp']; + + return $utimestamp; +} + function reporting_html_general(&$table, $item) { if (!empty($item["data"])) {