#12052 Fix filter alter detail view

This commit is contained in:
miguel angel rasteu 2023-09-19 13:50:06 +02:00
parent d94670c34d
commit d83c1a81d2
4 changed files with 38 additions and 16 deletions

View File

@ -435,6 +435,7 @@ if ($get_agent_alerts_datatable === true) {
}
$idGroup = $filter_alert['ag_group'];
$search_sg = $filter_alert['search_sg'];
$tag_filter = $filter_alert['tag'];
$action_filter = $filter_alert['action'];
@ -658,10 +659,9 @@ if ($get_agent_alerts_datatable === true) {
$id_groups = array_keys(
users_get_groups($config['id_user'], 'AR', false)
);
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter, $search_sg);
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
$countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
$countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter, $search_sg);
}
} else {
if ($idAgent !== 0) {
@ -673,9 +673,9 @@ if ($get_agent_alerts_datatable === true) {
users_get_groups($config['id_user'], $access, false)
);
$alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter, false);
$alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter, false, $search_sg);
$countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter, false);
$countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter, false, $search_sg);
}
}

View File

@ -2109,16 +2109,14 @@ function get_group_alerts(
$strict_user=false,
$tag=false,
$action_filter=false,
$alert_action=true
$alert_action=true,
$search_sg=false
) {
global $config;
$group_query = '';
if (!empty($idGroup)) {
$group_query = ' AND id_grupo = '.$idGroup;
$has_secondary = enterprise_hook('agents_is_using_secondary_groups');
if ((bool) $has_secondary === true) {
if ((bool) $search_sg === true) {
$group_query .= ' OR tasg.id_group = '.$idGroup;
}
}

View File

@ -56,8 +56,19 @@ function validateAlert($ids)
}
function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_standby=false, $tag_filter=false, $action_filter=false, $return=false, $strict_user=false, $access='AR')
{
function printFormFilterAlert(
$id_group,
$filter,
$free_search,
$url,
$filter_standby=false,
$tag_filter=false,
$action_filter=false,
$return=false,
$strict_user=false,
$access='AR',
$search_sg=0
) {
global $config;
include_once $config['homedir'].'/include/functions_tags.php';
@ -147,7 +158,12 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st
$callbackTag
);
$table->data[1][0] = html_print_label_input_block(
$table->data[3][0] = html_print_label_input_block(
__('Also search in secondary groups'),
html_print_checkbox_switch_extended('search_sg', 0, 0, false, '', '', true)
);
$table->data[2][0] = html_print_label_input_block(
__('Free text for search').ui_print_help_tip(
__('Filter by agent name, module name, template name or action name'),
true
@ -155,7 +171,7 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st
html_print_input_text('free_search', $free_search, '', 20, 40, true)
);
$table->data[1][1] = html_print_label_input_block(
$table->data[2][1] = html_print_label_input_block(
__('Standby'),
html_print_select(
$alert_standby,
@ -174,7 +190,7 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st
);
$alert_action = alerts_get_alert_actions_filter();
$table->data[1][2] = html_print_label_input_block(
$table->data[2][2] = html_print_label_input_block(
__('Action'),
html_print_select(
$alert_action,

View File

@ -58,7 +58,7 @@ $filter_standby = get_parameter('standby', 'all');
$id_group = (int) get_parameter('ag_group', 0);
// 0 is the All group (selects all groups)
$free_search = get_parameter('free_search', '');
$search_sg = get_parameter('search_sg', 0);
$user_tag_array = tags_get_user_tags($config['id_user'], 'AR', true);
if ($user_tag_array) {
@ -557,6 +557,14 @@ $(document).ready ( function () {
});
});
$('#checkbox-search_sg').click(function(){
if ($('#checkbox-search_sg').val() == 0) {
$('#checkbox-search_sg').val(1);
}else {
$('#checkbox-search_sg').val(0);
}
});
$('table.alert-status-filter #ag_group').change (function () {
var strict_user = $("#text-strict_user_hidden").val();
var is_meta = $("#text-is_meta_hidden").val();