From 6dfc476f8a641d92b8f39dc9ba847ea02bda5bbd Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Tue, 26 Nov 2013 13:08:27 +0000 Subject: [PATCH] 2013-11-26 Sergio Martin * mobile/operation/events.php mobile/include/style/main.css: Improve events layout and fix events validation * include/functions_events.php include/functions_api.php: Fix event validation from API and delete deprecated function git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9131 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 10 ++ pandora_console/include/functions_api.php | 2 +- pandora_console/include/functions_events.php | 114 ----------------- pandora_console/mobile/include/style/main.css | 41 +++++- pandora_console/mobile/operation/events.php | 121 +++++++++--------- 5 files changed, 110 insertions(+), 178 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 64338a8334..e47751c3a2 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2013-11-26 Sergio Martin + + * mobile/operation/events.php + mobile/include/style/main.css: Improve events layout + and fix events validation + + * include/functions_events.php + include/functions_api.php: Fix event validation from API + and delete deprecated function + 2013-11-26 KIKUCHI Koichiro * extensions/insert_data.php: Use UTF-8 for output XML encoding. diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 3bf3ee4463..204cb27efb 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -5180,7 +5180,7 @@ function api_set_validate_events($id_event, $trash1, $other, $return_type, $user $event = events_get_event ($id_event); alerts_agent_module_standby ($event['id_alert_am'], 0); - $result = events_validate_event ($id_event, false, 1); + $result = events_change_status ($id_event, EVENT_VALIDATE); if ($result) { if (!empty($text)) { diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index e731e5a27b..c999285006 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -311,120 +311,6 @@ function events_delete_event ($id_event, $similar = true, $meta = false, $histor } } -/** - * Validate events in a transresponse - * - * @param mixed Event ID or array of events - * @param bool Whether to validate similar events or not. - * @param int New status for the event 0=new;1=validated;2=inprocess - * @param bool Metaconsole mode flag - * @param bool History mode flag - * - * @return bool Whether or not it was successful - */ -function events_validate_event ($id_event, $similars = true, $new_status = 1, $meta = false, $history = false) { - global $config; - - $table_event = events_get_events_table($meta, $history); - - //Cleans up the selection for all unwanted values also casts any single values as an array - $id_event = (array) safe_int ($id_event, 1); - - if ($new_status) { - $ack_utimestamp = time(); - $ack_user = $config['id_user']; - } - else { - $acl_utimestamp = 0; - $ack_user = ''; - } - - /* We must validate all events like the selected */ - if ($similars && $new_status == 1) { - foreach ($id_event as $id) { - $id_event = array_merge ($id_event, events_get_similar_ids ($id, $meta, $history)); - } - $id_event = array_unique($id_event); - } - - switch ($new_status) { - case 0: - $status_string = 'New'; - break; - case 1: - $status_string = 'Validated'; - break; - case 2: - $status_string = 'In process'; - break; - default: - $status_string = ''; - break; - } - - events_comment($id_event, '', "Change status to $status_string", $meta, $history); - - $alerts = array(); - - foreach ($id_event as $event) { - if ($meta) { - $event_group = events_meta_get_group ($event, $history); - $event = events_meta_get_event ($event, false, $history); - $server_id = $event['server_id']; - } - else { - $event_group = events_get_group ($event); - $event = events_get_event ($event); - } - - if ($event['id_alert_am'] > 0 && !in_array($event['id_alert_am'], $alerts)) { - $alerts[] = $event['id_alert_am']; - } - - if (check_acl ($config["id_user"], $event_group, "EW") == 0) { - db_pandora_audit("ACL Violation", "Attempted updating event #".$event); - - return false; - } - - $values = array( - 'estado' => $new_status, - 'id_usuario' => $ack_user, - 'ack_utimestamp' => $ack_utimestamp); - - $ret = db_process_sql_update($table_event, $values, - array('id_evento' => $event), 'AND', false); - - if (($ret === false) || ($ret === 0)) { - return false; - } - } - - if ($meta && !empty($alerts)) { - $server = metaconsole_get_connection_by_id ($server_id); - metaconsole_connect($server); - } - - // Put the alerts in standby or not depends the new status - foreach ($alerts as $alert) { - switch($new_status) { - case EVENT_NEW: - case EVENT_VALIDATE: - alerts_agent_module_standby ($alert, 0); - break; - case EVENT_PROCESS: - alerts_agent_module_standby ($alert, 1); - break; - } - } - - if ($meta && !empty($alerts)) { - metaconsole_restore_db(); - } - - return true; -} - /** * Change the status of one or various events * diff --git a/pandora_console/mobile/include/style/main.css b/pandora_console/mobile/include/style/main.css index 66139886b9..e2237cf608 100644 --- a/pandora_console/mobile/include/style/main.css +++ b/pandora_console/mobile/include/style/main.css @@ -730,6 +730,43 @@ li.ui-btn { height: 28px !important; } -.ui-icon-arrow-r-big { - background-position: -103px 4px !important; +.events td { + min-height: 35px; +} + +@media screen and (max-width: 25em) +{ + .events .cell_3, .events .button_row { + display: none; + } + + .events .cell_0 a.event_name { + width: 87%; + float: left; + } +} + +@media screen and (min-width: 25em) +{ + .events .cell_0 .event_link{ + display: none; + } + + .events td { + height: 35px; + } +} + +.cell_event_name { + padding-bottom: 10px; + font-weight: bold; +} + +.ui-icon-eye { + background-image: url(../../images/eye.png) !important; + background-position: center; +} + +span.nobold * { + font-weight: normal; } diff --git a/pandora_console/mobile/operation/events.php b/pandora_console/mobile/operation/events.php index 78e43838b2..a2c46a1f18 100644 --- a/pandora_console/mobile/operation/events.php +++ b/pandora_console/mobile/operation/events.php @@ -72,11 +72,27 @@ class Events { $end = 1; foreach ($events_db as $event) { $end = 0; + + $details_button = ''; + $open_link = ''; + $close_link = ''; + + if (!$this->readOnly) { + /* + $details_button = '' . + ' +   + ' . + ''; + */ + + $open_link = '
'; + $close_link = '
'; + } + $row = array(); - $row[] = ' - ' . __('Event Name') . ' - ' . - io_safe_output($event['evento']) . ''; + $row[] = $open_link . '' . __('Event Name') . '' . io_safe_output($event['evento']) . $details_button . $close_link; + /* switch ($event['estado']) { case 0: @@ -99,50 +115,22 @@ class Events { "title" => $title_st, "id" => 'status_img_' . $event["id_evento"])); */ - $row[] = '' . __('Timestamp') . '' . - ui_print_timestamp ($event['timestamp_rep'], true); + + $row[] = $open_link . '' . __('Timestamp') . '' . + ui_print_timestamp ($event['timestamp_rep'], true) . $close_link; if ($event["id_agente"] == 0) { $agent_name = __('System'); } else { - $agent_name = ui_print_agent_name ($event["id_agente"], true); - } - $row[] = '' . __('Agent') . '' . - $agent_name; - - /* - $status = - html_print_image ("mobile/images/" . - get_priority_class($event['criticity']) . ".png", true); - $status .= " "; - if ($event['estado'] == 1) { - $img_st = "images/tick.png"; - $title_st = __('Event validated'); - - $status .= html_print_image ($img_st, true, - array ("class" => "image_status", - "width" => 16, - "height" => 16, - "title" => $title_st, - "id" => 'status_img_' . $event["id_evento"])); - } - else { - $status .= ''; + $agent_name = '' . ui_print_agent_name ($event["id_agente"], true, 'agent_medium', '', false, '', '', false, false) . ''; } - $row[] = '' . __('Status') . '' . - $status; + $row[] = $open_link . '' . __('Agent') . '' . + $agent_name . $close_link; - */ + $row[] = $details_button; - if (!$this->readOnly) { - $row[] = '' . - ' -   - ' . - ''; - } $row[] = get_priority_class ($event["criticity"]); $events[$event['id_evento']] = $row; } @@ -289,7 +277,7 @@ class Events { $id_event = $system->getRequest('id_event', 0); - if (events_validate_event($id_event)) { + if (events_change_status($id_event, EVENT_VALIDATE)) { echo json_encode(array('correct' => 1)); } else { @@ -493,6 +481,7 @@ class Events { __('Validate'), @@ -513,9 +502,7 @@ class Events {

' . __('Fail validate') . '

'; $options['button_close'] = false; - - - + $ui->addDialog($options); $options['type'] = 'hidden'; @@ -750,17 +737,28 @@ class Events { $row_class = array(); foreach ($events_db as $event) { $myclass = get_priority_class ($event["criticity"]); + + $details_button = ''; + $open_link = ''; + $close_link = ''; + if (!$this->readOnly) { + /* + $details_button = '' . + ' +   + ' . + ''; + */ + + $open_link = '
'; + $close_link = '
'; + } + $row_class[$event['id_evento']] = "events $myclass"; $row = array(); - if ($this->readOnly) { - $row[$field_event_name] = io_safe_output($event['evento']); - } - else { - $row[$field_event_name] = '' . - io_safe_output($event['evento']) . ''; - } + $row[$field_event_name] = $open_link . io_safe_output($event['evento']) . $details_button . $close_link; /* switch ($event['estado']) { case 0: @@ -778,22 +776,21 @@ class Events { } */ - $row[$field_timestamp] = ui_print_timestamp ($event['timestamp_rep'], true); + $row[$field_timestamp] = $open_link . ui_print_timestamp ($event['timestamp_rep'], true) . $close_link; + + if ($event["id_agente"] == 0) { + $agent_name = __('System'); + } + else { + $agent_name = '' . ui_print_agent_name ($event["id_agente"], true, 'agent_medium', '', false, '', '', false, false) . ''; + } if ($this->columns['agent']) { - $row[$field_agent] = '' . - (string) agents_get_name($event["id_agente"]) . ''; + $row[$field_agent] = $open_link . $agent_name . $close_link; } - if (!$this->readOnly) { - $row[' '] = '' . - ' -   - ' . - ''; - $row_class[' '] = "button_row"; - } + $row[' '] = $details_button; $events[$event['id_evento']] = $row; } @@ -882,6 +879,8 @@ class Events { .html(event[\"group\"]); $(\"#detail_event_dialog .cell_event_tags\") .html(event[\"tags\"]); + $(\"#detail_event_dialog .cell_agent\") + .html(event[\"agent\"]); //The link to module graph $(\".event_module_graph\").hide();