10454-Fix filters

This commit is contained in:
Pablo Aragon 2023-02-24 10:04:23 +01:00
parent f08fc6a8b7
commit a9d49dea3b
4 changed files with 228 additions and 82 deletions

View File

@ -569,7 +569,7 @@ if ($load_filter_modal) {
$table->width = '100%';
$table->cellspacing = 4;
$table->cellpadding = 4;
$table->styleTable = 'font-weight: bold; color: #555; text-align:left;';
$table->styleTable = 'font-weight: bold; color: #555; text-align:left; border: 0px !important;';
$table->class = 'databox';
$filter_id_width = '200px';
if (is_metaconsole() === true) {
@ -581,7 +581,7 @@ if ($load_filter_modal) {
$data = [];
$table->rowid[3] = 'update_filter_row1';
$data[0] = __('Load filter').$jump;
$data[0] = '<b>'.__('Load filter').'</b>'.$jump;
$data[0] .= html_print_select(
$filters,
'filter_id',
@ -621,7 +621,7 @@ function show_filter() {
draggable: true,
modal: false,
closeOnEscape: true,
width: 450
width: 550
});
}
@ -754,9 +754,9 @@ if ($save_filter_modal) {
$table->cellpadding = 0;
}
$table->styleTable = 'font-weight: bold; text-align:left;';
$table->styleTable = 'font-weight: bold; text-align:left; border: 0px !important;';
if (is_metaconsole() === false) {
$table->style[0] = 'width: 50%; width:50%;';
$table->style[0] = '';
}
$data = [];
@ -782,12 +782,12 @@ if ($save_filter_modal) {
$data = [];
$table->rowid[1] = 'save_filter_row1';
$data[0] = __('Filter name').$jump;
$data[0] = '<b>'.__('Filter name').'</b>'.$jump;
$data[0] .= html_print_input_text('id_name', '', '', 15, 255, true);
if (is_metaconsole()) {
$data[1] = __('Save in Group').$jump;
} else {
$data[1] = __('Filter group').$jump;
$data[1] = '<b>'.__('Filter group').'</b>'.$jump;
}
$user_groups_array = users_get_groups_for_select(
@ -893,7 +893,8 @@ function show_save_filter() {
resizable: true,
draggable: true,
modal: false,
closeOnEscape: true
closeOnEscape: true,
width: 700
});
}

View File

@ -3449,6 +3449,14 @@ function ui_print_datatable(array $parameters)
$parameters['paging'] = true;
}
if (!isset($parameters['filter_main_class'])) {
$parameters['filter_main_class'] = '';
}
if (!isset($parameters['toggle_collapsed'])) {
$parameters['toggle_collapsed'] = true;
}
$no_sortable_columns = json_encode([]);
if (isset($parameters['no_sortable_columns'])) {
$no_sortable_columns = json_encode($parameters['no_sortable_columns']);
@ -3559,7 +3567,7 @@ function ui_print_datatable(array $parameters)
$filter .= $parameters['form']['html'];
}
$filter .= '<ul class="datatable_filter content filter_table">';
$filter .= '<ul class="datatable_filter content filter_table no_border">';
foreach ($parameters['form']['inputs'] as $input) {
$filter .= html_print_input(($input + ['return' => true]), 'li');
@ -3568,19 +3576,21 @@ function ui_print_datatable(array $parameters)
$filter .= '<li>';
// Extra buttons.
$extra_buttons = '';
if (isset($parameters['form']['extra_buttons']) === true
&& is_array($parameters['form']['extra_buttons']) === true
) {
foreach ($parameters['form']['extra_buttons'] as $button) {
$filter .= html_print_button(
$extra_buttons .= html_print_button(
$button['text'],
$button['id'],
false,
$button['onclick'],
[
'style' => ($button['style'] ?? ''),
'mode' => 'link',
'mode' => 'secondary mini',
'class' => $button['class'],
'icon' => $button['icon'],
],
true
);
@ -3601,7 +3611,7 @@ function ui_print_datatable(array $parameters)
'class' => $search_button_class,
],
true
),
).$extra_buttons,
],
true
);
@ -3612,25 +3622,27 @@ function ui_print_datatable(array $parameters)
if (isset($parameters['form']['no_toggle']) === false) {
$filter = ui_toggle(
$filter,
'<span class="subsection_header_title">'.__('Filter').'</span>',
'<span class="subsection_header_title">'.__('Filters').'</span>',
'',
'',
true,
$parameters['toggle_collapsed'],
false,
'white_box white_box_opened fixed_filter_content',
'no-border'
'',
'no-border filter-datatable-submain',
'filter-datatable-main '.$parameters['filter_main_class']
);
}
} else if (isset($parameters['form_html'])) {
$filter = ui_toggle(
$parameters['form_html'],
'<span class="subsection_header_title">'.__('Filter').'</span>',
'<span class="subsection_header_title">'.__('Filters').'</span>',
'',
'',
true,
$parameters['toggle_collapsed'],
false,
'white_box white_box_opened fixed_filter_bar',
'no-border'
'',
'no-border filter-datatable-submain',
'box-float white_table_graph filter-datatable-main '.$parameters['filter_main_class']
);
}

