diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 55da5955f5..cea8db7fac 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,23 @@ +2012-10-01 Sergio Martin + + * include/functions_events.php + general/header.php + include/functions_modules.php + include/javascript/pandora_events.js + include/ajax/events.php + include/functions.php + operation/events/events_list.php + operation/events/events.php: Change the event details view + to modal window + + * include/styles/pandora_legacy.css + include/styles/pandora.css + images/status_sets/default/severity_major_pixel.png + images/status_sets/default/severity_minor_pixel.png + images/status_sets/default/severity_major.png + images/status_sets/default/severity_minor.png: Change the + major/minor icons and colors + 2012-09-28 Miguel de Dios * install.php, operation/agentes/stat_win.php, general/footer.php, include/config_process.php, include/functions_ui.php, diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 3c0c5e8287..8d83736f26 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -224,6 +224,7 @@ config_check(); ui_require_css_file ('jquery-ui-1.8.23.custom'); ui_require_jquery_file('jquery-ui-1.8.23.custom.min'); ui_require_jquery_file('countdown'); +ui_require_javascript_file('encode_decode_base64'); ?> '; + + echo $out.$js; +} + if($get_events_details) { $event_ids = explode(',',get_parameter ('event_ids')); $events = db_get_all_rows_filter ('tevento', @@ -57,4 +217,537 @@ if($get_events_details) { echo $out; } +function events_page_actions ($event) { + global $config; + ///////// + // Actions + ///////// + + $table_actions->width = '100%'; + $table_actions->data = array (); + $table_actions->head = array (); + $table_actions->style[0] = 'width:35%; font-weight: bold; text-align: left;'; + $table_actions->style[1] = 'text-align: left;'; + $table_actions->class = "databox alternate"; + + // Owner + $data = array(); + $data[0] = __('Change owner'); + + $user_name = db_get_value('fullname', 'tusuario', 'id_user', $config['id_user']); + + $owners = array($config['id_user'] => $user_name); + + if($event['owner_user'] == '') { + $owner_name = __('None'); + } + else { + $owner_name = db_get_value('fullname', 'tusuario', 'id_user', $event['owner_user']); + $owners[$event['owner_user']] = $owner_name; + } + + $data[1] = html_print_select($owners, 'id_owner', $event['owner_user'], '', __('None'), -1, true); + $data[1] .= html_print_button(__('Update'),'owner_button',false,'event_change_owner();','class="sub next"',true); + + $table_actions->data[] = $data; + + // Status + $data = array(); + $data[0] = __('Change status'); + + $status = array(0 => __('New'), 2 => __('In process'), 1 => __('Validated')); + + $data[1] = html_print_select($status, 'estado', $event['estado'], '', '', 0, true); + $data[1] .= html_print_button(__('Update'),'status_button',false,'event_change_status();','class="sub next"',true); + + $table_actions->data[] = $data; + + // Comments + $data = array(); + $data[0] = __('Comment'); + $data[1] = html_print_button(__('Add comment'),'comment_button',false,'$(\'#link_comments\').trigger(\'click\');','class="sub next"',true); + + $table_actions->data[] = $data; + + // Delete + $data = array(); + $data[0] = __('Delete event'); + $data[1] = '
'; + $data[1] .= html_print_button(__('Delete event'),'delete_button',false,'if(!confirm(\''.__('Are you sure?').'\')) { return false; } this.form.submit();','class="sub cancel"',true); + $data[1] .= '
'; + + $table_actions->data[] = $data; + + $actions = '
'.html_print_table($table_actions, true).'
'; + + return $actions; +} + +function events_page_custom_fields ($event) { + global $config; + ///////// + // Custom fields + ///////// + + $table->width = '100%'; + $table->data = array (); + $table->head = array (); + $table->style[0] = 'width:35%; font-weight: bold; text-align: left;'; + $table->style[1] = 'text-align: left;'; + $table->class = "databox alternate"; + + $fields = db_get_all_rows_filter('tagent_custom_fields'); + + if($event['id_agente'] == 0) { + $fields_data = array(); + } + else { + $fields_data = db_get_all_rows_filter('tagent_custom_data', array('id_agent' => $event['id_agente'])); + if(is_array($fields_data)) { + $fields_data_aux = array(); + foreach($fields_data as $fd) { + $fields_data_aux[$fd['id_field']] = $fd['description']; + } + $fields_data = $fields_data_aux; + } + } + + foreach($fields as $field) { + // Owner + $data = array(); + $data[0] = $field['name']; + + $data[1] = isset($fields_data[$field['id_field']]) ? $fields_data[$field['id_field']] : ''.__('N/A').''; + + $field['id_field']; + + $table->data[] = $data; + } + + $custom_fields = '
'.html_print_table($table, true).'
'; + + return $custom_fields; +} + +function events_page_details ($event) { + global $img_sev; + + ///////// + // Details + ///////// + + $table_details->width = '100%'; + $table_details->data = array (); + $table_details->head = array (); + $table_details->style[0] = 'width:35%; font-weight: bold; text-align: left;'; + $table_details->style[1] = 'text-align: left;'; + $table_details->class = "databox alternate"; + + switch($event['event_type']) { + case 'going_unknown': + case 'going_up_warning': + case 'going_down_warning': + case 'going_up_critical': + case 'going_down_critical': + + break; + } + + if ($event["id_agente"] != 0) { + $agent = db_get_row('tagente','id_agente',$event["id_agente"]); + } + else { + $agent = array(); + } + + $data = array(); + $data[0] = __('Agent details'); + $data[1] = empty($agent) ? '' . __('N/A') . '' : ''; + $table_details->data[] = $data; + + if (!empty($agent)) { + $data = array(); + $data[0] = '
'.__('Name').'
'; + $data[1] = ui_print_agent_name ($event["id_agente"], true); + $table_details->data[] = $data; + + $data = array(); + $data[0] = '
'.__('IP Address').'
'; + $data[1] = empty($agent['url_address']) ? ''.__('N/A').'' : $agent['url_address']; + $table_details->data[] = $data; + + $data = array(); + $data[0] = '
'.__('OS').'
'; + $data[1] = ui_print_os_icon ($agent["id_os"], true, true).' ('.$agent["os_version"].')'; + $table_details->data[] = $data; + + $data = array(); + $data[0] = '
'.__('Last contact').'
'; + $data[1] = $agent["ultimo_contacto"]; + $table_details->data[] = $data; + + $data = array(); + $data[0] = '
'.__('Last remote contact').'
'; + if ($agent["ultimo_contacto_remoto"] == "01-01-1970 00:00:00") { + $data[1] .= __('Never'); + } + else { + $data[1] .= $agent["ultimo_contacto_remoto"]; + } + $table_details->data[] = $data; + + $data = array(); + $data[0] = '
'.__('Custom fields').'
'; + $data[1] = html_print_button(__('View custom fields'),'custom_button',false,'$(\'#link_custom_fields\').trigger(\'click\');','class="sub next"',true); + $table_details->data[] = $data; + } + + if ($event["id_agentmodule"] != 0) { + $module = db_get_row_filter('tagente_modulo',array('id_agente_modulo' => $event["id_agentmodule"], 'delete_pending' => 0)); + } + else { + $module = array(); + } + + $data = array(); + $data[0] = __('Module details'); + $data[1] = empty($module) ? '' . __('N/A') . '' : ''; + $table_details->data[] = $data; + + if (!empty($module)) { + // Module name + $data = array(); + $data[0] = '
'.__('Name').'
'; + $data[1] = ''; + $data[1] .= $module['nombre']; + $data[1] .= ''; + $table_details->data[] = $data; + + // Module group + $data = array(); + $data[0] = '
'.__('Module group').'
'; + $id_module_group = $module['id_module_group']; + if($id_module_group == 0) { + $data[1] = __('No assigned'); + } + else { + $module_group = db_get_value('name', 'tmodule_group', 'id_mg', $id_module_group); + $data[1] = ''; + $data[1] .= $module_group; + $data[1] .= ''; + } + $table_details->data[] = $data; + + $data = array(); + $data[0] = '
'.__('Graph').'
'; + $data[1] = ''; + $data[1] .= html_print_image('images/chart_curve.png',true); + $data[1] .= ''; + $table_details->data[] = $data; + } + + $data = array(); + $data[0] = __('Alert details'); + $data[1] = $event["id_alert_am"] == 0 ? '' . __('N/A') . '' : ''; + $table_details->data[] = $data; + + if($event["id_alert_am"] != 0) { + $data = array(); + $data[0] = '
'.__('Source').'
'; + $data[1] = ''; + $standby = db_get_value('standby', 'talert_template_modules', 'id', $event["id_alert_am"]); + if(!$standby) { + $data[1] .= html_print_image ("images/bell.png", true, + array ("title" => __('Go to data overview'))); + } + else { + $data[1] .= html_print_image ("images/bell_pause.png", true, + array ("title" => __('Go to data overview'))); + } + + $sql = 'SELECT name + FROM talert_templates + WHERE id IN (SELECT id_alert_template + FROM talert_template_modules + WHERE id = ' . $event["id_alert_am"] . ');'; + + $templateName = db_get_sql($sql); + + $data[1] .= $templateName; + + $data[1] .= ''; + + $table_details->data[] = $data; + + $data = array(); + $data[0] = '
'.__('Priority').'
'; + + $priority_code = db_get_value('priority', 'talert_template_modules', 'id', $event["id_alert_am"]); + $alert_priority = get_priority_name ($priority_code); + $data[1] = html_print_image ($img_sev, true, + array ("class" => "image_status", + "width" => 12, + "height" => 12, + "title" => $alert_priority)); + $data[1] .= ' '.$alert_priority; + + $table_details->data[] = $data; + } + + switch($event['event_type']) { + case 'going_unknown': + $data = array(); + $data[0] = __('Instructions'); + if ($event["unknown_instructions"] != '') { + $data[1] = $event["unknown_instructions"]; + } + else { + $data[1] = '' . __('N/A') . ''; + } + $table_details->data[] = $data; + break; + case 'going_up_warning': + case 'going_down_warning': + $data = array(); + $data[0] = __('Instructions'); + if ($event["warning_instructions"] != '') { + $data[1] = $event["warning_instructions"]; + } + else { + $data[1] = '' . __('N/A') . ''; + } + $table_details->data[] = $data; + break; + case 'going_up_critical': + case 'going_down_critical': + $data = array(); + $data[0] = __('Instructions'); + if ($event["critical_instructions"] != '') { + $data[1] = $event["critical_instructions"]; + } + else { + $data[1] = '' . __('N/A') . ''; + } + $table_details->data[] = $data; + break; + } + + $data = array(); + $data[0] = __('Extra id'); + if ($event["id_extra"] != '') { + $data[1] = $event["id_extra"]; + } + else { + $data[1] = '' . __('N/A') . ''; + } + $table_details->data[] = $data; + + $data = array(); + $data[0] = __('Source'); + if ($event["source"] != '') { + $data[1] = $event["source"]; + } + else { + $data[1] = '' . __('N/A') . ''; + } + $table_details->data[] = $data; + + $details = '
'.html_print_table($table_details, true).'
'; + + return $details; +} + +function events_page_general ($event) { + global $img_sev; + global $config; + global $group_rep; + ///////// + // General + ///////// + + $table_general->width = '100%'; + $table_general->data = array (); + $table_general->head = array (); + $table_general->style[0] = 'width:35%; font-weight: bold; text-align: left;'; + $table_general->style[1] = 'text-align: left;'; + $table_general->class = "databox alternate"; + + $data = array(); + $data[0] = __('Event ID'); + $data[1] = "#".$event["id_evento"]; + $table_general->data[] = $data; + + $data = array(); + $data[0] = __('Event name'); + $data[1] = io_safe_output(io_safe_output($event["evento"])); + $table_general->data[] = $data; + + $data = array(); + $data[0] = __('Timestamp'); + if ($group_rep == 1 && $event["event_rep"] > 0) { + $data[1] = __('First event').': '.date ($config["date_format"], $event['timestamp_rep_min']).'
'.__('Last event').': '.date ($config["date_format"], $event['timestamp_rep']); + } + else { + $data[1] = date ($config["date_format"], strtotime($event["timestamp"])); + } + $table_general->data[] = $data; + + $data = array(); + $data[0] = __('Type'); + $data[1] = events_print_type_img ($event["event_type"], true).' '.events_print_type_description($event["event_type"], true); + $table_general->data[] = $data; + + $data = array(); + $data[0] = __('Repeated'); + if ($group_rep != 0) { + if($event["event_rep"] == 0) { + $data[1] = __('No'); + } + else { + $data[1] = sprintf("%d Times",$event["event_rep"]); + } + } + else { + $data[1] = __('No'); + } + $table_general->data[] = $data; + + $data = array(); + $data[0] = __('Severity'); + $event_criticity = get_priority_name ($event["criticity"]); + $data[1] = html_print_image ($img_sev, true, + array ("class" => "image_status", + "width" => 12, + "height" => 12, + "title" => $event_criticity)); + $data[1] .= ' '.$event_criticity; + $table_general->data[] = $data; + + // Get Status + switch($event['estado']) { + case 0: + $img_st = "images/star.png"; + $title_st = __('New event'); + break; + case 1: + $img_st = "images/tick.png"; + $title_st = __('Event validated'); + break; + case 2: + $img_st = "images/hourglass.png"; + $title_st = __('Event in process'); + break; + } + + $data = array(); + $data[0] = __('Status'); + $data[1] = html_print_image($img_st,true).' '.$title_st; + $table_general->data[] = $data; + + // If event is validated, show who and when acknowleded it + $data = array(); + $data[0] = __('Acknowledged by'); + + if($event['estado'] == 1) { + $user_ack = db_get_value('fullname', 'tusuario', 'id_user', $event['id_usuario']); + $date_ack = date ($config["date_format"], $event['ack_utimestamp']); + $data[1] = $user_ack.' ('.$date_ack.')'; + } + else { + $data[1] = ''.__('N/A').''; + } + $table_general->data[] = $data; + + $data = array(); + $data[0] = __('Group'); + $data[1] = ui_print_group_icon ($event["id_grupo"], true); + $data[1] .= groups_get_name ($event["id_grupo"]); + $table_general->data[] = $data; + + $data = array(); + $data[0] = __('Tags'); + + if ($event["tags"] != '') { + $tag_array = explode(',', $event["tags"]); + $data[1] = ''; + foreach ($tag_array as $tag_element){ + $blank_char_pos = strpos($tag_element, ' '); + $tag_name = substr($tag_element, 0, $blank_char_pos); + $tag_url = substr($tag_element, $blank_char_pos + 1); + $data[1] .= ' ' .$tag_name; + if (!empty($tag_url)){ + $data[1] .= ' ' . html_print_image('images/lupa.png', true, array('title' => __('Click here to open a popup window with URL tag'))) . ' '; + } + $data[1] .= ','; + } + $data[1] = rtrim($table_general, ','); + } + else { + $data[1] = '' . __('N/A') . ''; + } + $table_general->data[] = $data; + + $general = '
'.html_print_table($table_general,true).'
'; + + return $general; +} + +function events_page_comments ($event) { + ///////// + // Comments + ///////// + + $table_comments->width = '100%'; + $table_comments->data = array (); + $table_comments->head = array (); + $table_comments->style[0] = 'width:35%; vertical-align: top; text-align: left;'; + $table_comments->style[1] = 'text-align: left;'; + $table_comments->class = "databox alternate"; + + $comments_array = explode('
',io_safe_output($event["user_comment"])); + + // Split comments and put in table + $col = 0; + $data = array(); + foreach($comments_array as $c) { + switch($col) { + case 0: + $row_text = preg_replace('/\s*--\s*/',"",$c); + html_debug_print($row_text,true); + $row_text = preg_replace('/\<\/b\>/',"",$row_text); + html_debug_print($row_text,true); + $row_text = preg_replace('/\[/',"

[",$row_text); + $row_text = preg_replace('/[\[|\]]/',"",$row_text); + break; + case 1: + $row_text = preg_replace("/\r\n/","
",io_safe_output(strip_tags($c))); + break; + } + + $data[$col] = $row_text; + + $col++; + + if($col == 2) { + $col = 0; + $table_comments->data[] = $data; + $data = array(); + } + } + + if(count($comments_array) == 1 && $comments_array[0] == '') { + $table_comments->style[0] = 'text-align:center;'; + $table_comments->colspan[0][0] = 2; + $data = array(); + $data[0] = __('There are no comments'); + $table_comments->data[] = $data; + } + + $comments_form = '
'.html_print_textarea("comment", 3, 10, '', 'style="min-height: 15px; width: 100%;"', true); + $comments_form .= '
'.html_print_button(__('Add comment'),'comment_button',false,'event_comment();','class="sub next"',true).'

'; + + $comments = '
'.$comments_form.html_print_table($table_comments, true).'
'; + + return $comments; +} ?> diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index ebb78f94f8..866afa6999 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -54,8 +54,9 @@ function check_refererer() { // Remove protocol from referer $referer = preg_replace('/http(s?):\/\//','',$referer); + $referer = preg_replace('/\?.*/','',$referer); - if (strpos($referer, $url) === 0) { + if (strpos($url, $referer) === 0) { return true; } else { @@ -964,10 +965,10 @@ function get_priority_class($priority) { return "datos_red"; break; case 5: - return "datos_sky"; + return "datos_pink"; break; case 6: - return "datos_pink"; + return "datos_brown"; break; default: return "datos_grey"; diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index b67feca4b8..12f50eca83 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -153,12 +153,21 @@ function events_delete_event ($id_event, $similar = true) { * * @return bool Whether or not it was successful */ -function events_validate_event ($id_event, $similars = true, $comment = '', $new_status = 1) { +function events_validate_event ($id_event, $similars = true, $new_status = 1) { global $config; //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) { @@ -167,20 +176,143 @@ function events_validate_event ($id_event, $similars = true, $comment = '', $new $id_event = array_unique($id_event); } - db_process_sql_begin (); - - switch ($new_status) { + switch($new_status) { + case 0: + $status_string = 'New'; + break; case 1: - $new_status_string = __('Validated'); + $status_string = 'Validated'; break; case 2: - $new_status_string = __('Set in process'); + $status_string = 'In process'; break; - case 3: - $new_status_string = __('Added comment'); + default: + $status_string = ''; break; } + events_comment_event($id_event, $similars, '', "Change status to $status_string"); + + db_process_sql_begin (); + + foreach ($id_event as $event) { + if (check_acl ($config["id_user"], events_get_group ($event), "IW") == 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('tevento', $values, + array('id_evento' => $event), 'AND', false); + + if (($ret === false) || ($ret === 0)) { + db_process_sql_rollback (); + return false; + } + } + + db_process_sql_commit (); + + return true; +} + +/** + * Change the owner of an event if the event hasn't owner + * + * @param mixed Event ID or array of events + * @param bool Whether to change owner on similar events or not. + * @param string id_user of the new owner. If is false, the current owner will be setted + * @param bool flag to force the change or not (not force is change only when it hasn't owner) + * + * @return bool Whether or not it was successful + */ +function events_change_owner_event ($id_event, $similars = true, $new_owner = false, $force = false) { + global $config; + + //Cleans up the selection for all unwanted values also casts any single values as an array + $id_event = (array) safe_int ($id_event, 1); + + /* We must validate all events like the selected */ + if ($similars) { + foreach ($id_event as $id) { + $id_event = array_merge ($id_event, events_get_similar_ids ($id)); + } + $id_event = array_unique($id_event); + } + + // Only generate comment when is forced (sometimes is changed the owner when comment) + if($force) { + events_comment_event($event, $similars, '', 'Change owner'); + } + + if($new_owner === false) { + $new_owner = $config['id_user']; + } + + db_process_sql_begin (); + + foreach ($id_event as $event) { + if (check_acl ($config["id_user"], events_get_group ($event), "IW") == 0) { + db_pandora_audit("ACL Violation", "Attempted updating event #".$event); + return false; + } + + if($owner) { + $owner_user = db_get_value('owner_user', 'tevento', 'id_evento', $event); + } + + if(!empty($owner_user) && $force === false) { + continue; + } + + $values = array('owner_user' => $new_owner); + + $ret = db_process_sql_update('tevento', $values, + array('id_evento' => $event), 'AND', false); + + if (($ret === false) || ($ret === 0)) { + db_process_sql_rollback (); + return false; + } + } + + db_process_sql_commit (); + + return true; +} + +/** + * Comment events in a transaction + * + * @param mixed Event ID or array of events + * @param bool Whether to validate similar events or not. + * + * @return bool Whether or not it was successful + */ +function events_comment_event ($id_event, $similars = true, $comment = '', $action = 'Added comment') { + global $config; + + //Cleans up the selection for all unwanted values also casts any single values as an array + $id_event = (array) safe_int ($id_event, 1); + + /* We must validate all events like the selected */ + if ($similars) { + foreach ($id_event as $id) { + $id_event = array_merge ($id_event, events_get_similar_ids ($id)); + } + $id_event = array_unique($id_event); + } + + // If the event hasn't owner, assign the user as owner + events_change_owner_event ($id_event, $similars); + + db_process_sql_begin (); + $comment = str_replace(array("\r\n", "\r", "\n"), '
', $comment); if ($comment != '') { @@ -197,18 +329,13 @@ function events_validate_event ($id_event, $similars = true, $comment = '', $new return false; } - $comment = '-- '.$new_status_string.' '.__('by').' '.$config['id_user'].' '.'['.date ($config["date_format"]).'] --
'.$commentbox; + $comment = '-- '.$action.' by '.$config['id_user'].' '.'['.date ($config["date_format"]).'] --
'.$commentbox; $fullevent = events_get_event($event); if ($fullevent['user_comment'] != '') { $comment .= '
'.$fullevent['user_comment']; } - if ($new_status == 3){ //only add a comment - $new_status = $fullevent["estado"]; - } - $values = array( - 'estado' => $new_status, 'id_usuario' => $config['id_user'], 'user_comment' => $comment); @@ -524,6 +651,15 @@ function events_print_type_img ($type, $return = false, $only_url = false) { array ("title" => events_print_type_description($type, true))); } break; + case "going_unknown": + if ($only_url) { + $output = $urlImage . "/" . "images/b_blue.png"; + } + else { + $output .= html_print_image ("images/b_blue.png", true, + array ("title" => events_print_type_description($type, true))); + } + break; case "alert_fired": if ($only_url) { $output = $urlImage . "/" . "images/bell.png"; @@ -589,6 +725,9 @@ function events_print_type_description ($type, $return = false) { $output = ''; switch ($type) { + case "going_unknown": + $output .= __('Going to unknown'); + break; case "alert_recovered": $output .= __('Alert recovered'); break; diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index d3d6d83643..f0721c4d56 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -1082,7 +1082,7 @@ function modules_get_agentmodule_status($id_agentmodule = 0, $without_alerts = f function modules_get_agentmodule_last_status($id_agentmodule = 0) { $status_row = db_get_row ("tagente_estado", "id_agente_modulo", $id_agentmodule); - return $status_row['last_status']; + return $status_row['last_known_status']; } /** diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js new file mode 100644 index 0000000000..41497a2b12 --- /dev/null +++ b/pandora_console/include/javascript/pandora_events.js @@ -0,0 +1,148 @@ +function show_event_dialog(event_id, group_rep, dialog_page, result) { + if(dialog_page == undefined) { + dialog_page = 'general'; + } + + jQuery.post ("ajax.php", + {"page": "include/ajax/events", + "get_extended_event": 1, + "group_rep": group_rep, + "dialog_page": dialog_page, + "event_id": event_id}, + function (data, status) { + $("#alert_messages").hide () + .empty () + .append (data) + .dialog ({ + title: $("#hidden-event_title_"+event_id).val(), + resizable: true, + draggable: true, + modal: true, + overlay: { + opacity: 0.5, + background: "black" + }, + bgiframe: jQuery.browser.msie, + width: 620, + height: 500 + }) + .show (); + + switch(result) { + case 'comment_ok': + $('#notification_comment_success').show(); + break; + case 'comment_error': + $('#notification_comment_error').show(); + break; + case 'status_ok': + $('#notification_status_success').show(); + break; + case 'status_error': + $('#notification_status_error').show(); + break; + case 'owner_ok': + $('#notification_owner_success').show(); + break; + case 'owner_error': + $('#notification_owner_error').show(); + break; + } + }, + "html" + ); + return false; +} + + +function event_change_status() { + var event_id = $('#hidden-id_event').val(); + var new_status = $('#estado').val(); + + var params = []; + params.push("page=include/ajax/events"); + params.push("change_status=1"); + params.push("event_id="+event_id); + params.push("new_status="+new_status); + + $('#button-status_button').attr('disabled','disabled'); + + jQuery.ajax ({ + data: params.join ("&"), + type: 'POST', + url: action="ajax.php", + async: true, + timeout: 10000, + dataType: 'html', + success: function (data) { + $('#button-status_button').removeAttr('disabled'); + show_event_dialog(event_id, $('#hidden-group_rep').val(), 'actions', data); + if(data == 'ok') { + } + else { + } + } + }); + return false; +} + +function event_change_owner() { + var event_id = $('#hidden-id_event').val(); + var new_owner = $('#id_owner').val(); + + var params = []; + params.push("page=include/ajax/events"); + params.push("change_owner=1"); + params.push("event_id="+event_id); + params.push("new_owner="+new_owner); + + $('#button-owner_button').attr('disabled','disabled'); + + jQuery.ajax ({ + data: params.join ("&"), + type: 'POST', + url: action="ajax.php", + async: true, + timeout: 10000, + dataType: 'html', + success: function (data) { + $('#button-owner_button').removeAttr('disabled'); + show_event_dialog(event_id, $('#hidden-group_rep').val(), 'actions', data); + } + }); + + return false; +} + +function event_comment() { + var event_id = $('#hidden-id_event').val(); + var comment = $('#textarea_comment').val(); + + if(comment == '') { + show_event_dialog(event_id, $('#hidden-group_rep').val(), 'comments', 'comment_error'); + return false; + } + + var params = []; + params.push("page=include/ajax/events"); + params.push("add_comment=1"); + params.push("event_id="+event_id); + params.push("comment="+comment); + + $('#button-comment_button').attr('disabled','disabled'); + + jQuery.ajax ({ + data: params.join ("&"), + type: 'POST', + url: action="ajax.php", + async: true, + timeout: 10000, + dataType: 'html', + success: function (data) { + $('#button-comment_button').removeAttr('disabled'); + show_event_dialog(event_id, $('#hidden-group_rep').val(), 'comments', data); + } + }); + + return false; +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 9d844eb97a..19064be882 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -886,7 +886,10 @@ span.rmess, span.nrmess { } .databox { - background-color: #f4f5f4; + background-color: #f4f504; +} +table.alternate tr:nth-child(odd) td{ + background-color: #e4e5e4; } /* Style for login form */ .databox_login { @@ -1624,12 +1627,12 @@ a.datos_blue, .datos_bluef9, .datos_blue { .datos_grey, .datos_greyf9 { background-color: #E4E4E4; } -.datos_sky, .datos_skyf9 { - background-color: #05FFF0; -} .datos_pink, .datos_pinkf9 { background-color: #FF92E9; } +.datos_brown, .datos_brownf9 { + background-color: #c97a4a; +} td.datos_greyf9, td.datos_bluef9, td.datos_greenf9, td.datos_redf9, td.datos_yellowf9 { padding: 5px 5px 5px 5px; } diff --git a/pandora_console/include/styles/pandora_legacy.css b/pandora_console/include/styles/pandora_legacy.css index f60ca8b328..84eaacf365 100644 --- a/pandora_console/include/styles/pandora_legacy.css +++ b/pandora_console/include/styles/pandora_legacy.css @@ -837,6 +837,9 @@ span.rmess, span.nrmess { .databox { background-color: #fafafa; } +table.alternate tr:nth-child(odd) td{ + background-color: #e4e5e4; +} /* Style for login form */ .databox_login { #margin-top: 100px !important; @@ -921,25 +924,25 @@ div#logo_text3 { } /* classes for event priorities. Sits now in functions.php */ .datos_green, .datos_greenf9 { - background-color: #BBFFA4; + background-color: #BBFFA4 !important; } .datos_red, .datos_redf9 { - background-color: #FFC0B5; + background-color: #FFC0B5 !important; } .datos_yellow, .datos_yellowf9 { - background-color: #F4FFBF; + background-color: #F4FFBF !important; } .datos_blue, .datos_bluef9 { - background-color: #CDE2EA; + background-color: #CDE2EA !important; } .datos_grey, .datos_greyf9 { - background-color: #E4E4E4; -} -.datos_sky, .datos_skyf9 { - background-color: #cdfffc; + background-color: #E4E4E4 !important; } .datos_pink, .datos_pinkf9 { - background-color: #F39DE2; + background-color: #F39DE2 !important; +} +.datos_brown, .datos_brownf9 { + background-color: #ffb589 !important; } td.datos_greyf9, td.datos_bluef9, td.datos_greenf9, td.datos_redf9, td.datos_yellowf9 { padding: 5px 5px 5px 5px; diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 5115c92dc6..7b36dd54fd 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -383,6 +383,7 @@ else { } ui_require_jquery_file ('bgiframe'); +ui_require_javascript_file('pandora_events'); ?> \ No newline at end of file diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index 5dd2b9d5c3..9b97b1dad7 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -126,34 +126,11 @@ echo ""; $tag = get_parameter("tag", ""); -if ($id_agent == -2) { +if ($id_agent == 0) { $text_agent = (string) get_parameter("text_agent", __("All")); - switch ($text_agent) - { - case __('All'): - $id_agent = -1; - break; - case __('Server'): - $id_agent = 0; - break; - default: - $id_agent = agents_get_agent_id($text_agent); - break; - } -} -else { - switch ($id_agent) - { - case -1: - $text_agent = __('All'); - break; - case 0: - $text_agent = __('Server'); - break; - default: - $text_agent = agents_get_name($id_agent); - break; + if($text_agent != __('All')) { + $id_agent = -1; } } @@ -211,8 +188,19 @@ if ($event_type != "") { } if ($severity != -1) $sql_post .= " AND criticity = ".$severity; -if ($id_agent != -1) - $sql_post .= " AND id_agente = ".$id_agent; + +switch($id_agent) { + case 0: + break; + case -1: + // Agent doesnt exist. No results will returned + $sql_post .= " AND 1 = 0"; + break; + default: + $sql_post .= " AND id_agente = ".$id_agent; + break; +} + if ($id_event != -1) $sql_post .= " AND id_evento = ".$id_event; @@ -313,7 +301,9 @@ echo "" . __('Agent search') . ""; echo ''; $params = array(); $params['show_helptip'] = false; -$params['input_name'] = 'id_agent'; +$params['input_name'] = 'text_agent'; +$params['print_hidden_input_idagent'] = true; +$params['hidden_input_idagent_name'] = 'id_agent'; $params['value'] = $text_agent; ui_print_agent_autocomplete_input($params); echo ''; @@ -468,7 +458,8 @@ else { GROUP_CONCAT(DISTINCT user_comment SEPARATOR '') AS user_comment, MIN(estado) AS min_estado, MAX(estado) AS max_estado, - COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep + COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep, + MIN(utimestamp) AS timestamp_rep_min FROM tevento WHERE 1=1 ".$sql_post." GROUP BY evento, id_agentmodule @@ -476,7 +467,8 @@ else { break; case "postgresql": $sql = "SELECT *, MAX(id_evento) AS id_evento, array_to_string(array_agg(DISTINCT user_comment), '') AS user_comment, - MIN(estado) AS min_estado, MAX(estado) AS max_estado, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep + MIN(estado) AS min_estado, MAX(estado) AS max_estado, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep, + MIN(utimestamp) AS timestamp_rep_min FROM tevento WHERE 1=1 ".$sql_post." GROUP BY 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 @@ -491,7 +483,8 @@ else { FROM (SELECT * FROM tevento WHERE 1=1 ".$sql_post.") a, (SELECT MAX (id_evento) AS id_evento, to_char(evento) AS evento, id_agentmodule, COUNT(*) AS event_rep, MIN(estado) AS min_estado, MAX(estado) AS max_estado, - LISTAGG(user_comment, '') AS user_comment, MAX(utimestamp) AS timestamp_rep + LISTAGG(user_comment, '') AS user_comment, MAX(utimestamp) AS timestamp_rep, + MIN(utimestamp) AS timestamp_rep_min FROM tevento WHERE 1=1 ".$sql_post." GROUP BY to_char(evento), id_agentmodule) b @@ -510,7 +503,7 @@ $result = db_get_all_rows_sql ($sql); // Delete rnum field generated by oracle_recode_query() function if (($config['dbtype'] == 'oracle') && ($result !== false)) { for ($i=0; $i < count($result); $i++) { - unset($result[$i]['rnum']); + unset($result[$i]['rnum']); } } @@ -714,7 +707,7 @@ foreach ($result as $event) { if (in_array('evento', $show_fields)) { // Event description $data[$i] = ''; - $data[$i] .= ''; + $data[$i] = ''; $data[$i] .= '' . ui_print_truncate_text (io_safe_output($event["evento"]), 160) . ''; $data[$i] .= ''; $i++; @@ -862,9 +855,10 @@ foreach ($result as $event) { } } - $data[$i] .= ''; + $data[$i] .= ''; + $data[$i] .= html_print_input_hidden('event_title_'.$event["id_evento"], "#".$event["id_evento"]." - ".$event["evento"], true); $data[$i] .= html_print_image ("images/eye.png", true, - array ("title" => __('Show more'))); + array ("title" => __('Show more'))); $data[$i] .= ' '; // Create incident from this event @@ -912,7 +906,7 @@ foreach ($result as $event) { if($event["id_alert_am"] != 0) { $string .= ''; } - $string .= ''; + $string .= ''; $data = array($string); @@ -922,258 +916,7 @@ foreach ($result as $event) { $table->colspan[$idx][0] = 10; $table->rowstyle[$idx] = 'display: none;'; array_push ($table->data, $data); - - //Hiden row with extended description - $string = ''; - $string .= ''; - - $string .= ''; - $string .= ''; - $string .= ''; - $string .= ''; - $string .= ''; - - $odd = 'rowOdd'; - - $string .= ''; - - $odd = ($odd == '')? 'rowOdd' : ''; - - if ($event["id_agentmodule"] != 0) { - $string .= ''; - - $odd = ($odd == '')? 'rowOdd' : ''; - // Module group - $string .= ''; - - $odd = ($odd == '')? 'rowOdd' : ''; - } - else { - $string .= ''; - $odd = ($odd == '')? 'rowOdd' : ''; - // Module group - $string .= ''; - $odd = ($odd == '')? 'rowOdd' : ''; - } - - $string .= ''; - - $odd = ($odd == '')? 'rowOdd' : ''; - - } - else { - $string .= '- ' . __('Empty') . ' -'; - $string .= ''; - $odd = ($odd == '')? 'rowOdd' : ''; - } - - $string .= ''; - $odd = ($odd == '')? 'rowOdd' : ''; - - if ($group_rep != 0) { - $string .= ''; - $odd = ($odd == '')? 'rowOdd' : ''; - } - - $string .= ''; - $odd = ($odd == '')? 'rowOdd' : ''; - $string .= ''; - $odd = ($odd == '')? 'rowOdd' : ''; - $string .= ''; - $odd = ($odd == '')? 'rowOdd' : ''; - } - else { - $string .= '- ' . __('Empty') . ' -'; - $odd = ($odd == '')? 'rowOdd' : ''; - } - - $string .= ''; - $odd = ($odd == '')? 'rowOdd' : ''; - } - else { - $string .= '- ' . __('Empty') . ' -'; - } - $string .= ''; - - $string .= ''; - if ($event["criticity"] == 4) { - $string .= ''; - $odd = ($odd == '')? 'rowOdd' : ''; - } - else { - $string .= '- ' . __('Empty') . ' -'; - } - $string .= ''; - } - - if ($event["criticity"] == 3) { - $string .= ''; - $odd = ($odd == '')? 'rowOdd' : ''; - } - else { - $string .= '- ' . __('Empty') . ' -'; - } - $string .= ''; - } - - if ($event["criticity"] == 0) { - $string .= ''; - $odd = ($odd == '')? 'rowOdd' : ''; - } - else { - $string .= '- ' . __('Empty') . ' -'; - } - $string .= ''; - } - - $string .= '
'; - $string .= '' . __('Event ID') . ''; - $string .= io_safe_output($event["id_evento"]); - $string .= '
'; - $string .= '' . __('Event name') . ''; - $string .= io_safe_output($event["evento"]); - $string .= '
'; - $string .= '' . __('Severity') . ''; - $string .= html_print_image ($img_sev, true, - array ("class" => "image_status", - "width" => 12, - "height" => 12, - "title" => get_priority_name ($event["criticity"]))); - $string .= ' '.get_priority_name ($event["criticity"]); - $string .= '
'; - $string .= '' . __('Type') . ''; - $string .= events_print_type_img ($event["event_type"], true).' '.events_print_type_description($event["event_type"], true); - $string .= '
'; - $string .= '' . __('Status') . ''; - $string .= $title_st; - $string .= '
'; - $string .= '' . __('Timestamp') . ''; - if ($group_rep == 1) { - $string .= date ($config["date_format"], $event['timestamp_rep']); - } - else { - $string .= date ($config["date_format"], strtotime($event["timestamp"])); - } - $string .= '
'; - $string .= '' . __('Agent name') . ''; - if ($event["id_agente"] != 0) { - $string .= ui_print_agent_name ($event["id_agente"], true); - } - else { - $string .= '- ' . __('Empty') . ' -'; - } - $string .= '
'; - $string .= '' . __('Agent module') . ''; - $string .= ''; - $string .= db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $event["id_agentmodule"]); - $string .= '
'; - $string .= '' . __('Module group') . ''; - $id_module_group = db_get_value('id_module_group', 'tagente_modulo', 'id_agente_modulo', $event["id_agentmodule"]); - $module_group = db_get_value('name', 'tmodule_group', 'id_mg', $id_module_group); - $string .= ''; - $string .= $module_group; - $string .= '
'; - $string .= '' . __('Agent module') . ''; - $string .= '- ' . __('Empty') . ' -'; - $string .= '
'; - $string .= '' . __('Module group') . ''; - $string .= '- ' . __('Empty') . ' -'; - $string .= '
'; - $string .= '' . __('Alert source') . ''; - if ($event["id_alert_am"] != 0) { - $string .= ''; - $standby = db_get_value('standby', 'talert_template_modules', 'id', $event["id_alert_am"]); - if(!$standby) { - $string .= html_print_image ("images/bell.png", true, - array ("title" => __('Go to data overview'))); - } - else { - $string .= html_print_image ("images/bell_pause.png", true, - array ("title" => __('Go to data overview'))); - } - - $sql = 'SELECT name - FROM talert_templates - WHERE id IN (SELECT id_alert_template - FROM talert_template_modules - WHERE id = ' . $event["id_alert_am"] . ');'; - - $templateName = db_get_sql($sql); - - $string .= $templateName; - - $string .= '
'; - $string .= '' . __('Group') . ''; - $string .= ui_print_group_icon ($event["id_grupo"], true); - $string .= groups_get_name ($event["id_grupo"]); - $string .= '
'; - $string .= '' . __('Count') . ''; - } - - if ($group_rep == 1) { - $string .= $event["event_rep"]; - $string .= '
' . '' . __('Comments') . ''; - if($event["user_comment"] != '') { - $string .= $event["user_comment"]; - } - else { - $string .= '- ' . __('Empty') . ' -'; - } - $string .= '
' . '' . __('Tags') . ''; - if ($event["tags"] != '') { - $tag_array = explode(',', $event["tags"]); - foreach ($tag_array as $tag_element){ - $blank_char_pos = strpos($tag_element, ' '); - $tag_name = substr($tag_element, 0, $blank_char_pos); - $tag_url = substr($tag_element, $blank_char_pos + 1); - $string .= ' ' .$tag_name; - if (!empty($tag_url)){ - $string .= ' ' . html_print_image('images/lupa.png', true, array('title' => __('Click here to open a popup window with URL tag'))) . ' '; - } - $string .= ','; - } - $string = rtrim($string, ','); - $odd = ($odd == '')? 'rowOdd' : ''; - } - else { - $string .= '- ' . __('Empty') . ' -'; - $odd = ($odd == '')? 'rowOdd' : ''; - } - - $string .= '
' . '' . __('Source') . ''; - if ($event["source"] != '') { - $string .= $event["source"]; - $string .= '
' . '' . __('Extra id') . ''; - if ($event["id_extra"] != '') { - $string .= $event["id_extra"]; - $string .= '
' . '' . __('User name') . ''; - if (($event["id_usuario"]!= '') || ($event["id_usuario"]!= 0)){ - $string .= $user_name; - } - else { - $string .= '- ' . __('Empty') . ' -'; - } - - $string .= '
' . '' . __('Critical instructions') . ''; - if ($event["critical_instructions"] != '') { - $string .= $event["critical_instructions"]; - $string .= '
' . '' . __('Warning instructions') . ''; - if ($event["warning_instructions"] != '') { - $string .= $event["warning_instructions"]; - $string .= '
' . '' . __('Unknown instructions') . ''; - if ($event["unknown_instructions"] != '') { - $string .= $event["unknown_instructions"]; - $string .= '
'; - - $data = array($string); - - $idx++; - - $table->rowclass[$idx] = 'event_info_' . $event["id_evento"].' event_info'; - $table->colspan[$idx][0] = 10; - $table->rowstyle[$idx] = 'display: none;'; - array_push ($table->data, $data); $idx++; } @@ -1479,4 +1222,4 @@ $(document).ready( function() { }); }); /* ]]> */ - \ No newline at end of file +