diff --git a/pandora_console/godmode/reporting/graph_builder.graph_editor.php b/pandora_console/godmode/reporting/graph_builder.graph_editor.php index 54ced4e030..dfe8c1d117 100644 --- a/pandora_console/godmode/reporting/graph_builder.graph_editor.php +++ b/pandora_console/godmode/reporting/graph_builder.graph_editor.php @@ -327,59 +327,17 @@ echo '
'; // Configuration form. echo ''; -echo "
"; +echo ""; echo ""; echo ''; -echo "'; -echo ''; -echo "'; -echo ''; -echo "'; -echo ''; -echo "'; -echo ''; -echo ''; -echo ''; -echo ''; echo ''; echo "
".__('Filter group').'
".html_print_select_groups( - $config['id_user'], - ($report_w == true) ? 'RW' : (($report_m == true) ? 'RM' : 'RW'), - true, - 'group', - '', - 'filterByGroup($(\'#group\').val());', - '', - 0, - true -).'
".__('Agents').ui_print_help_tip( - __('If you select several agents, only the common modules will be displayed'), - true -).'".__('Modules').'
'.html_print_select( - agents_get_group_agents(), - 'id_agents[]', - 0, - false, - '', - '', - true, - true, - true, - 'w100p', - false, - '' -).''.html_print_select( - [], - 'module[]', - 0, - false, - '', - 0, - true, - true, - true, - 'w100p', - false, - '' +echo ''.html_print_input( + [ + 'type' => 'select_multiple_modules_filtered', + 'uniqId' => 'modules', + 'class' => 'flex flex-row', + 'searchBar' => true, + ] ).'
"; @@ -403,52 +361,34 @@ ui_require_jquery_file('autocomplete'); $(document).ready (function () { $(document).data('text_for_module', $("#none_text").html()); - $("#id_agents").change(agent_changed_by_multiple_agents); - $("#submit-add").click(function() { - $('#module').map(function(){ - if ($(this).val() != "0" ) - $(this).prop('selected', true); - }); - - if($('#module')[0].childElementCount == 1 && ($('#module')[0].value == "" || $('#module')[0].value == "0")) { + if($('#filtered-module-modules-modules')[0].value == "" || $('#filtered-module-modules-modules')[0].value == "0") { alert(""); return false; } + + var modules_selected = $( + "#filtered-module-modules-modules" + ).val(); + var agents_selected = $( + "#filtered-module-agents-modules" + ).val(); + + $("#agentmodules").submit( function(eventObj) { + $("").attr("type", "hidden") + .attr("value", agents_selected) + .attr("name", "id_agents") + .appendTo("#agentmodules"); + $("").attr("type", "hidden") + .attr("value", modules_selected) + .attr("name", "id_modules") + .appendTo("#agentmodules"); + return true; + }); }); }); -function filterByGroup(idGroup) { - $('#id_agents').empty (); - $('#module').empty(); - $("#module").append ($("").attr ("value", 0).html ('')); - - jQuery.post ("ajax.php", - {"page" : "godmode/groups/group_list", - "get_group_agents" : 1, - "id_group" : idGroup, - // Add a key prefix to avoid auto sorting in js object conversion - "keys_prefix" : "_" - }, - function (data, status) { - i = 0 - jQuery.each (data, function (id, value) { - // Remove keys_prefix from the index - id = id.substring(1); - - i++; - $("#id_agents").append ($("").attr ("value", id).html (value)); - }); - - if (i == 0) { - $("#id_agents").append ($("").attr ("value", 0).html ('')); - } - }, - "json" - ); -} - function added_ids_sorted_items_to_hidden_input() { var ids = ''; var first = true; diff --git a/pandora_console/godmode/reporting/graph_builder.php b/pandora_console/godmode/reporting/graph_builder.php index 92d117df1b..bdbee9a14b 100644 --- a/pandora_console/godmode/reporting/graph_builder.php +++ b/pandora_console/godmode/reporting/graph_builder.php @@ -222,17 +222,14 @@ function add_quotes($item) if ($add_module === true) { $id_graph = get_parameter('id'); - $id_modules = get_parameter('module'); - $id_agents = get_parameter('id_agents'); + $id_modules = explode(',', get_parameter('id_modules')); + $id_agents = explode(',', get_parameter('id_agents')); $weight = get_parameter('weight'); // Id modules has double entities conversion. // Safe output remove all entities. io_safe_output_array($id_modules, ''); - // We need to put the entities again - // to browse in db. - io_safe_input_array($id_modules); $id_agent_modules = db_get_all_rows_sql( 'SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN ('.implode(',', $id_agents).") AND nombre IN ('".implode("','", $id_modules)."')" diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index c0b4ea2899..da12915fc8 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1480,11 +1480,43 @@ function html_print_select_multiple_modules_filtered(array $data):string 'return' => true, 'nothing' => __('All'), 'nothing_value' => 0, - 'script' => 'fmModuleChange(\''.$uniqId.'\', '.is_metaconsole().')', + 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', ] ); $output .= ''; + if (empty($data['searchBar']) === false && $data['searchBar'] === true) { + $output .= '
'; + + $output .= '
'; + $output .= html_print_input( + [ + 'type' => 'text', + 'name' => 'agent-searchBar-'.$uniqId, + 'onKeyUp' => 'searchAgent(\''.$uniqId.'\')', + 'placeholder' => __('Type to search agents'), + 'return' => true, + ] + ); + + $output .= '
'; + + $output .= '
'; + $output .= html_print_input( + [ + 'type' => 'text', + 'name' => 'module-searchBar-'.$uniqId, + 'onKeyUp' => 'searchModule(\''.$uniqId.'\')', + 'return' => true, + 'placeholder' => __('Type to search modules'), + ] + ); + + $output .= '
'; + + $output .= '
'; + } + $output .= '
'; // Agent. $agents = agents_get_group_agents( @@ -1533,7 +1565,7 @@ function html_print_select_multiple_modules_filtered(array $data):string 'return' => true, 'multiple' => true, 'style' => 'min-width: 200px;max-width:200px;', - 'script' => 'fmModuleChange(\''.$uniqId.'\', '.is_metaconsole().')', + 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', ] ); @@ -1550,7 +1582,7 @@ function html_print_select_multiple_modules_filtered(array $data):string 'name' => 'filtered-module-show-common-modules-'.$uniqId, 'selected' => $data['mShowCommonModules'], 'return' => true, - 'script' => 'fmModuleChange(\''.$uniqId.'\', '.is_metaconsole().')', + 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', ] ); diff --git a/pandora_console/include/javascript/multiselect_filtered.js b/pandora_console/include/javascript/multiselect_filtered.js index 8de92ffcf3..88a0ad8dde 100644 --- a/pandora_console/include/javascript/multiselect_filtered.js +++ b/pandora_console/include/javascript/multiselect_filtered.js @@ -231,7 +231,7 @@ function fmModuleChange(uniqId, isMeta) { if (data) { jQuery.each(data, function(id, value) { var option = $(""); - if (isMeta === true) { + if (isMeta === 1) { option .attr( "value", @@ -251,3 +251,50 @@ function fmModuleChange(uniqId, isMeta) { "json" ); } + +// Function to search in agents select. +function searchAgent(uniqId) { + // Declare variables + var agents = $("#filtered-module-agents-" + uniqId + " option"); + + // Loop through all list items, and hide those who don't match the search query + agents.each(function() { + var filter = $("#text-agent-searchBar-modules") + .val() + .toUpperCase(); + + if ( + $(this) + .text() + .toUpperCase() + .indexOf(filter) > -1 + ) { + $(this).show(); + } else { + $(this).hide(); + } + }); +} + +// Function to search in modules select. +function searchModule(uniqId) { + // Declare variables + var modules = $("#filtered-module-modules-" + uniqId + " option"); + + // Loop through all list items, and hide those who don't match the search query + modules.each(function() { + var filter = $("#text-module-searchBar-modules") + .val() + .toUpperCase(); + if ( + $(this) + .text() + .toUpperCase() + .indexOf(filter) > -1 + ) { + $(this).show(); + } else { + $(this).hide(); + } + }); +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index c457176f49..ba89e2d915 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -8469,3 +8469,40 @@ div#err_msg_centralised { display: flex; flex-direction: row; } + +#select_multiple_modules_filtered > div { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + margin: 5px; + flex-wrap: wrap; + flex: 1 1 320px; +} + +#select_multiple_modules_filtered > div > div { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + flex-wrap: wrap; + width: 250px; +} + +#select_multiple_modules_filtered > div > div > * { + flex: auto; +} + +#select_multiple_modules_filtered > div > div > select { + min-width: 250px !important; +} + +#select_multiple_modules_filtered > div > div > .select2 { + min-width: 250px !important; +} + +#select_multiple_modules_filtered > div > div > input { + max-width: 250px; + width: 95%; + height: 95%; +} diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 8a33477d57..3e7a143b74 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -556,13 +556,13 @@ $table_ichanges = '