wip event vwr ui-box close tick

This commit is contained in:
fbsanchez 2019-06-17 17:02:33 +02:00
parent 36a1387632
commit ab7d72a1c9
13 changed files with 152 additions and 89 deletions

View File

@ -954,26 +954,26 @@ if ($change_owner) {
return;
}
// Generate a modal window with extended information of given event.
if ($get_extended_event) {
global $config;
$event_id = get_parameter('event_id', false);
$childrens_ids = get_parameter('childrens_ids');
$childrens_ids = json_decode($childrens_ids);
$event = get_parameter('event', false);
if ($meta) {
$event = events_meta_get_event($event_id, false, $history, 'ER');
} else {
$event = events_get_event($event_id);
if ($event === false) {
return;
}
$event_id = $event['id_evento'];
$readonly = false;
if (!$meta
&& isset($config['event_replication'])
&& $config['event_replication'] == 1
&& $config['show_events_in_local'] == 1
) {
$readonly = true;
$readonly = true;
}
// Clean url from events and store in array.
@ -986,20 +986,17 @@ if ($get_extended_event) {
}
$dialog_page = get_parameter('dialog_page', 'general');
$similar_ids = get_parameter('similar_ids', $event_id);
$group_rep = get_parameter('group_rep', false);
$event_rep = get_parameter('event_rep', 1);
$timestamp_first = get_parameter('timestamp_first', $event['utimestamp']);
$timestamp_last = get_parameter('timestamp_last', $event['utimestamp']);
$server_id = get_parameter('server_id', 0);
$filter = get_parameter('filter', []);
$group_rep = $filter['group_rep'];
$event_rep = $event['event_rep'];
$timestamp_first = $event['min_timestamp'];
$timestamp_last = $event['max_timestamp'];
$server_id = $event['server_id'];
$comments = $event['comments'];
$event_rep = events_get_related_events($event_id, true, $filter);
$event['similar_ids'] = $similar_ids;
$event['timestamp_first'] = $timestamp_first;
$event['timestamp_last'] = $timestamp_last;
$event['event_rep'] = $event_rep;
if (!isset($comments)) {
$comments = $event['user_comment'];
}
// Check ACLs.
if (is_user_admin($config['id_user'])) {

View File

@ -448,6 +448,7 @@ function events_update_status($id_evento, $status, $filter=null, $history=false)
* @param string $sort_field Sort field.
* @param boolean $history Apply on historical table.
* @param boolean $return_sql Return SQL (true) or execute it (false).
* @param string $having Having filter.
*
* @return array Events.
* @throws Exception On error.
@ -460,7 +461,8 @@ function events_get_all(
$order=null,
$sort_field=null,
$history=false,
$return_sql=false
$return_sql=false,
$having=''
) {
global $config;
@ -653,6 +655,17 @@ function events_get_all(
// Free search.
if (!empty($filter['search'])) {
if (isset($config['dbconnection']->server_version)
&& $config['dbconnection']->server_version > 50600
) {
// Use "from_base64" requires mysql 5.6 or greater.
$custom_data_search = 'from_base64(te.custom_data)';
} else {
// Custom data is JSON encoded base64, if 5.6 or lower,
// user is condemned to use plain search.
$custom_data_search = 'te.custom_data';
}
$sql_filters[] = vsprintf(
' AND (lower(ta.alias) like lower("%%%s%%")
OR te.id_evento like "%%%s%%"
@ -660,7 +673,7 @@ function events_get_all(
OR lower(te.user_comment) like lower("%%%s%%")
OR lower(te.id_extra) like lower("%%%s%%")
OR lower(te.source) like lower("%%%s%%")
OR lower(te.custom_data) like lower("%%%s%%") )',
OR lower('.$custom_data_search.') like lower("%%%s%%") )',
array_fill(0, 7, $filter['search'])
);
}
@ -947,7 +960,8 @@ function events_get_all(
if ($group_by != '') {
$group_selects = ',COUNT(id_evento) AS event_rep
,GROUP_CONCAT(DISTINCT user_comment SEPARATOR "<br>") AS comments,
MAX(timestamp) as max_timestamp,
MAX(utimestamp) as timestamp_last,
MIN(utimestamp) as timestamp_first,
MAX(id_evento) as max_id_evento';
if ($count === false) {
@ -974,6 +988,7 @@ function events_get_all(
%s
%s
%s
%s
',
join(',', $fields),
$group_selects,
@ -988,7 +1003,8 @@ function events_get_all(
join(' ', $sql_filters),
$group_by,
$order_by,
$pagination
$pagination,
$having
);
if (!$user_is_admin) {

View File

@ -1,20 +1,19 @@
/*global jQuery,$,forced_title_callback,Base64, dt_events*/
// Show the modal window of an event
function show_event_dialog(event_id, group_rep, dialog_page, result) {
function show_event_dialog(event, dialog_page, result) {
var ajax_file = $("#hidden-ajax_file").val();
if (dialog_page == undefined) {
dialog_page = "general";
}
var similar_ids = $("#hidden-similar_ids_" + event_id).val();
var timestamp_first = $("#hidden-timestamp_first_" + event_id).val();
var timestamp_last = $("#hidden-timestamp_last_" + event_id).val();
var user_comment = $("#hidden-user_comment_" + event_id).val();
var event_rep = $("#hidden-event_rep_" + event_id).val();
var server_id = $("#hidden-server_id_" + event_id).val();
var childrens_ids = $("#hidden-childrens_ids").val();
try {
event = JSON.parse(atob(event));
} catch (e) {
console.error(e);
return;
}
var inputs = $("#events_form :input");
var values = {};
@ -33,17 +32,9 @@ function show_event_dialog(event_id, group_rep, dialog_page, result) {
{
page: "include/ajax/events",
get_extended_event: 1,
group_rep: group_rep,
event_rep: event_rep,
dialog_page: dialog_page,
similar_ids: similar_ids,
timestamp_first: timestamp_first,
timestamp_last: timestamp_last,
user_comment: user_comment,
event_id: event_id,
server_id: server_id,
event: event,
meta: meta,
childrens_ids: childrens_ids,
history: history,
filter: values
},
@ -53,7 +44,7 @@ function show_event_dialog(event_id, group_rep, dialog_page, result) {
.empty()
.append(data)
.dialog({
title: get_event_name(event_id, meta, history),
title: event.evento,
resizable: true,
draggable: true,
modal: true,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -168,22 +168,22 @@
.ui-dialog-titlebar {
border: 0px;
}
.ui-dialog-titlebar .ui-icon-closethick,
.ui-dialog-titlebar .ui-state-default,
.ui-dialog-titlebar .ui-state-hover,
.ui-dialog-titlebar button {
background: transparent;
border: 0px;
.ui-state-hover .ui-icon,
.ui-state-focus .ui-icon,
.ui-button:hover .ui-icon,
.ui-button:focus .ui-icon {
background: none;
}
.ui-dialog-titlebar.ui-icon-closethick:hover,
.ui-dialog-titlebar .ui-icon-closethick {
margin-top: -5px;
background-image: url("../../../images/icono_cerrar.png");
top: 20%;
left: 70%;
background: none;
}
.ui-dialog-titlebar.ui-icon-closethick:hover {
background-image: url("../../../images/icono_cerrar.png");
.ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close,
.ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close:hover {
background: url("../../../images/icono_cerrar.png") no-repeat center center;
}
.ui-dialog-title {
color: #ffffff;
font-size: 9pt;

View File

@ -142,41 +142,43 @@ switch ($status) {
break;
}
$events_wi_cdata = db_get_all_rows_sql('SELECT id_evento,custom_data from tevento WHERE custom_data != ""');
$count_events = 0;
$events_wi_cdata_id = 'OR id_evento IN (';
if ($events_wi_cdata === false) {
$events_wi_cdata = [];
}
foreach ($events_wi_cdata as $key => $value) {
$needle = base64_decode($value['custom_data']);
if (($needle != '') && ($search != '')) {
if (strpos(strtolower($needle), strtolower($search)) != false) {
$events_wi_cdata_id .= $value['id_evento'];
$count_events++;
}
}
if ($value !== end($events_wi_cdata) && $count_events > 0) {
$events_wi_cdata_id .= ',';
$events_wi_cdata_id = str_replace(',,', ',', $events_wi_cdata_id);
}
}
$events_wi_cdata_id .= ')';
$events_wi_cdata_id = str_replace(',)', ')', $events_wi_cdata_id);
if ($count_events == 0) {
$events_wi_cdata_id = '';
}
/*
* Never use things like this.
*
* $events_wi_cdata = db_get_all_rows_sql('SELECT id_evento,custom_data from tevento WHERE custom_data != ""');
* $count_events = 0;
* $events_wi_cdata_id = 'OR id_evento IN (';
* if ($events_wi_cdata === false) {
* $events_wi_cdata = [];
* }
*
* foreach ($events_wi_cdata as $key => $value) {
* $needle = base64_decode($value['custom_data']);
* if (($needle != '') && ($search != '')) {
* if (strpos(strtolower($needle), strtolower($search)) != false) {
* $events_wi_cdata_id .= $value['id_evento'];
* $count_events++;
* }
* }
*
* if ($value !== end($events_wi_cdata) && $count_events > 0) {
* $events_wi_cdata_id .= ',';
* $events_wi_cdata_id = str_replace(',,', ',', $events_wi_cdata_id);
* }
* }
*
* $events_wi_cdata_id .= ')';
*
* $events_wi_cdata_id = str_replace(',)', ')', $events_wi_cdata_id);
*
* if ($count_events == 0) {
* $events_wi_cdata_id = '';
* }
*/
if ($search != '') {
$filter_resume['free_search'] = $search;
$sql_post .= " AND (evento LIKE '%".$search."%' OR id_evento LIKE '%$search%' ".$events_wi_cdata_id.')';
$sql_post .= " AND (evento LIKE '%".$search."%' OR id_evento LIKE '%$search%' )";
}
if ($event_type != '') {

View File

@ -169,7 +169,9 @@ if (is_ajax()) {
$data = array_reduce(
$events,
function ($carry, $item) {
$carry[] = (object) $item;
$tmp = (object) $item;
$tmp->evento = io_safe_output($tmp->evento);
$carry[] = $tmp;
return $carry;
}
);
@ -589,6 +591,47 @@ if (is_metaconsole() !== true) {
}
}
/*
* Load user default form.
*/
$user_filter = db_get_row_sql(
sprintf(
'SELECT f.id_filter, f.id_name
FROM tevent_filter f
INNER JOIN tusuario u
ON u.default_event_filter=f.id_filter
WHERE u.id_user = "%s" ',
$config['id_user']
)
);
if ($user_filter !== false) {
$filter = events_get_event_filter($user_filter['id_filter']);
if ($filter !== false) {
$id_group = $filter['id_group'];
$event_type = $filter['event_type'];
$severity = $filter['severity'];
$status = $filter['status'];
$search = $filter['search'];
$text_agent = $filter['text_agent'];
$id_agent = $filter['id_agent'];
$id_agent_module = $filter['id_agent_module'];
$pagination = $filter['pagination'];
$event_view_hr = $filter['event_view_hr'];
$id_user_ack = $filter['id_user_ack'];
$group_rep = $filter['group_rep'];
$tag_with = $filter['tag_with'];
$tag_without = $filter['tag_without'];
$filter_only_alert = $filter['filter_only_alert'];
$id_group_filter = $filter['id_group_filter'];
$date_from = $filter['date_from'];
$date_to = $filter['date_to'];
$source = $filter['source'];
$id_extra = $filter['id_extra'];
$user_comment = $filter['user_comment'];
}
}
/*
* Load filter form.
*/
@ -1039,6 +1082,20 @@ try {
// Open current filter quick reference.
$active_filters_div = '<div class="filter_summary">';
// Current filter.
$active_filters_div .= '<div>';
$active_filters_div .= '<div class="label box-shadow">'.__('Current filter').'</div>';
$active_filters_div .= '<div id="current_filter" class="content">';
if ($user_filter !== false) {
$active_filters_div .= io_safe_output($user_filter['id_name']);
} else {
$active_filters_div .= __('Not set.');
}
$active_filters_div .= '</div>';
$active_filters_div .= '</div>';
// Event status.
$active_filters_div .= '<div>';
$active_filters_div .= '<div class="label box-shadow">'.__('Event status').'</div>';
@ -1362,8 +1419,8 @@ function process_datatables_item(item) {
// Add event severity to end of text.
evn = '<div class="event flex-row h100p nowrap">';
evn += '<div><a href="javascript:" onclick="show_event_dialog(';
evn += item.id_evento+','+$("#group_rep").val()+');">';
evn += '<div><a href="javascript:" onclick="show_event_dialog(\'';
evn += btoa(JSON.stringify(item))+'\','+$("#group_rep").val()+');">';
// Grouped events.
if(item.event_rep) {
evn += '('+item.event_rep+') ';