mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
Merge branch 'ent-9162-10821-modificar-columnas-widget-eventos' into 'develop'
Ent 9162 10821 modificar columnas widget eventos See merge request artica/pandorafms!5843
This commit is contained in:
commit
add65eca5d
@ -1833,7 +1833,6 @@ if (is_metaconsole() === false) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#button-uptbutton").click (function () {
|
$("#button-uptbutton").click (function () {
|
||||||
console.log('aaaaaaaaaaaaa');
|
|
||||||
if($("#autorefresh_list option").length > 0) {
|
if($("#autorefresh_list option").length > 0) {
|
||||||
$('#autorefresh_list option').prop('selected', true);
|
$('#autorefresh_list option').prop('selected', true);
|
||||||
}
|
}
|
||||||
|
@ -768,7 +768,8 @@ function html_print_select(
|
|||||||
$select2_enable=true,
|
$select2_enable=true,
|
||||||
$select2_multiple_enable=false,
|
$select2_multiple_enable=false,
|
||||||
$select2_multiple_enable_all=false,
|
$select2_multiple_enable_all=false,
|
||||||
$form=''
|
$form='',
|
||||||
|
$order=false,
|
||||||
) {
|
) {
|
||||||
$output = "\n";
|
$output = "\n";
|
||||||
|
|
||||||
@ -805,6 +806,10 @@ function html_print_select(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($multiple === true && $order === true) {
|
||||||
|
$class .= ' order-arrows';
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($class)) {
|
if (!empty($class)) {
|
||||||
$attributes .= ' class="'.$class.'"';
|
$attributes .= ' class="'.$class.'"';
|
||||||
}
|
}
|
||||||
@ -1129,6 +1134,49 @@ function html_print_select(
|
|||||||
$output .= '</script>';
|
$output .= '</script>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($multiple === true && $order === true) {
|
||||||
|
$output .= '<script>';
|
||||||
|
$output .= '
|
||||||
|
if(typeof draggingOption === "undefined") {
|
||||||
|
let draggingOption = null;
|
||||||
|
} else {
|
||||||
|
draggingOption = null;
|
||||||
|
}
|
||||||
|
document.getElementById("'.$id.'").addEventListener("mousedown", e => {
|
||||||
|
if (e.target.tagName === "OPTION") {
|
||||||
|
draggingOption = e.target;
|
||||||
|
document.getElementById("'.$id.'").classList.add("dragging");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById("'.$id.'").addEventListener("mousemove", e => {
|
||||||
|
if (typeof draggingOption !== "undefined") {
|
||||||
|
if(draggingOption) {
|
||||||
|
e.preventDefault();
|
||||||
|
const targetOption = document.elementFromPoint(e.clientX, e.clientY);
|
||||||
|
if (targetOption && targetOption.tagName === "OPTION") {
|
||||||
|
const boundingRect = targetOption.getBoundingClientRect();
|
||||||
|
if (e.clientY < boundingRect.top + boundingRect.height / 2) {
|
||||||
|
document.getElementById("'.$id.'").insertBefore(draggingOption, targetOption);
|
||||||
|
} else {
|
||||||
|
document.getElementById("'.$id.'").insertBefore(draggingOption, targetOption.nextSibling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById("'.$id.'").addEventListener("mouseup", e => {
|
||||||
|
if (typeof draggingOption !== "undefined") {
|
||||||
|
if(draggingOption) {
|
||||||
|
document.getElementById("'.$id.'").classList.remove("dragging");
|
||||||
|
draggingOption = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});';
|
||||||
|
$output .= '</script>';
|
||||||
|
}
|
||||||
|
|
||||||
if ($return) {
|
if ($return) {
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
@ -5528,7 +5576,9 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||||||
((isset($data['truncate_size']) === true) ? $data['truncate_size'] : false),
|
((isset($data['truncate_size']) === true) ? $data['truncate_size'] : false),
|
||||||
((isset($data['select2_enable']) === true) ? $data['select2_enable'] : true),
|
((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']) === 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;
|
break;
|
||||||
|
|
||||||
@ -6042,6 +6092,94 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||||||
// );
|
// );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'select_add_elements':
|
||||||
|
if (empty($data['selected']) === false) {
|
||||||
|
foreach ($data['selected'] as $key => $value) {
|
||||||
|
unset($data['fields'][$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= '<div>';
|
||||||
|
$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 .= '<div class="flex justify-content-between mrgn_top_5px">';
|
||||||
|
$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 .= '<div id="modal_'.$data['name'].'" class="modal-select-add-elements" style="display: none;">';
|
||||||
|
$output .= html_print_select(
|
||||||
|
$data['fields'],
|
||||||
|
$data['name'].'_select_modal',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
0,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
'',
|
||||||
|
false,
|
||||||
|
'width: 80%'
|
||||||
|
);
|
||||||
|
$output .= '</div>';
|
||||||
|
$output .= '</div>';
|
||||||
|
$output .= '</div>';
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Ignore.
|
// Ignore.
|
||||||
break;
|
break;
|
||||||
|
@ -1180,3 +1180,52 @@ function getUrlAjax() {
|
|||||||
return $("#hidden-ajax_file_sound_console").val();
|
return $("#hidden-ajax_file_sound_console").val();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addElement(name_select, id_modal) {
|
||||||
|
var modal = document.getElementById(id_modal);
|
||||||
|
var parent = $(modal).parent();
|
||||||
|
$(modal).dialog({
|
||||||
|
title: "Choose columns",
|
||||||
|
width: 330,
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
class:
|
||||||
|
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-next",
|
||||||
|
text: "Confirm",
|
||||||
|
click: function() {
|
||||||
|
$(modal)
|
||||||
|
.find("select option:selected")
|
||||||
|
.each(function(key, option) {
|
||||||
|
$("select[name='" + name_select + "']").append(option);
|
||||||
|
});
|
||||||
|
var clone = $(modal).clone();
|
||||||
|
$(modal)
|
||||||
|
.dialog("destroy")
|
||||||
|
.remove();
|
||||||
|
$(clone).hide();
|
||||||
|
$(parent).append(clone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
close: function() {
|
||||||
|
var clone = $(modal).clone();
|
||||||
|
$(modal)
|
||||||
|
.dialog("destroy")
|
||||||
|
.remove();
|
||||||
|
$(clone).hide();
|
||||||
|
$(parent).append(clone);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeElement(name_select, id_modal) {
|
||||||
|
var modal = document.getElementById(id_modal);
|
||||||
|
$("select[name='" + name_select + "'] option:selected").each(function(
|
||||||
|
key,
|
||||||
|
option
|
||||||
|
) {
|
||||||
|
$(modal)
|
||||||
|
.find("select")
|
||||||
|
.append(option);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -258,6 +258,10 @@ class EventsListWidget extends Widget
|
|||||||
$values['tagsId'] = $decoder['tagsId'];
|
$values['tagsId'] = $decoder['tagsId'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($decoder['columns_events_widget']) === true) {
|
||||||
|
$values['columns_events_widget'] = $decoder['columns_events_widget'];
|
||||||
|
}
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +273,14 @@ class EventsListWidget extends Widget
|
|||||||
*/
|
*/
|
||||||
public function getFormJS(): string
|
public function getFormJS(): string
|
||||||
{
|
{
|
||||||
return '$( document ).ready(function() {event_widget_options();});';
|
return '$( document ).ready(function() {
|
||||||
|
event_widget_options();
|
||||||
|
$(document).on("mousedown", ".ui-dialog-buttonset button", function(){
|
||||||
|
if($("#columns_events_widget").length > 0){
|
||||||
|
$("#columns_events_widget option").prop("selected", true);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -471,6 +482,35 @@ class EventsListWidget extends Widget
|
|||||||
'nothing_value' => 0,
|
'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,
|
||||||
|
'style' => 'width: 93%;',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
return $inputs;
|
return $inputs;
|
||||||
}
|
}
|
||||||
@ -495,6 +535,7 @@ class EventsListWidget extends Widget
|
|||||||
$values['tagsId'] = \get_parameter_switch('tagsId', []);
|
$values['tagsId'] = \get_parameter_switch('tagsId', []);
|
||||||
$values['groupRecursion'] = \get_parameter_switch('groupRecursion', 0);
|
$values['groupRecursion'] = \get_parameter_switch('groupRecursion', 0);
|
||||||
$values['customFilter'] = \get_parameter('customFilter', -1);
|
$values['customFilter'] = \get_parameter('customFilter', -1);
|
||||||
|
$values['columns_events_widget'] = \get_parameter('columns_events_widget', []);
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
}
|
}
|
||||||
@ -620,7 +661,12 @@ class EventsListWidget extends Widget
|
|||||||
'class' => 'table_action_buttons w120px',
|
'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.
|
// Always check something is shown.
|
||||||
if (empty($fields) === true) {
|
if (empty($fields) === true) {
|
||||||
@ -750,4 +796,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'),
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8384,6 +8384,11 @@ div.graph div.legend table {
|
|||||||
justify-content: end;
|
justify-content: end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.justify-content-between {
|
||||||
|
-ms-flex-pack: justify;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
.span_priority {
|
.span_priority {
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 10px;
|
height: 10px;
|
||||||
@ -11911,6 +11916,32 @@ span.help_icon_15px > img {
|
|||||||
height: 65px !important;
|
height: 65px !important;
|
||||||
margin-top: 10px;
|
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 ==== */
|
||||||
.spinner-fixed {
|
.spinner-fixed {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user