Merge branch 'ent-7323-Bug-visuales-y-funcionamiento-parametros-de-filtros-de-eventos' into 'develop'

fixed filter load in events view

See merge request artica/pandorafms!4048
This commit is contained in:
Daniel Rodriguez 2021-04-27 10:33:15 +00:00
commit e0c7fc8c1e
2 changed files with 67 additions and 64 deletions

View File

@ -402,6 +402,8 @@ if ($load_filter_modal) {
); );
echo '<div id="load-filter-select" class="load-filter-modal">'; echo '<div id="load-filter-select" class="load-filter-modal">';
echo '<form method="post" id="form_load_filter">';
$table = new StdClass; $table = new StdClass;
$table->id = 'load_filter_form'; $table->id = 'load_filter_form';
$table->width = '100%'; $table->width = '100%';
@ -441,13 +443,15 @@ if ($load_filter_modal) {
__('Load filter'), __('Load filter'),
'load_filter', 'load_filter',
false, false,
'class="sub upd" onclick="load_form_filter();"', 'class="sub upd"',
true true
); );
$data[1] .= html_print_input_hidden('load_filter', 1, true);
$table->data[] = $data; $table->data[] = $data;
$table->rowclass[] = ''; $table->rowclass[] = '';
html_print_table($table); html_print_table($table);
echo '</form>';
echo '</div>'; echo '</div>';
?> ?>
<script type="text/javascript"> <script type="text/javascript">
@ -460,7 +464,8 @@ function show_filter() {
width: 450 width: 450
}); });
} }
//aki
function load_form_filter() { function load_form_filter() {
jQuery.post ( jQuery.post (
"<?php echo ui_get_full_url('ajax.php', false, false, false); ?>", "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",

View File

@ -446,7 +446,11 @@ if (is_ajax()) {
* Load user default form. * Load user default form.
*/ */
$user_filter = db_get_row_sql( $load_filter_id = (int) get_parameter('filter_id', 0);
if ($load_filter_id === 0) {
// Load user filter.
$loaded_filter = db_get_row_sql(
sprintf( sprintf(
'SELECT f.id_filter, f.id_name 'SELECT f.id_filter, f.id_name
FROM tevent_filter f FROM tevent_filter f
@ -456,11 +460,21 @@ $user_filter = db_get_row_sql(
$config['id_user'] $config['id_user']
) )
); );
} else {
// Load filter selected by user.
$loaded_filter['id_filter'] = $load_filter_id;
$loaded_filter['id_name'] = db_get_value(
'id_name',
'tevent_filter',
'id_filter',
$load_filter_id
);
}
// Do not load the user filter if we come from the 24h event graph. // Do not load the user filter if we come from the 24h event graph.
$from_event_graph = get_parameter('filter[from_event_graph]', $filter['from_event_graph']); $from_event_graph = get_parameter('filter[from_event_graph]', $filter['from_event_graph']);
if ($user_filter !== false && $from_event_graph != 1) { if ($loaded_filter !== false && $from_event_graph != 1) {
$filter = events_get_event_filter($user_filter['id_filter']); $filter = events_get_event_filter($loaded_filter['id_filter']);
if ($filter !== false) { if ($filter !== false) {
$id_group = $filter['id_group']; $id_group = $filter['id_group'];
$event_type = $filter['event_type']; $event_type = $filter['event_type'];
@ -1057,7 +1071,7 @@ if (empty($severity) && $severity !== '0') {
$data = html_print_select( $data = html_print_select(
get_priorities(), get_priorities(),
'severity', 'severity',
$severity, explode(',', $severity),
'', '',
__('All'), __('All'),
-1, -1,
@ -1138,6 +1152,23 @@ $params['hidden_input_idagent_name'] = 'id_agent';
$params['hidden_input_idagent_value'] = $id_agent; $params['hidden_input_idagent_value'] = $id_agent;
$params['size'] = ''; $params['size'] = '';
if ($id_agent !== null) {
if (is_metaconsole()) {
$metaconsole_agent = db_get_row_sql(
sprintf(
'SELECT alias, server_name
FROM tmetaconsole_agent
WHERE id_tagente = "%d" ',
$id_agent
)
);
$params['value'] = $metaconsole_agent['alias'].' ('.$metaconsole_agent['server_name'].')';
} else {
$params['value'] = agents_get_alias($id_agent);
}
}
$data = ui_print_agent_autocomplete_input($params); $data = ui_print_agent_autocomplete_input($params);
$in = '<div class="filter_input"><label>'.__('Agent search').'</label>'; $in = '<div class="filter_input"><label>'.__('Agent search').'</label>';
$in .= $data.'</div>'; $in .= $data.'</div>';
@ -1212,6 +1243,11 @@ $in .= $data.'</div>';
$adv_inputs[] = $in; $adv_inputs[] = $in;
if (is_metaconsole()) { if (is_metaconsole()) {
if (empty($id_source_event) === true) {
$id_source_event = '';
}
$input_id_source_event = (empty($id_source_event) === true) ? '' : $id_source_event;
$data = html_print_input_text( $data = html_print_input_text(
'id_source_event', 'id_source_event',
$id_source_event, $id_source_event,
@ -1225,6 +1261,9 @@ if (is_metaconsole()) {
$adv_inputs[] = $in; $adv_inputs[] = $in;
} }
if ($date_from === '0000-00-00') {
$date_from = '';
}
// Date from. // Date from.
$data = html_print_input_text( $data = html_print_input_text(
@ -1251,32 +1290,14 @@ $in = '<div class="filter_input">';
$in .= '<div class="filter_input_little"><label>'.__('Date from').'</label>'; $in .= '<div class="filter_input_little"><label>'.__('Date from').'</label>';
$in .= $data.'</div>'; $in .= $data.'</div>';
// Time from. $data = '';
$data = html_print_input_text(
'time_from',
$time_from,
'',
false,
10,
true,
// Disabled.
false,
// Required.
false,
// Function.
'',
// Class.
'',
// OnChange.
'',
// Autocomplete.
'off'
);
$in .= '<div class="filter_input_little"><label>'.__('Time from').'</label>';
$in .= $data.'</div>'; $in .= $data.'</div>';
$in .= '</div>';
$adv_inputs[] = $in; $adv_inputs[] = $in;
if ($date_to === '0000-00-00') {
$date_to = '';
}
// Date to. // Date to.
$data = html_print_input_text( $data = html_print_input_text(
'date_to', 'date_to',
@ -1302,33 +1323,10 @@ $in = '<div class="filter_input">';
$in .= '<div class="filter_input_little"><label>'.__('Date to').'</label>'; $in .= '<div class="filter_input_little"><label>'.__('Date to').'</label>';
$in .= $data.'</div>'; $in .= $data.'</div>';
// Time to. $data = '';
$data = html_print_input_text(
'time_to',
$time_to,
'',
false,
10,
true,
// Disabled.
false,
// Required.
false,
// Function.
'',
// Class.
'',
// OnChange.
'',
// Autocomplete.
'off'
);
$in .= '<div class="filter_input_little"><label>'.__('Time to').'</label>';
$in .= $data.'</div>'; $in .= $data.'</div>';
$in .= '</div>';
$adv_inputs[] = $in; $adv_inputs[] = $in;
// Tags. // Tags.
if (is_metaconsole()) { if (is_metaconsole()) {
$data = '<fieldset><legend class="pdd_0px">'.__('Events with following tags').'</legend>'.html_print_table($tabletags_with, true).'</fieldset>'; $data = '<fieldset><legend class="pdd_0px">'.__('Events with following tags').'</legend>'.html_print_table($tabletags_with, true).'</fieldset>';
@ -1472,8 +1470,8 @@ try {
$active_filters_div .= '<div>'; $active_filters_div .= '<div>';
$active_filters_div .= '<div class="label box-shadow">'.__('Current filter').'</div>'; $active_filters_div .= '<div class="label box-shadow">'.__('Current filter').'</div>';
$active_filters_div .= '<div id="current_filter" class="content">'; $active_filters_div .= '<div id="current_filter" class="content">';
if ($user_filter !== false) { if ($loaded_filter !== false) {
$active_filters_div .= io_safe_output($user_filter['id_name']); $active_filters_div .= io_safe_output($loaded_filter['id_name']);
} else { } else {
$active_filters_div .= __('Not set.'); $active_filters_div .= __('Not set.');
} }