From 7a6614912b17e9ea0e6b5943349265a7894923f8 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Thu, 7 Mar 2013 16:35:37 +0000 Subject: [PATCH] 2013-03-07 Sergio Martin * include/functions_events.php operation/events/events.build_table.php: Improve instructions in list and details view on agents and fix the bug of doesnt show the owner in the list table when events are grouped. To fix it I added a couple of subqueries to the grouped query. Yes, I checked the performance :) Bug: 3607097 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7809 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 9 +++++++ pandora_console/include/functions_events.php | 24 ++++++++++++------- .../operation/events/events.build_table.php | 21 +++++++++++----- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 5c4b4d7ed7..844c5f771d 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2013-03-07 Sergio Martin + + * include/functions_events.php + operation/events/events.build_table.php: Improve instructions + in list and details view on agents and fix the bug of doesnt + show the owner in the list table when events are grouped. To fix + it I added a couple of subqueries to the grouped query. Yes, I + checked the performance :) Bug: 3607097 + 2013-03-07 Miguel de Dios * include/functions_reporting.php: fixed the apply format to diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 4c931cd62f..f9a2e63ea1 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -85,8 +85,10 @@ function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $met GROUP_CONCAT(DISTINCT user_comment SEPARATOR '
') AS user_comment, GROUP_CONCAT(DISTINCT id_evento SEPARATOR ',') AS similar_ids, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep, - MIN(utimestamp) AS timestamp_rep_min - FROM $table + MIN(utimestamp) AS timestamp_rep_min, + (SELECT owner_user FROM tevento WHERE id_evento = MAX(te.id_evento)) owner_user, + (SELECT id_usuario FROM tevento WHERE id_evento = MAX(te.id_evento)) id_usuario + FROM $table te WHERE 1=1 ".$sql_post." GROUP BY estado, evento, id_agentmodule".$groupby_extra." ORDER BY timestamp_rep DESC LIMIT ".$offset.",".$pagination; @@ -95,8 +97,10 @@ function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $met $sql = "SELECT *, MAX(id_evento) AS id_evento, array_to_string(array_agg(DISTINCT user_comment), '
') AS user_comment, array_to_string(array_agg(DISTINCT id_evento), ',') AS similar_ids, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep, - MIN(utimestamp) AS timestamp_rep_min - FROM $table + MIN(utimestamp) AS timestamp_rep_min, + (SELECT owner_user FROM tevento WHERE id_evento = MAX(te.id_evento)) owner_user, + (SELECT id_usuario FROM tevento WHERE id_evento = MAX(te.id_evento)) id_usuario + FROM $table te WHERE 1=1 ".$sql_post." GROUP BY estado, evento, id_agentmodule, id_evento, id_agente, id_usuario, id_grupo, estado, timestamp, utimestamp, event_type, id_alert_am, criticity, user_comment, tags, source, id_extra".$groupby_extra." ORDER BY timestamp_rep DESC LIMIT ".$pagination." OFFSET ".$offset; @@ -112,8 +116,10 @@ function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $met id_agentmodule, COUNT(*) AS event_rep, LISTAGG(user_comment, '') AS user_comment, MAX(utimestamp) AS timestamp_rep, LISTAGG(id_evento, '') AS similar_ids, - MIN(utimestamp) AS timestamp_rep_min - FROM $table + MIN(utimestamp) AS timestamp_rep_min, + (SELECT owner_user FROM tevento WHERE id_evento = MAX(te.id_evento)) owner_user, + (SELECT id_usuario FROM tevento WHERE id_evento = MAX(te.id_evento)) id_usuario + FROM $table te WHERE 1=1 ".$sql_post." GROUP BY estado, to_char(evento), id_agentmodule".$groupby_extra.") b WHERE a.id_evento=b.id_evento AND @@ -1956,7 +1962,7 @@ function events_page_details ($event, $server = "") { $data = array(); $data[0] = __('Instructions'); if ($event["unknown_instructions"] != '') { - $data[1] = $event["unknown_instructions"]; + $data[1] = str_replace("\n","
", io_safe_output($event["unknown_instructions"])); } else { $data[1] = '' . __('N/A') . ''; @@ -1968,7 +1974,7 @@ function events_page_details ($event, $server = "") { $data = array(); $data[0] = __('Instructions'); if ($event["warning_instructions"] != '') { - $data[1] = $event["warning_instructions"]; + $data[1] = str_replace("\n","
", io_safe_output($event["warning_instructions"])); } else { $data[1] = '' . __('N/A') . ''; @@ -1980,7 +1986,7 @@ function events_page_details ($event, $server = "") { $data = array(); $data[0] = __('Instructions'); if ($event["critical_instructions"] != '') { - $data[1] = $event["critical_instructions"]; + $data[1] = str_replace("\n","
", io_safe_output($event["critical_instructions"])); } else { $data[1] = '' . __('N/A') . ''; diff --git a/pandora_console/operation/events/events.build_table.php b/pandora_console/operation/events/events.build_table.php index bc5c628941..c9d51935bd 100644 --- a/pandora_console/operation/events/events.build_table.php +++ b/pandora_console/operation/events/events.build_table.php @@ -123,7 +123,7 @@ if (in_array('ack_utimestamp', $show_fields)) { } if (in_array('instructions', $show_fields)) { $table->head[$i] = __('Instructions'); - $table->align[$i] = 'left'; + $table->align[$i] = 'center'; $i++; } if ($i != 0 && $allow_action) { @@ -430,18 +430,27 @@ foreach ($result as $event) { if (in_array('instructions',$show_fields)) { switch($event['event_type']) { case 'going_unknown': - $data[$i] = ui_print_truncate_text(str_replace("\n","
", io_safe_output($event["unknown_instructions"]))); + if(!empty($event["unknown_instructions"])) { + $data[$i] = html_print_image('images/page_white_text.png', true, array('title' => str_replace("\n","
", io_safe_output($event["unknown_instructions"])))); + } break; case 'going_up_critical': case 'going_down_critical': - $data[$i] = ui_print_truncate_text(str_replace("\n","
", io_safe_output($event["critical_instructions"]))); + if(!empty($event["critical_instructions"])) { + $data[$i] = html_print_image('images/page_white_text.png', true, array('title' => str_replace("\n","
", io_safe_output($event["critical_instructions"])))); + } break; case 'going_down_warning': - $data[$i] = ui_print_truncate_text(str_replace("\n","
", io_safe_output($event["warning_instructions"]))); + if(!empty($event["warning_instructions"])) { + $data[$i] = html_print_image('images/page_white_text.png', true, array('title' => str_replace("\n","
", io_safe_output($event["warning_instructions"])))); + } break; - default: - $data[$i] = ''; } + + if(!isset($data[$i])) { + $data[$i] = ''; + } + $i++; }