From 4b4e2b02660019eccad9e6d7288a442d5998a6cd Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Mon, 5 Jun 2023 16:05:38 +0200 Subject: [PATCH 1/4] #10875 add mw250px to comment column --- pandora_console/operation/events/events.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index d1d653777a..8b734743f8 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -2393,6 +2393,14 @@ try { ]; } + $user_comment = array_search('user_comment', $fields); + if ($user_comment !== false) { + $fields[$user_comment] = [ + 'text' => 'user_comment', + 'class' => 'mw250px', + ]; + } + // Always add options column. $fields = array_merge( $fields, From b4ae714af325b2bcfcb977e60dde359f7d57db91 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 28 Jul 2023 10:39:46 +0200 Subject: [PATCH 2/4] #10875 Truncate long string --- pandora_console/include/functions_ui.php | 46 +++++-- pandora_console/operation/events/events.php | 141 +++++++++++++++++++- 2 files changed, 170 insertions(+), 17 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index b2e3928b69..07290347f9 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -88,8 +88,16 @@ function ui_bbcode_to_html($text, $allowed_tags=['[url]']) * * @return string Truncated text. */ -function ui_print_truncate_text($text, $numChars=GENERIC_SIZE_TEXT, $showTextInAToopTip=true, $return=true, $showTextInTitle=true, $suffix='…', $style=false) -{ +function ui_print_truncate_text( + $text, + $numChars=GENERIC_SIZE_TEXT, + $showTextInAToopTip=true, + $return=true, + $showTextInTitle=true, + $suffix='…', + $style=false, + $forced_title=false +) { global $config; if (is_string($numChars)) { @@ -190,6 +198,10 @@ function ui_print_truncate_text($text, $numChars=GENERIC_SIZE_TEXT, $showTextInA } } + if ($forced_title === true) { + $truncateText = 'evento)); - if (strlen($tmp->evento) >= 255) { + if (strlen($tmp->evento) >= 40) { $tmp->evento = ui_print_truncate_text( $tmp->evento, - 255, - $tmp->evento, + 40, + false, + true, + false, + '…', + true, true, - false ); } if (empty($tmp->module_name) === false) { $tmp->module_name = io_safe_output($tmp->module_name); + if (strlen($tmp->module_name) >= 20) { + $tmp->evento = ui_print_truncate_text( + $tmp->module_name, + 20, + false, + true, + false, + '…', + true, + true, + ); + } } if (empty($tmp->comments) === false) { - $tmp->comments = ui_print_comments($tmp->comments); + $tmp->comments = ui_print_comments($tmp->comments, 20); } // Show last event. @@ -535,6 +563,32 @@ if (is_ajax() === true) { } $tmp->agent_name = io_safe_output($tmp->agent_name); + if (strlen($tmp->agent_name) >= 10) { + $tmp->agent_name = ui_print_truncate_text( + $tmp->agent_name, + 10, + false, + true, + false, + '…', + true, + true, + ); + } + + $tmp->id_extra = io_safe_output($tmp->id_extra); + if (strlen($tmp->id_extra) >= 10) { + $tmp->id_extra = ui_print_truncate_text( + $tmp->id_extra, + 10, + false, + true, + false, + '…', + true, + true, + ); + } $tmp->ack_utimestamp_raw = $tmp->ack_utimestamp; @@ -583,6 +637,18 @@ if (is_ajax() === true) { } $tmp->instructions = events_get_instructions($item); + if (strlen($tmp->instructions) >= 20) { + $tmp->instructions = ui_print_truncate_text( + $tmp->instructions, + 20, + false, + true, + false, + '…', + true, + true, + ); + } $tmp->b64 = base64_encode(json_encode($tmp)); @@ -844,6 +910,19 @@ if (is_ajax() === true) { $tmp->owner_user = get_user_fullname($tmp->owner_user).' ('.$tmp->owner_user.')'; } + if (strlen($tmp->owner_user) >= 10) { + $tmp->owner_user = ui_print_truncate_text( + $tmp->owner_user, + 10, + false, + true, + false, + '…', + true, + true, + ); + } + // Group name. if (empty($tmp->id_grupo) === true) { $tmp->id_grupo = __('All'); @@ -851,8 +930,33 @@ if (is_ajax() === true) { $tmp->id_grupo = $tmp->group_name; } + if (strlen($tmp->id_grupo) >= 10) { + $tmp->id_grupo = ui_print_truncate_text( + $tmp->id_grupo, + 10, + false, + true, + false, + '…', + true, + true, + ); + } + // Module name. $tmp->id_agentmodule = $tmp->module_name; + if (strlen($tmp->id_agentmodule) >= 10) { + $tmp->id_agentmodule = ui_print_truncate_text( + $tmp->id_agentmodule, + 10, + false, + true, + false, + '…', + true, + true, + ); + } // Options. // Show more. @@ -1083,6 +1187,18 @@ if (is_ajax() === true) { } $tmp->custom_data = $custom_data_str; + if (strlen($tmp->custom_data) >= 20) { + $tmp->custom_data = ui_print_truncate_text( + $tmp->custom_data, + 20, + false, + true, + false, + '…', + true, + true, + ); + } } $carry[] = $tmp; @@ -2417,7 +2533,7 @@ try { if (in_array('instructions', $fields) > 0) { $fields[array_search('instructions', $fields)] = [ 'text' => 'instructions', - 'class' => 'column-instructions', + 'class' => 'column-instructions mw60px', ]; } @@ -2433,10 +2549,20 @@ try { if ($user_comment !== false) { $fields[$user_comment] = [ 'text' => 'user_comment', - 'class' => 'mw250px', + 'class' => 'mw100px', ]; } + + foreach ($fields as $key => $field) { + if (is_array($field) === false) { + $fields[$key] = [ + 'text' => $field, + 'class' => 'mw100px', + ]; + } + } + // Always add options column. $fields = array_merge( $fields, @@ -2462,6 +2588,7 @@ try { } } + // mw60px // Open current filter quick reference. $active_filters_div = '
'; From 014d32181ced86349f5e89e2a4ddb4433aecfefd Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 28 Jul 2023 12:12:14 +0200 Subject: [PATCH 3/4] #10875 Fix title --- pandora_console/include/functions_ui.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 07290347f9..430b09cc3c 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -199,7 +199,7 @@ function ui_print_truncate_text( } if ($forced_title === true) { - $truncateText = 'evento)); + $event_text = $tmp->evento; if (strlen($tmp->evento) >= 40) { $tmp->evento = ui_print_truncate_text( $tmp->evento, @@ -523,7 +524,7 @@ if (is_ajax() === true) { if (empty($tmp->module_name) === false) { $tmp->module_name = io_safe_output($tmp->module_name); if (strlen($tmp->module_name) >= 20) { - $tmp->evento = ui_print_truncate_text( + $tmp->module_name = ui_print_truncate_text( $tmp->module_name, 20, false, @@ -611,7 +612,7 @@ if (is_ajax() === true) { $total_sec = strtotime($tmp->timestamp); $total_sec += $dif; - $last_contact = date($config['date_format'], $total_sec); + $last_contact = date($confb64ig['date_format'], $total_sec); $last_contact_value = ui_print_timestamp($last_contact, true); } else { $title = date($config['date_format'], strtotime($tmp->timestamp)); @@ -650,8 +651,10 @@ if (is_ajax() === true) { ); } + $aux_event = $tmp->evento; + $tmp->evento = $event_text; $tmp->b64 = base64_encode(json_encode($tmp)); - + $tmp->evento = $aux_event; // Show comments events. if (empty($tmp->comments) === false) { $tmp->user_comment = $tmp->comments;