View File

@ -561,3 +561,96 @@ table.filter-table-adv td > div .label-thin {
/*
padding-right: calc(100% - 1024px);
*/
div.filter-datatable-submain {
padding: 10px 25px;
}
div.filter-datatable-submain > form > div.filter_input {
max-width: 20%;
display: grid;
justify-content: initial;
}
div.filter-datatable-submain > form {
align-items: flex-start;
}
div.filter-datatable-submain > form > div.filter_input > label,
div.advanced-options-events > div.filter_input > label {
font-size: 13px;
line-height: 16px;
font-weight: bold;
margin-bottom: 10px;
}
div.filter-datatable-submain > form > div.filter_input,
div.advanced-options-events > div.filter_input {
margin-bottom: 10px !important;
}
.display-initial {
display: initial;
/* margin-bottom: 10px; */
}
.vert-align-bottom {
vertical-align: bottom;
}
label.vert-align-bottom > a.tip {
vertical-align: middle;
}
div.display-initial > a.tip {
vertical-align: bottom;
}
div.advanced-options-events > div.filter_input {
display: grid !important;
}
div.advanced-options-events > div.filter_input input {
width: 400px;
}
div.advanced-options-events > div.filter_input.large {
display: flex !important;
}
div.filter_input > div.datetime-adv-opt > input.hasDatepicker {
width: 193px !important;
}
div.filter_input > div.datetime-adv-opt > span {
padding: 0px 5px;
}
tr#update_save_selector {
display: block;
}
td#load_filter_form-0-0,
td#load_filter_form-0-1,
td#save_filter_form-1-0,
td#save_filter_form-1-1 {
display: grid;
}
td#load_filter_form-0-0 > b,
td#save_filter_form-1-0 > b {
padding-bottom: 10px;
font-size: 13px;
line-height: 16px;
}
tr#save_filter_row1 {
display: flex !important;
}
td#save_filter_form-0-0,
td#save_filter_form-0-1,
td#save_filter_form-1-0 > input#text-id_name,
td#save_filter_form-1-1 > span {
width: 300px !important;
}

View File

