diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 2f01df4a55..a85844bd7a 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -1777,7 +1777,6 @@ if (is_metaconsole() === false) { }); $("#button-uptbutton").click (function () { - console.log('aaaaaaaaaaaaa'); if($("#autorefresh_list option").length > 0) { $('#autorefresh_list option').prop('selected', true); } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 189bef609c..7691ec2fde 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -768,7 +768,8 @@ function html_print_select( $select2_enable=true, $select2_multiple_enable=false, $select2_multiple_enable_all=false, - $form='' + $form='', + $order=false, ) { $output = "\n"; @@ -805,6 +806,10 @@ function html_print_select( } } + if ($multiple === true && $order === true) { + $class .= ' order-arrows'; + } + if (!empty($class)) { $attributes .= ' class="'.$class.'"'; } @@ -1124,6 +1129,49 @@ function html_print_select( $output .= ''; } + if ($multiple === true && $order === true) { + $output .= ''; + } + if ($return) { return $output; } @@ -5510,7 +5558,9 @@ function html_print_input($data, $wrapper='div', $input_only=false) ((isset($data['truncate_size']) === true) ? $data['truncate_size'] : false), ((isset($data['select2_enable']) === true) ? $data['select2_enable'] : true), ((isset($data['select2_multiple_enable']) === true) ? $data['select2_multiple_enable'] : false), - ((isset($data['select2_multiple_enable_all']) === true) ? $data['select2_multiple_enable_all'] : false) + ((isset($data['select2_multiple_enable_all']) === true) ? $data['select2_multiple_enable_all'] : false), + ((isset($data['form']) === true) ? $data['form'] : ''), + ((isset($data['order']) === true) ? $data['order'] : false) ); break; @@ -6024,6 +6074,94 @@ function html_print_input($data, $wrapper='div', $input_only=false) // ); break; + case 'select_add_elements': + if (empty($data['selected']) === false) { + foreach ($data['selected'] as $key => $value) { + unset($data['fields'][$key]); + } + } + + $output .= '
'; + $output .= html_print_select( + ((isset($data['selected']) === true) ? $data['selected'] : ''), + $data['name'], + '', + ((isset($data['script']) === true) ? $data['script'] : ''), + ((isset($data['nothing']) === true) ? $data['nothing'] : ''), + ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['multiple']) === true) ? $data['multiple'] : false), + ((isset($data['sort']) === true) ? $data['sort'] : true), + ((isset($data['class']) === true) ? $data['class'] : ''), + ((isset($data['disabled']) === true) ? $data['disabled'] : false), + ((isset($data['style']) === true) ? $data['style'] : false), + ((isset($data['option_style']) === true) ? $data['option_style'] : false), + ((isset($data['size']) === true) ? $data['size'] : false), + ((isset($data['modal']) === true) ? $data['modal'] : false), + ((isset($data['message']) === true) ? $data['message'] : ''), + ((isset($data['select_all']) === true) ? $data['select_all'] : false), + ((isset($data['simple_multiple_options']) === true) ? $data['simple_multiple_options'] : false), + ((isset($data['required']) === true) ? $data['required'] : false), + ((isset($data['truncate_size']) === true) ? $data['truncate_size'] : false), + ((isset($data['select2_enable']) === true) ? $data['select2_enable'] : true), + ((isset($data['select2_multiple_enable']) === true) ? $data['select2_multiple_enable'] : false), + ((isset($data['select2_multiple_enable_all']) === true) ? $data['select2_multiple_enable_all'] : false), + ((isset($data['form']) === true) ? $data['form'] : ''), + ((isset($data['order']) === true) ? $data['order'] : false) + ); + $output .= '
'; + $output .= html_print_button( + __('Add'), + 'add_column', + false, + 'addElement("'.$data['name'].'", "modal_'.$data['name'].'")', + [ + 'style' => 'max-width: fit-content; min-width: auto; height: 30px; border: 0px;', + 'class' => 'sub', + 'icon' => 'plus', + ], + true, + false, + false, + '' + ); + $output .= html_print_button( + __('Remove'), + 'remove_column', + false, + 'removeElement("'.$data['name'].'", "modal_'.$data['name'].'")', + [ + 'style' => 'max-width: fit-content; min-width: auto; height: 30px; border: 0px;', + 'class' => 'sub', + 'icon' => 'delete', + ], + true, + false, + false, + '' + ); + $output .= ''; + $output .= '
'; + $output .= '
'; + ?> + 0){ + $("#columns_events_widget option").prop("selected", true); + } + }) + });'; } @@ -471,6 +482,34 @@ class EventsListWidget extends Widget 'nothing_value' => 0, ], ]; + if (empty($values['columns_events_widget'][0]) === true) { + $columns_array = explode(',', $config['event_fields']); + } else { + $columns_array = explode(',', $values['columns_events_widget'][0]); + } + + $selected = []; + foreach ($columns_array as $key => $value) { + if (empty($value) === false) { + $selected[$value] = $this->getColumnsAvailables()[$value]; + } + } + + $inputs['inputs']['row2'][] = [ + 'label' => \__('Columns'), + 'arguments' => [ + 'type' => 'select_add_elements', + 'fields' => $this->getColumnsAvailables(), + 'class' => 'event-widget-input force-all-values', + 'name' => 'columns_events_widget[]', + 'selected' => (count($selected) > 0) ? $selected : '', + 'return' => true, + 'multiple' => true, + 'order' => true, + 'nothing' => false, + 'sort' => false, + ], + ]; return $inputs; } @@ -495,6 +534,7 @@ class EventsListWidget extends Widget $values['tagsId'] = \get_parameter_switch('tagsId', []); $values['groupRecursion'] = \get_parameter_switch('groupRecursion', 0); $values['customFilter'] = \get_parameter('customFilter', -1); + $values['columns_events_widget'] = \get_parameter('columns_events_widget', []); return $values; } @@ -620,7 +660,12 @@ class EventsListWidget extends Widget 'class' => 'table_action_buttons w120px', ], ]; - $fields = explode(',', $config['event_fields']); + + if (empty($this->values['columns_events_widget'][0]) === true) { + $fields = explode(',', $config['event_fields']); + } else { + $fields = explode(',', $this->values['columns_events_widget'][0]); + } // Always check something is shown. if (empty($fields) === true) { @@ -743,4 +788,43 @@ class EventsListWidget extends Widget } + /** + * Return array with all columns availables for select. + * + * @return array All columns availables. + */ + public function getColumnsAvailables() + { + return [ + 'id_evento' => __('Event Id'), + 'evento' => __('Event Name'), + 'id_agente' => __('Agent ID'), + 'agent_name' => __('Agent Name'), + 'direccion' => __('Agent IP'), + 'id_usuario' => __('User'), + 'id_grupo' => __('Group'), + 'estado' => __('Status'), + 'timestamp' => __('Timestamp'), + 'event_type' => __('Event Type'), + 'id_agentmodule' => __('Module Name'), + 'id_alert_am' => __('Alert'), + 'criticity' => __('Severity'), + 'user_comment' => __('Comment'), + 'tags' => __('Tags'), + 'source' => __('Source'), + 'id_extra' => __('Extra Id'), + 'owner_user' => __('Owner'), + 'ack_utimestamp' => __('ACK Timestamp'), + 'instructions' => __('Instructions'), + 'server_name' => __('Server Name'), + 'data' => __('Data'), + 'module_status' => __('Module Status'), + 'mini_severity' => __('Severity mini'), + 'module_custom_id' => __('Module custom ID'), + 'custom_data' => __('Custom data'), + ]; + + } + + } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index adf1325b07..f1bb3365aa 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -11850,6 +11850,32 @@ span.help_icon_15px > img { height: 65px !important; margin-top: 10px; } +.order-arrows option { + position: relative; +} +.order-arrows option::before { + opacity: 0.5; + content: " "; + right: 19px; + top: 5px; + background-image: url(../../images/darrowup.png); + position: absolute; + width: 8px; + height: 9px; + background-position: center; +} + +.order-arrows option::after { + opacity: 0.5; + content: " "; + right: 19px; + bottom: 6px; + background-image: url(../../images/darrowdown.png); + position: absolute; + width: 8px; + height: 9px; + background-position: center; +} /* ==== Spinner ==== */ .spinner-fixed {