2013-11-26 Sergio Martin <sergio.martin@artica.es>
* 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
This commit is contained in:
parent
3f393e6977
commit
6dfc476f8a
|
@ -1,3 +1,13 @@
|
||||||
|
2013-11-26 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
|
* 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 <koichiro@rworks.jp>
|
2013-11-26 KIKUCHI Koichiro <koichiro@rworks.jp>
|
||||||
|
|
||||||
* extensions/insert_data.php: Use UTF-8 for output XML encoding.
|
* extensions/insert_data.php: Use UTF-8 for output XML encoding.
|
||||||
|
|
|
@ -5180,7 +5180,7 @@ function api_set_validate_events($id_event, $trash1, $other, $return_type, $user
|
||||||
$event = events_get_event ($id_event);
|
$event = events_get_event ($id_event);
|
||||||
alerts_agent_module_standby ($event['id_alert_am'], 0);
|
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 ($result) {
|
||||||
if (!empty($text)) {
|
if (!empty($text)) {
|
||||||
|
|
|
@ -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
|
* Change the status of one or various events
|
||||||
*
|
*
|
||||||
|
|
|
@ -730,6 +730,43 @@ li.ui-btn {
|
||||||
height: 28px !important;
|
height: 28px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ui-icon-arrow-r-big {
|
.events td {
|
||||||
background-position: -103px 4px !important;
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,11 +72,27 @@ class Events {
|
||||||
$end = 1;
|
$end = 1;
|
||||||
foreach ($events_db as $event) {
|
foreach ($events_db as $event) {
|
||||||
$end = 0;
|
$end = 0;
|
||||||
|
|
||||||
|
$details_button = '';
|
||||||
|
$open_link = '';
|
||||||
|
$close_link = '';
|
||||||
|
|
||||||
|
if (!$this->readOnly) {
|
||||||
|
/*
|
||||||
|
$details_button = '<a href="javascript: openDetails(' . $event['id_evento'] . ')" class="event_link">' .
|
||||||
|
'<span style="position: relative; float: right; margin-right: 30px;">
|
||||||
|
<span class="ui-icon ui-icon-big ui-icon-eye ui-icon-eye ui-icon-shadow" style="position: absolute; left: 50%;"> </span>
|
||||||
|
</span>' .
|
||||||
|
'</a>';
|
||||||
|
*/
|
||||||
|
|
||||||
|
$open_link = '<a href="javascript: openDetails(' . $event['id_evento'] . ')"><div style="height:100%;width:100%">';
|
||||||
|
$close_link = '</div></a>';
|
||||||
|
}
|
||||||
|
|
||||||
$row = array();
|
$row = array();
|
||||||
$row[] = '
|
$row[] = $open_link . '<b class="ui-table-cell-label">' . __('Event Name') . '</b>' . io_safe_output($event['evento']) . $details_button . $close_link;
|
||||||
<b class="ui-table-cell-label">' . __('Event Name') . '</b>
|
|
||||||
<a class="ui-link" href="javascript: openDetails(' . $event['id_evento'] . ')">' .
|
|
||||||
io_safe_output($event['evento']) . '</a>';
|
|
||||||
/*
|
/*
|
||||||
switch ($event['estado']) {
|
switch ($event['estado']) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -99,50 +115,22 @@ class Events {
|
||||||
"title" => $title_st,
|
"title" => $title_st,
|
||||||
"id" => 'status_img_' . $event["id_evento"]));
|
"id" => 'status_img_' . $event["id_evento"]));
|
||||||
*/
|
*/
|
||||||
$row[] = '<b class="ui-table-cell-label">' . __('Timestamp') . '</b>' .
|
|
||||||
ui_print_timestamp ($event['timestamp_rep'], true);
|
$row[] = $open_link . '<b class="ui-table-cell-label">' . __('Timestamp') . '</b>' .
|
||||||
|
ui_print_timestamp ($event['timestamp_rep'], true) . $close_link;
|
||||||
|
|
||||||
if ($event["id_agente"] == 0) {
|
if ($event["id_agente"] == 0) {
|
||||||
$agent_name = __('System');
|
$agent_name = __('System');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$agent_name = ui_print_agent_name ($event["id_agente"], true);
|
$agent_name = '<span class="nobold">' . ui_print_agent_name ($event["id_agente"], true, 'agent_medium', '', false, '', '', false, false) . '</span>';
|
||||||
}
|
|
||||||
$row[] = '<b class="ui-table-cell-label">' . __('Agent') . '</b>' .
|
|
||||||
$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 .= '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$row[] = '<b class="ui-table-cell-label">' . __('Status') . '</b>' .
|
$row[] = $open_link . '<b class="ui-table-cell-label">' . __('Agent') . '</b>' .
|
||||||
$status;
|
$agent_name . $close_link;
|
||||||
|
|
||||||
*/
|
$row[] = $details_button;
|
||||||
|
|
||||||
if (!$this->readOnly) {
|
|
||||||
$row[] = '<a href="javascript: openDetails(' . $event['id_evento'] . ')">' .
|
|
||||||
'<span style="position: relative; float: right; margin-right: 30px;">
|
|
||||||
<span class="ui-icon ui-icon-big ui-icon-arrow-r ui-icon-arrow-r-big ui-icon-shadow" style="position: absolute; left: 50%;"> </span>
|
|
||||||
</span>' .
|
|
||||||
'</a>';
|
|
||||||
}
|
|
||||||
$row[] = get_priority_class ($event["criticity"]);
|
$row[] = get_priority_class ($event["criticity"]);
|
||||||
$events[$event['id_evento']] = $row;
|
$events[$event['id_evento']] = $row;
|
||||||
}
|
}
|
||||||
|
@ -289,7 +277,7 @@ class Events {
|
||||||
|
|
||||||
$id_event = $system->getRequest('id_event', 0);
|
$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));
|
echo json_encode(array('correct' => 1));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -493,6 +481,7 @@ class Events {
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$options['content_text'] = ob_get_clean();
|
$options['content_text'] = ob_get_clean();
|
||||||
$options_button = array(
|
$options_button = array(
|
||||||
'text' => __('Validate'),
|
'text' => __('Validate'),
|
||||||
|
@ -513,9 +502,7 @@ class Events {
|
||||||
<h3 style="color: #ff0000;">' . __('Fail validate') . '</h3></div>';
|
<h3 style="color: #ff0000;">' . __('Fail validate') . '</h3></div>';
|
||||||
|
|
||||||
$options['button_close'] = false;
|
$options['button_close'] = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$ui->addDialog($options);
|
$ui->addDialog($options);
|
||||||
$options['type'] = 'hidden';
|
$options['type'] = 'hidden';
|
||||||
|
|
||||||
|
@ -750,17 +737,28 @@ class Events {
|
||||||
$row_class = array();
|
$row_class = array();
|
||||||
foreach ($events_db as $event) {
|
foreach ($events_db as $event) {
|
||||||
$myclass = get_priority_class ($event["criticity"]);
|
$myclass = get_priority_class ($event["criticity"]);
|
||||||
|
|
||||||
|
$details_button = '';
|
||||||
|
$open_link = '';
|
||||||
|
$close_link = '';
|
||||||
|
|
||||||
|
if (!$this->readOnly) {
|
||||||
|
/*
|
||||||
|
$details_button = '<a href="javascript: openDetails(' . $event['id_evento'] . ')" class="event_link">' .
|
||||||
|
'<span style="position: relative; float: right; margin-right: 30px;">
|
||||||
|
<span class="ui-icon ui-icon-big ui-icon-eye ui-icon-eye ui-icon-shadow" style="position: absolute; left: 50%;"> </span>
|
||||||
|
</span>' .
|
||||||
|
'</a>';
|
||||||
|
*/
|
||||||
|
|
||||||
|
$open_link = '<a href="javascript: openDetails(' . $event['id_evento'] . ')"><div style="height:100%;width:100%">';
|
||||||
|
$close_link = '</div></a>';
|
||||||
|
}
|
||||||
|
|
||||||
$row_class[$event['id_evento']] = "events $myclass";
|
$row_class[$event['id_evento']] = "events $myclass";
|
||||||
|
|
||||||
$row = array();
|
$row = array();
|
||||||
if ($this->readOnly) {
|
$row[$field_event_name] = $open_link . io_safe_output($event['evento']) . $details_button . $close_link;
|
||||||
$row[$field_event_name] = io_safe_output($event['evento']);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$row[$field_event_name] = '<a href="javascript: openDetails(' . $event['id_evento'] . ')">' .
|
|
||||||
io_safe_output($event['evento']) . '</a>';
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
switch ($event['estado']) {
|
switch ($event['estado']) {
|
||||||
case 0:
|
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 = '<span class="nobold">' . ui_print_agent_name ($event["id_agente"], true, 'agent_medium', '', false, '', '', false, false) . '</span>';
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->columns['agent']) {
|
if ($this->columns['agent']) {
|
||||||
$row[$field_agent] = '<a class="ui-link" data-ajax="false" href="index.php?page=agent&id=' . $event["id_agente"] . '">' .
|
$row[$field_agent] = $open_link . $agent_name . $close_link;
|
||||||
(string) agents_get_name($event["id_agente"]) . '</a>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!$this->readOnly) {
|
$row[' '] = $details_button;
|
||||||
$row[' '] = '<a href="javascript: openDetails(' . $event['id_evento'] . ')">' .
|
|
||||||
'<span class="button_layer">
|
|
||||||
<span class="ui-icon ui-icon-big ui-icon-arrow-r ui-icon-arrow-r-big ui-icon-shadow" style="position: absolute; left: 50%;"> </span>
|
|
||||||
</span>' .
|
|
||||||
'</a>';
|
|
||||||
$row_class[' '] = "button_row";
|
|
||||||
}
|
|
||||||
|
|
||||||
$events[$event['id_evento']] = $row;
|
$events[$event['id_evento']] = $row;
|
||||||
}
|
}
|
||||||
|
@ -882,6 +879,8 @@ class Events {
|
||||||
.html(event[\"group\"]);
|
.html(event[\"group\"]);
|
||||||
$(\"#detail_event_dialog .cell_event_tags\")
|
$(\"#detail_event_dialog .cell_event_tags\")
|
||||||
.html(event[\"tags\"]);
|
.html(event[\"tags\"]);
|
||||||
|
$(\"#detail_event_dialog .cell_agent\")
|
||||||
|
.html(event[\"agent\"]);
|
||||||
|
|
||||||
//The link to module graph
|
//The link to module graph
|
||||||
$(\".event_module_graph\").hide();
|
$(\".event_module_graph\").hide();
|
||||||
|
|
Loading…
Reference in New Issue