diff --git a/pandora_console/extras/mr/35.sql b/pandora_console/extras/mr/35.sql new file mode 100644 index 0000000000..86236df36f --- /dev/null +++ b/pandora_console/extras/mr/35.sql @@ -0,0 +1,5 @@ +START TRANSACTION; + +ALTER TABLE `tevent_filter` MODIFY `severity` TEXT NOT NULL; + +COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index ca415cd52a..0c95628752 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1401,6 +1401,7 @@ ALTER TABLE tevent_filter ADD COLUMN `source` tinytext NOT NULL; ALTER TABLE tevent_filter ADD COLUMN `id_extra` tinytext NOT NULL; ALTER TABLE tevent_filter ADD COLUMN `id_source_event` int(10); ALTER TABLE `tevent_filter` MODIFY COLUMN `user_comment` text NOT NULL; +ALTER TABLE `tevent_filter` MODIFY COLUMN `severity` text NOT NULL; -- --------------------------------------------------------------------- -- Table `tusuario` diff --git a/pandora_console/godmode/events/event_edit_filter.php b/pandora_console/godmode/events/event_edit_filter.php index 41068372d4..a677c6f801 100644 --- a/pandora_console/godmode/events/event_edit_filter.php +++ b/pandora_console/godmode/events/event_edit_filter.php @@ -55,7 +55,7 @@ if ($id) { $id_group = $filter['id_group']; $id_name = $filter['id_name']; $event_type = $filter['event_type']; - $severity = $filter['severity']; + $severity = explode(',', $filter['severity']); $status = $filter['status']; $search = $filter['search']; $text_agent = $filter['text_agent']; @@ -123,7 +123,7 @@ if ($update || $create) { $id_group_filter = get_parameter('id_group_filter'); $id_name = (string) get_parameter('id_name'); $event_type = get_parameter('event_type', ''); - $severity = get_parameter('severity', ''); + $severity = implode(',', get_parameter('severity', -1)); $status = get_parameter('status', ''); $search = get_parameter('search', ''); $text_agent = get_parameter('text_agent', ''); @@ -172,6 +172,8 @@ if ($update || $create) { 'user_comment' => $user_comment, 'filter_only_alert' => $filter_only_alert, ]; + + $severity = explode(',', $severity); } if ($update) { @@ -289,15 +291,24 @@ $table->data[3][1] = html_print_select( true ); +if (empty($severity) && $severity !== '0') { + $severity = -1; +} + $table->data[4][0] = ''.__('Severity').''; $table->data[4][1] = html_print_select( get_priorities(), - 'severity', + 'severity[]', $severity, '', __('All'), - '-1', - true + -1, + true, + true, + true, + '', + false, + 'width: 175px' ); $fields = events_get_all_status(); diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 24fa8be341..2a068e0214 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -231,7 +231,7 @@ if ($save_event_filter) { $values['id_name'] = get_parameter('id_name'); $values['id_group'] = get_parameter('id_group'); $values['event_type'] = get_parameter('event_type'); - $values['severity'] = get_parameter('severity'); + $values['severity'] = implode(',', get_parameter('severity', -1)); $values['status'] = get_parameter('status'); $values['search'] = get_parameter('search'); $values['text_agent'] = get_parameter('text_agent'); @@ -278,7 +278,7 @@ if ($update_event_filter) { $id = get_parameter('id'); $values['id_group'] = get_parameter('id_group'); $values['event_type'] = get_parameter('event_type'); - $values['severity'] = get_parameter('severity'); + $values['severity'] = implode(',', get_parameter('severity', -1)); $values['status'] = get_parameter('status'); $values['search'] = get_parameter('search'); $values['text_agent'] = get_parameter('text_agent'); @@ -439,8 +439,10 @@ function load_form_filter() { $("#id_group").val(val); if (i == 'event_type') $("#event_type").val(val); - if (i == 'severity') - $("#severity").val(val); + if (i == 'severity') { + const multiple = val.split(","); + $("#severity").val(multiple); + } if (i == 'status') $("#status").val(val); if (i == 'search') @@ -1579,7 +1581,7 @@ if ($get_list_events_agents) { $id_agent = get_parameter('id_agent'); $server_id = get_parameter('server_id'); $event_type = get_parameter('event_type'); - $severity = get_parameter('severity'); + $severity = implode(',', get_parameter('severity', -1)); $status = get_parameter('status'); $search = get_parameter('search'); $id_agent_module = get_parameter('id_agent_module'); diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 53005037df..3734c93092 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -751,43 +751,78 @@ function events_get_all( } if (isset($filter['severity']) && $filter['severity'] > 0) { - switch ($filter['severity']) { - case EVENT_CRIT_MAINTENANCE: - case EVENT_CRIT_INFORMATIONAL: - case EVENT_CRIT_NORMAL: - case EVENT_CRIT_MINOR: - case EVENT_CRIT_WARNING: - case EVENT_CRIT_MAJOR: - case EVENT_CRIT_CRITICAL: - default: - $sql_filters[] = sprintf( - ' AND criticity = %d ', - $filter['severity'] - ); - break; + if (is_array($filter['severity'])) { + if (!in_array(-1, $filter['severity'])) { + $not_normal = array_search(EVENT_CRIT_NOT_NORMAL, $filter['severity']); + if ($not_normal !== false) { + unset($filter['severity'][$not_normal]); + $sql_filters[] = sprintf( + ' AND criticity != %d', + EVENT_CRIT_NORMAL + ); + } else { + $critical_warning = array_search(EVENT_CRIT_WARNING_OR_CRITICAL, $filter['severity']); + if ($critical_warning !== false) { + unset($filter['severity'][$critical_warning]); + $filter['severity'][] = EVENT_CRIT_WARNING; + $filter['severity'][] = EVENT_CRIT_CRITICAL; + } - case EVENT_CRIT_WARNING_OR_CRITICAL: - $sql_filters[] = sprintf( - ' AND (criticity = %d OR criticity = %d)', - EVENT_CRIT_WARNING, - EVENT_CRIT_CRITICAL - ); - break; + $critical_normal = array_search(EVENT_CRIT_OR_NORMAL, $filter['severity']); + if ($critical_normal !== false) { + unset($filter['severity'][$critical_normal]); + $filter['severity'][] = EVENT_CRIT_NORMAL; + $filter['severity'][] = EVENT_CRIT_CRITICAL; + } - case EVENT_CRIT_NOT_NORMAL: - $sql_filters[] = sprintf( - ' AND criticity != %d', - EVENT_CRIT_NORMAL - ); - break; + if (!empty($filter['severity'])) { + $filter['severity'] = implode(',', $filter['severity']); + $sql_filters[] = sprintf( + ' AND criticity IN (%s)', + $filter['severity'] + ); + } + } + } + } else { + switch ($filter['severity']) { + case EVENT_CRIT_MAINTENANCE: + case EVENT_CRIT_INFORMATIONAL: + case EVENT_CRIT_NORMAL: + case EVENT_CRIT_MINOR: + case EVENT_CRIT_WARNING: + case EVENT_CRIT_MAJOR: + case EVENT_CRIT_CRITICAL: + default: + $sql_filters[] = sprintf( + ' AND criticity = %d ', + $filter['severity'] + ); + break; - case EVENT_CRIT_OR_NORMAL: - $sql_filters[] = sprintf( - ' AND (criticity = %d OR criticity = %d)', - EVENT_CRIT_NORMAL, - EVENT_CRIT_CRITICAL - ); - break; + case EVENT_CRIT_WARNING_OR_CRITICAL: + $sql_filters[] = sprintf( + ' AND (criticity = %d OR criticity = %d)', + EVENT_CRIT_WARNING, + EVENT_CRIT_CRITICAL + ); + break; + + case EVENT_CRIT_NOT_NORMAL: + $sql_filters[] = sprintf( + ' AND criticity != %d', + EVENT_CRIT_NORMAL + ); + break; + + case EVENT_CRIT_OR_NORMAL: + $sql_filters[] = sprintf( + ' AND (criticity = %d OR criticity = %d)', + EVENT_CRIT_NORMAL, + EVENT_CRIT_CRITICAL + ); + break; + } } } diff --git a/pandora_console/include/styles/events.css b/pandora_console/include/styles/events.css index 9461fcf424..a0b2fdf89c 100644 --- a/pandora_console/include/styles/events.css +++ b/pandora_console/include/styles/events.css @@ -30,7 +30,6 @@ div.mini-criticity.h100p { form.flex-row div.filter_input, form.flex-row ul { width: 30%; - min-width: 300px; display: flex; flex-direction: row; align-items: baseline; @@ -47,12 +46,13 @@ div.filter_input_little { flex-direction: row; align-items: baseline; flex-wrap: nowrap; - margin: 0.5em 0 0.5em 1em; + margin: 0.5em 0 0.5em 0em; } form.flex-row div.filter_input.large { flex: 1; - min-width: 470px; + min-width: 700px; + max-width: 100%; } div.filter_input > label, @@ -120,6 +120,8 @@ table.dataTable tbody td { .filter_input { align-items: center; + min-width: 400px; + max-width: 450px; } .filter_input_little > select, diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 9cabe15b47..3b065f9c12 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -894,22 +894,6 @@ $in = '