From 4ce316397ce786adb490be8e5f7cfc06e5bd73e1 Mon Sep 17 00:00:00 2001 From: juanmanuelr Date: Mon, 14 Nov 2011 22:16:47 +0000 Subject: [PATCH] 2011-11-14 Juan Manuel Ramon * include/javascript/pandora.js: Added ajax callback for metaconsole event search. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5133 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 ++ pandora_console/include/javascript/pandora.js | 46 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index bfed53116d..dd8c8c1c5e 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2011-11-14 Juan Manuel Ramon + + * include/javascript/pandora.js: Added ajax callback for metaconsole + event search. + 2011-11-14 Juan Manuel Ramon * include/functions_menu.php diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 3db0cd2ddc..7d4c2719a1 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -457,3 +457,49 @@ function agent_module_autocomplete (id_agent_name, id_agent_id, id_agent_module_ } ); } + +/** + * Autocomplete Agent box functions. + * + * This function has all the necesary javascript to use the box with to autocomplete + * an agent name, and store it's id on a hidden field and fill a selector with the + * modules from that agent. + * + * @param id_agent_name id of the agent name box + * @param id_agent_id id of the hidden field to store the agent id + * @param id_agent_module_selector id of the selector for the modules of the agent. + */ +function agent_autocomplete (id_agent_name, id_server_name, id_agent_id ) { + $(id_agent_name).autocomplete( + "ajax.php", + { + minChars: 2, + scroll:true, + extraParams: { + page: "include/ajax/agent", + search_agents: 1 + }, + formatItem: function (data, i, total) { + if (total == 0) + $(id_agent_name).css ('background-color', '#cc0000'); + else + $(id_agent_name).css ('background-color', ''); + if (data == "") + return false; + return data[0]+'
: '+data[2]+''; + }, + delay: 200 + } + ); + + // Callback from the autocomplete + $(id_agent_name).result ( + function (e, data, formatted) { + //$(id_agent_module_selector).attr('disabled', false); + agent_id = data[1]; + server_name = data[2]; + $(id_server_name).val(server_name); + $(id_agent_id).val(agent_id); + } + ); +}