From 9d3c9febad228cecf10bc07a24cd8d1fc3e94339 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Tue, 12 Nov 2019 13:16:25 +0100 Subject: [PATCH] Add alert correlation wizard --- pandora_console/include/functions_html.php | 121 ++++++++++++++++++- pandora_console/include/functions_menu.php | 2 +- pandora_console/include/styles/discovery.css | 1 + pandora_console/include/styles/pandora.css | 12 ++ 4 files changed, 134 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 12a8ecfa88..e329af6013 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1618,6 +1618,89 @@ function html_print_input_email(array $settings):string } +/** + * Render an input number element. + * + * @param array $settings Array with attributes input. + * only name is necessary. + * + * @return string + */ +function html_print_input_number(array $settings):string +{ + // TODO: const. + $valid_attrs = [ + 'accept', + 'disabled', + 'maxlength', + 'name', + 'readonly', + 'placeholder', + 'size', + 'value', + 'accesskey', + 'class', + 'dir', + 'id', + 'lang', + 'style', + 'tabindex', + 'title', + 'xml:lang', + 'onfocus', + 'onblur', + 'onselect', + 'onchange', + 'onclick', + 'ondblclick', + 'onmousedown', + 'onmouseup', + 'onmouseover', + 'onmousemove', + 'onmouseout', + 'onkeypress', + 'onkeydown', + 'onkeyup', + 'required', + 'pattern', + 'autocomplete', + ]; + + $output = ''; + if (isset($settings) === true && is_array($settings) === true) { + // Check Name is necessary. + if (isset($settings['name']) === true) { + $output = ' $attr_value) { + // Check valid attribute. + if (in_array($attribute, $valid_attrs) === false) { + continue; + } + + $output .= $attribute.'="'.$attr_value.'" '; + } + + $output .= $function.'/>'; + } + } + + return $output; +} + + /** * Render an input image element. * @@ -3309,6 +3392,10 @@ function html_print_input($data, $wrapper='div', $input_only=false) $output .= html_print_input_email($data); break; + case 'number': + $output .= html_print_input_number($data); + break; + case 'hidden': $output .= html_print_input_hidden( $data['name'], @@ -3413,7 +3500,8 @@ function html_print_input($data, $wrapper='div', $input_only=false) break; case 'submit': - $output .= '<'.$wrapper.' class="action-buttons" style="width: 100%">'.html_print_submit_button( + $width = (isset($data['width']) === true) ? 'width: '.$data['width'] : 'width: 100%'; + $output .= '<'.$wrapper.' class="action-buttons" style="'.$width.'">'.html_print_submit_button( ((isset($data['label']) === true) ? $data['label'] : 'OK'), ((isset($data['name']) === true) ? $data['name'] : ''), ((isset($data['disabled']) === true) ? $data['disabled'] : false), @@ -3498,6 +3586,10 @@ function html_print_input($data, $wrapper='div', $input_only=false) $output .= html_print_input_email($data); break; + case 'multicheck': + $output .= html_print_input_multicheck($data); + break; + default: // Ignore. break; @@ -3514,6 +3606,33 @@ function html_print_input($data, $wrapper='div', $input_only=false) } +/** + * Print all checkbox in the same row. + * + * @param array $data Array with attributes input. + * only name is necessary. + * + * @return string + */ +function html_print_input_multicheck(array $data):string +{ + $html = ''; + if (isset($data['data']) === true && is_array($data['data']) === true) { + foreach ($data['data'] as $key => $value) { + $html .= $value; + $html .= html_print_checkbox( + 'days_week_'.$key, + 1, + $data['checked'][$key], + true + ); + } + } + + return $html; +} + + /** * Print an autocomplete input filled out with Integria IMS users. * diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index 36785064ef..ee242a1624 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -536,7 +536,7 @@ function menu_add_extras(&$menu) $menu_extra['galertas']['sub']['godmode/alerts/configure_alert_action']['text'] = __('Manage alert actions'); $menu_extra['galertas']['sub']['godmode/alerts/configure_alert_command']['text'] = __('Manage commands'); - $menu_extra['galertas']['sub']['enterprise/godmode/alerts/alert_events']['text'] = __('Manage event alerts'); + $menu_extra['galertas']['sub']['enterprise/godmode/alerts/alert_correlation']['text'] = __('Manage event alerts'); $menu_extra['gservers']['sub']['enterprise/godmode/servers/manage_export_form']['text'] = __('Manage export targets'); diff --git a/pandora_console/include/styles/discovery.css b/pandora_console/include/styles/discovery.css index 2aee23f645..d191357511 100644 --- a/pandora_console/include/styles/discovery.css +++ b/pandora_console/include/styles/discovery.css @@ -204,6 +204,7 @@ label { width: 100%; } +li > input[type="number"], li > input[type="text"], li > input[type="email"], li > input[type="password"], diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index d6a1d97ecf..a7bf928bb5 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -551,6 +551,18 @@ select:-internal-list-box { align-items: center; } +.flex-space-around { + justify-content: space-around; +} + +.flex-end { + justify-content: flex-end; +} + +.flex-start { + justify-content: flex-start; +} + .nowrap { flex-wrap: nowrap; }