diff --git a/pandora_console/godmode/massive/massive_delete_modules.php b/pandora_console/godmode/massive/massive_delete_modules.php index 9c440163a3..b6a098f07d 100755 --- a/pandora_console/godmode/massive/massive_delete_modules.php +++ b/pandora_console/godmode/massive/massive_delete_modules.php @@ -683,6 +683,7 @@ $(document).ready (function () { var params = { "page" : "operation/agentes/ver_agente", "get_agent_modules_json" : 1, + "truncate_module_names": 1, "get_distinct_name" : 1, "indexed" : 0, "privilege" : "AW", @@ -712,7 +713,7 @@ $(document).ready (function () { function (data, status) { jQuery.each (data, function (id, value) { option = $("") - .attr("value", value["nombre"]) + .attr({value: value["nombre"], title: value["nombre"]}) .html(value["safe_name"]); $("#module_name").append (option); }); diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index 9d0544b649..1045e8efa6 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -1369,6 +1369,7 @@ $(document).ready (function () { var params = { "page" : "operation/agentes/ver_agente", "get_agent_modules_json" : 1, + "truncate_module_names": 1, "get_distinct_name" : 1, "indexed" : 0, "safe_name" : 1 @@ -1396,7 +1397,7 @@ $(document).ready (function () { params, function (data, status) { jQuery.each (data, function (id, value) { - option = $("").attr("value", value["nombre"]).html(value["safe_name"]); + option = $("").attr({value: value["nombre"], title: value["nombre"]}).html(value["safe_name"]); $("#module_name").append (option); }); hideSpinner(); diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 5b96a8fcd6..e26cd5e2a8 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -88,6 +88,23 @@ function js_html_entity_decode(str) { return str2; } +function truncate_string(str, str_length, separator) { + if (str.length <= str_length) { + return str; + } + + separator = separator || "..."; + + var separator_length = separator.length, + chars_to_show = str_length - separator_length, + front_chars = Math.ceil(chars_to_show / 2), + tail_chars = Math.floor(chars_to_show / 2); + + return ( + str.substr(0, front_chars) + separator + str.substr(str.length - tail_chars) + ); +} + /** * Function to search an element in an array. * @@ -554,6 +571,7 @@ function module_changed_by_multiple_modules(event, id_module, selected) { { page: "operation/agentes/ver_agente", get_agents_json_for_multiple_modules: 1, + truncate_agent_names: 1, status_module: status_module, "module_name[]": idModules, selection_mode: selection_mode, @@ -619,8 +637,8 @@ function module_changed_by_multiple_modules(event, id_module, selected) { s = js_html_entity_decode(val); $("#agents").append( $("") - .html(s) - .attr("value", i) + .html(truncate_string(s, 30, "...")) + .attr({ value: i, title: s }) ); $("#agents").fadeIn("normal"); }); diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 617f62b97b..50ba2a7f9c 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -353,6 +353,8 @@ if (is_ajax()) { $selection_mode = get_parameter('selection_mode', 'common') == 'all'; $status_modulo = (int) get_parameter('status_module', -1); $tags_selected = (array) get_parameter('tags', []); + $truncate_agent_names = (bool) get_parameter('truncate_agent_names'); + $names = select_agents_for_module_group( $nameModules, $selection_mode, @@ -790,6 +792,8 @@ if (is_ajax()) { $safe_name = (bool) get_parameter('safe_name', false); + $truncate_module_names = (bool) get_parameter('truncate_module_names'); + // Filter. $filter = []; if ($disabled !== -1) { @@ -945,6 +949,16 @@ if (is_ajax()) { $agent_modules = $new_elements; } + if ($truncate_module_names === true) { + $agent_modules = array_map( + function ($item) { + $item['safe_name'] = ui_print_truncate_text($item['safe_name'], 'module_medium'); + return $item; + }, + $agent_modules + ); + } + echo json_encode($agent_modules); return;