@ -1655,11 +1655,57 @@ $data = html_print_input(
'selected' => $id_group,
'nothing' => false,
'return' => true,
'size' => '80%',
'size' => '100%',
]
);
$in = '<div class="filter_input"><label>'.__('Group').'</label>';
$in .= $data.'</div>';
$in .= $data;
// Search recursive groups.
$data = html_print_checkbox_switch(
'search_recursive_groups',
$search_recursive_groups,
$search_recursive_groups,
true,
false,
'checked_slide_events(this);',
true
);
$in_group = '<div class="display-initial">';
$in_group .= $data;
$in_group .= '<label class="vert-align-bottom pdd_r_20px">';
$in_group .= __('Group recursion');
$in_group .= ui_print_help_tip(
__('WARNING: This could cause a performace impact.'),
true
);
$in_group .= '</label>';
$in .= $in_group;
// Search secondary groups.
$data = html_print_checkbox_switch(
'search_secondary_groups',
$search_secondary_groups,
$search_secondary_groups,
true,
false,
'checked_slide_events(this);',
true
);
$in_sec_group .= $data;
$in_sec_group .= '<label class="vert-align-bottom">';
$in_sec_group .= __('Search in secondary groups');
$in_sec_group .= ui_print_help_tip(
__('WARNING: This could cause a performace impact.'),
true
);
$in_sec_group .= '</label>';
$in_sec_group .= '</div>';
$in .= $in_sec_group;
$in .= '</div>';
$inputs[] = $in;
// Event type.
@ -1726,11 +1772,9 @@ $inputs[] = $in;
// Free search.
$data = html_print_input_text('search', $search, '', '', 255, true);
// Search recursive groups.
$data .= ui_print_help_tip(
__('Search for elements NOT containing given text.'),
true
);
$data .= '<div class="display-initial">';
$data .= html_print_checkbox_switch(
'not_search',
$not_search,
@ -1740,6 +1784,13 @@ $data .= html_print_checkbox_switch(
'checked_slide_events(this);',
true
);
$data .= ui_print_help_tip(
__('Search for elements NOT containing given text.'),
true
);
$data .= '</div>';
$in = '<div class="filter_input filter_input_not_search"><label>'.__('Free search').'</label>';
$in .= $data;
$in .= '</div>';
@ -1774,52 +1825,8 @@ $in = '<div class="filter_input"><label>'.__('Severity').'</label>';
$in .= $data.'</div>';
$inputs[] = $in;
// Search recursive groups.
$data = html_print_checkbox_switch(
'search_recursive_groups',
$search_recursive_groups,
$search_recursive_groups,
true,
false,
'checked_slide_events(this);',
true
);
$in = '<div class="filter_input filter_input_switch"><label>';
$in .= __('Group recursion');
$in .= ui_print_help_tip(
__('WARNING: This could cause a performace impact.'),
true
);
$in .= '</label>';
$in .= $data;
$in .= '</div>';
$inputs[] = $in;
// Search secondary groups.
$data = html_print_checkbox_switch(
'search_secondary_groups',
$search_secondary_groups,
$search_secondary_groups,
true,
false,
'checked_slide_events(this);',
true
);
$in = '<div class="filter_input filter_input_switch"><label>';
$in .= __('Search in secondary groups');
$in .= ui_print_help_tip(
__('WARNING: This could cause a performace impact.'),
true
);
$in .= '</label>';
$in .= $data;
$in .= '</div>';
$inputs[] = $in;
// Trick view in table.
$inputs[] = '<div class="w100p"></div>';
$inputs[] = '<div class="w100p pdd_t_15px"></div>';
$buttons = [];
@ -1828,14 +1835,16 @@ $buttons[] = [
'class' => 'float-left margin-right-2',
'text' => __('Load filter'),
'onclick' => '',
'icon' => 'search',
];
if ($event_w === true || $event_m === true) {
$buttons[] = [
'id' => 'save-filter',
'class' => 'float-left margin-right-2',
'class' => 'margin-right-2',
'text' => __('Save filter'),
'onclick' => '',
'icon' => 'search',
];
}
@ -1908,8 +1917,9 @@ if ($id_agent !== null) {
}
$data = ui_print_agent_autocomplete_input($params);
$in = '<div class="filter_input"><label>'.__('Agent search').'</label>';
$in .= $data.'</div>';
$in = '<div class="filter_input"><label>'.__('Agent search');
$in .= '</label>'.$data.'</div>';
$adv_inputs[] = $in;
// Mixed. Metaconsole => server, Console => module.
@ -1962,7 +1972,12 @@ $data = html_print_select(
'',
__('Any'),
0,
true
true,
false,
true,
'',
false,
'width: 400px'
);
$in = '<div class="filter_input"><label>'.__('User ack.').'</label>';
$in .= $data.'</div>';
@ -1975,7 +1990,12 @@ $data = html_print_select(
'',
__('Any'),
0,
true
true,
false,
true,
'',
false,
'width: 400px'
);
$in = '<div class="filter_input"><label>'.__('Owner').'</label>';
$in .= $data.'</div>';
@ -1992,7 +2012,12 @@ $data = html_print_select(
'',
__('All'),
-1,
true
true,
false,
true,
'',
false,
'width: 400px'
);
$adv_inputs[] = html_print_div(
@ -2079,7 +2104,7 @@ $adv_inputs[] = html_print_div(
[
'class' => 'filter_input',
'content' => sprintf(
'<label>%s</label>%s<span>:</span>%s',
'<label>%s</label><div class="datetime-adv-opt">%s<span>:</span>%s</div>',
__('From (date:time)'),
$inputDateFrom,
$inputTimeFrom
@ -2137,7 +2162,7 @@ $adv_inputs[] = html_print_div(
[
'class' => 'filter_input',
'content' => sprintf(
'<label>%s</label>%s<span>:</span>%s',
'<label>%s</label><div class="datetime-adv-opt">%s<span>:</span>%s</div>',
__('To (date:time)'),
$inputDateTo,
$inputTimeTo
@ -2157,7 +2182,12 @@ $custom_data_filter_type_input = html_print_select(
'',
false,
-1,
true
true,
false,
true,
'',
false,
'width: 400px'
);
$adv_inputs[] = html_print_div(
@ -2217,8 +2247,8 @@ $filter .= ui_toggle(
'',
true,
true,
'white_box white_box_opened',
'no-border flex-row',
'white_box white_box_opened no_border',
'advanced-options-events no-border flex-row',
'box-flat white_table_graph w100p'
);
@ -2451,6 +2481,7 @@ try {
'drawCallback' => 'process_datatables_callback(this, settings)',
'print' => false,
'csv' => 0,
'filter_main_class' => 'box-flat white_table_graph fixed_filter_bar',
],
),
]
@ -3172,4 +3203,13 @@ function show_instructions(id){
});
}
$(document).ready(function () {
let agentLabel = $('#text-text_agent').prev();
let agentTip = $('#text-text_agent').next();
agentLabel.append(agentTip);
let moduleLabel = $('#text-module_search').prev();
let moduleTip = $('#text-module_search').next().next();
moduleLabel.append(moduleTip);
});
</script>