Merge branch 'ent-10875-15383-limitar-ancho-y-o-largo-de-la-linea-de-los-eventos' into 'develop'

Ent 10875 15383 limitar ancho y o largo de la linea de los eventos

See merge request artica/pandorafms!6034
This commit is contained in:
Rafael Ameijeiras 2023-07-31 06:40:38 +00:00
commit 6db5b41633
2 changed files with 178 additions and 22 deletions

View File

@ -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 = '<span class="forced_title" style="'.$style.'" data-title="'.$text.'" data-use_title_for_force_title="1>'.$truncateText.'</span>';
}
if ($return == true) {
return $truncateText;
} else {
@ -7075,7 +7087,7 @@ function ui_print_breadcrums($tab_name)
*
* @return string HTML string with the last comment of the events.
*/
function ui_print_comments($comments)
function ui_print_comments($comments, $truncate_limit=255)
{
global $config;
@ -7117,26 +7129,40 @@ function ui_print_comments($comments)
$last_comment['comment'] = $last_comment['action'];
}
$tip_comment = '';
$short_comment = substr($last_comment['comment'], 0, 20);
if ($config['prominent_time'] == 'timestamp') {
$comentario = '<i>'.date($config['date_format'], $last_comment['utimestamp']).'&nbsp;('.$last_comment['id_user'].'):&nbsp;'.$last_comment['comment'].'';
if (strlen($comentario) > '200px') {
$tip_comment = date($config['date_format'], $last_comment['utimestamp']).'('.$last_comment['id_user'].'): '.$last_comment['comment'];
if (strlen($comentario) > '200px' && $truncate_limit >= 255) {
$comentario = '<i>'.date($config['date_format'], $last_comment['utimestamp']).'&nbsp;('.$last_comment['id_user'].'):&nbsp;'.$short_comment.'...';
}
} else {
$rest_time = (time() - $last_comment['utimestamp']);
$time_last = (($rest_time / 60) / 60);
$comentario = '<i>'.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).'&nbsp; Hours &nbsp;('.$last_comment['id_user'].'):&nbsp;'.$last_comment['comment'].'';
if (strlen($comentario) > '200px') {
$comentario = '<i>'.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).'&nbsp; Hours &nbsp;('.$last_comment['id_user'].'):&nbsp;'.$last_comment['comment'].'</i>';
$tip_comment = number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).' Hours ('.$last_comment['id_user'].'): '.$last_comment['comment'];
if (strlen($comentario) > '200px' && $truncate_limit >= 255) {
$comentario = '<i>'.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).'&nbsp; Hours &nbsp;('.$last_comment['id_user'].'):&nbsp;'.$short_comment.'...';
}
}
return io_safe_output($comentario);
$comentario = io_safe_output($comentario);
if (strlen($comentario) >= $truncate_limit) {
$comentario = ui_print_truncate_text(
$comentario,
$truncate_limit,
false,
true,
false,
'&hellip;',
true,
true,
);
}
return $comentario;
}

View File

@ -493,23 +493,52 @@ if (is_ajax() === true) {
}
}
if (strlen($tmp->server_name) >= 10) {
$tmp->server_name = ui_print_truncate_text(
$tmp->server_name,
10,
false,
true,
false,
'&hellip;',
true,
true,
);
}
$tmp->evento = str_replace('"', '', io_safe_output($tmp->evento));
if (strlen($tmp->evento) >= 255) {
$event_text = $tmp->evento;
if (strlen($tmp->evento) >= 40) {
$tmp->evento = ui_print_truncate_text(
$tmp->evento,
255,
$tmp->evento,
40,
false,
true,
false,
'&hellip;',
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->module_name = ui_print_truncate_text(
$tmp->module_name,
20,
false,
true,
false,
'&hellip;',
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 +564,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,
'&hellip;',
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,
'&hellip;',
true,
true,
);
}
$tmp->ack_utimestamp_raw = $tmp->ack_utimestamp;
@ -557,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));
@ -583,9 +638,23 @@ 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,
'&hellip;',
true,
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;
@ -844,6 +913,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,
'&hellip;',
true,
true,
);
}
// Group name.
if (empty($tmp->id_grupo) === true) {
$tmp->id_grupo = __('All');
@ -851,8 +933,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,
'&hellip;',
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,
'&hellip;',
true,
true,
);
}
// Options.
// Show more.
@ -1083,6 +1190,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,
'&hellip;',
true,
true,
);
}
}
$carry[] = $tmp;
@ -2417,7 +2536,7 @@ try {
if (in_array('instructions', $fields) > 0) {
$fields[array_search('instructions', $fields)] = [
'text' => 'instructions',
'class' => 'column-instructions',
'class' => 'column-instructions mw60px',
];
}
@ -2429,14 +2548,24 @@ try {
];
}
$comment_id = array_search('user_comment', $fields);
if ($comment_id !== false) {
$fields[$comment_id] = [
$user_comment = array_search('user_comment', $fields);
if ($user_comment !== false) {
$fields[$user_comment] = [
'text' => 'user_comment',
'class' => 'nowrap_max180px',
'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 +2591,7 @@ try {
}
}
// mw60px
// Open current filter quick reference.
$active_filters_div = '<div class="filter_summary">';