From 8dac9aa36d2711e3752d20a6f185efbb3cd219e9 Mon Sep 17 00:00:00 2001 From: esanchezm Date: Tue, 9 Jun 2009 14:29:03 +0000 Subject: [PATCH] 2009-06-09 Esteban Sanchez * godmode/agentes/agent_manager.php: Fixed string filter when searching agents. Avoids a PHP notice when none found * godmode/agentes/configurar_agente.php: Solved a mess with variable names. * godmode/agentes/module_manager_editor_prediction.php: Improved the prediction module selection, adding a filter for agents and module. Fixes #2707907 * include/javascript/jquery.pandora.controls.js: Returns whenever callbackBefore returns false. * include/javascript/pandora_modules.js: Check for module selection when creating a prediction one. * include/styles/pandora.css: Added style to prediction module selection. * godmode/alerts/alert_list.php: callbackBefore on pandora.controls elements must return true now. * godmode/agentes/module_manager_editor_common.php: Added moduletype hidden input to be used in javascript. * godmode/agentes/module_manager_editor.php: Use pandora.controls and added a string for javascript. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1744 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 30 ++++++++++++++++ .../godmode/agentes/agent_manager.php | 4 ++- .../godmode/agentes/configurar_agente.php | 3 +- .../godmode/agentes/module_manager_editor.php | 2 ++ .../agentes/module_manager_editor_common.php | 2 ++ .../module_manager_editor_prediction.php | 34 ++++++++++++++----- pandora_console/godmode/alerts/alert_list.php | 3 +- .../javascript/jquery.pandora.controls.js | 11 +++--- .../include/javascript/pandora_modules.js | 33 ++++++++++++++++-- pandora_console/include/styles/pandora.css | 12 ++++++- 10 files changed, 114 insertions(+), 20 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 8527510517..cf2b64af59 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,33 @@ +2009-06-09 Esteban Sanchez + + * godmode/agentes/agent_manager.php: Fixed string filter when + searching agents. Avoids a PHP notice when none found + + * godmode/agentes/configurar_agente.php: Solved a mess with variable + names. + + * godmode/agentes/module_manager_editor_prediction.php: Improved + the prediction module selection, adding a filter for agents and + module. Fixes #2707907 + + * include/javascript/jquery.pandora.controls.js: Returns + whenever callbackBefore returns false. + + * include/javascript/pandora_modules.js: Check for module selection + when creating a prediction one. + + * include/styles/pandora.css: Added style to prediction module + selection. + + * godmode/alerts/alert_list.php: callbackBefore on pandora.controls + elements must return true now. + + * godmode/agentes/module_manager_editor_common.php: Added moduletype + hidden input to be used in javascript. + + * godmode/agentes/module_manager_editor.php: Use pandora.controls and + added a string for javascript. + 2009-06-09 Esteban Sanchez * godmode/reporting/reporting_builder.php: Fixed a couple of typo diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 6ae45ebe8b..5e6032659c 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -23,10 +23,12 @@ if (is_ajax ()) { $string = (string) get_parameter ('q'); /* q is what autocomplete plugin gives */ $filter = array (); - $filter[] = 'nombre LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%"'; + $filter[] = '(nombre LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%")'; $filter[] = 'id_agente != '.$id_agent; $agents = get_agents ($filter, array ('nombre', 'direccion')); + if ($agents === false) + return; foreach ($agents as $agent) { echo $agent['nombre']."|".$agent['direccion']."\n"; diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 13c4f9a4d6..50fe346201 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -376,7 +376,6 @@ if ($update_module || $create_module) { $min = (int) get_parameter_post ("min"); $max = (int) get_parameter ('max'); $interval = (int) get_parameter ('module_interval', $intervalo); - $id_prediction_module = (int) get_parameter ('id_prediction_module'); $id_plugin = (int) get_parameter ('id_plugin'); $id_export = (int) get_parameter ('id_export'); $disabled = (bool) get_parameter ('disabled'); @@ -477,7 +476,7 @@ if ($create_module) { 'plugin_parameter' => $plugin_parameter, 'id_plugin' => $id_plugin, 'post_process' => $post_process, - 'prediction_module' => $id_prediction_module, + 'prediction_module' => $prediction_module, 'max_timeout' => $max_timeout, 'disabled' => $disabled, 'id_modulo' => $id_module, diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 1b192b583a..c589122e83 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -236,6 +236,7 @@ echo ''; require_jquery_file ('ui'); require_jquery_file ('form'); require_jquery_file ('pandora'); +require_jquery_file ('pandora.controls'); require_javascript_file ('pandora_modules'); ?> @@ -244,6 +245,7 @@ require_javascript_file ('pandora_modules'); var no_name_lang = ""; var no_target_lang = ""; var no_oid_lang = ""; +var no_prediction_module_lang = ""; $(document).ready (function () { configure_modules_form (); diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 8264a32910..a645a8a14b 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -93,6 +93,8 @@ require_once ('include/functions_network_components.php'); $update_module_id = (int) get_parameter_get ('update_module'); +print_input_hidden ('moduletype', $moduletype); + $table_simple->id = 'simple'; $table_simple->width = '90%'; $table_simple->class = 'databox_color'; diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index 29868b1621..c1c13bc7ff 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -18,16 +18,34 @@ $extra_title = __('Prediction server module'); $data = array (); $data[0] = __('Source module'); $data[0] .= print_help_icon ('prediction_source_module', true); -$agents = get_group_agents (array_keys (get_user_groups ($config["id_user"], "AW"))); -$fields = array (); -foreach ($agents as $agent_id => $agent_name) { - $modules = get_agent_modules ($agent_id, false, 'disabled = 0 AND history_data = 1'); - foreach ($modules as $module_id => $module_name) { - $fields[$module_id] = $agent_name.' / '.$module_name; - } +$groups = get_user_groups ($config["id_user"], "AR"); +$agents = get_group_agents (array_keys ($groups)); + +if ($prediction_module) { + $prediction_id_agent = get_agentmodule_agent ($prediction_module); + $prediction_id_group = get_agent_group ($prediction_id_agent); +} else { + $prediction_id_agent = $id_agente; + $prediction_id_group = get_agent_group ($id_agente); } -$data[1] = print_select ($fields, 'prediction_module', $prediction_module, '', +$modules = get_agent_modules ($prediction_id_agent, false, 'disabled = 0 AND history_data = 1'); + +$data[1] = ''; +$data[1] .= print_select ($groups, 'prediction_id_group', $prediction_id_group, '', '', '', true); +$data[1] .= ' '; +$data[1] .= ''; +$data[1] .= print_select ($agents, 'prediction_id_agent', $prediction_id_agent, '', + '', '', true); +$data[1] .= ' '; +$data[1] .= ''; +$data[1] .= print_select ($modules, 'prediction_module', $prediction_module, '', + '', '', true); + $table_simple->colspan['prediction_module'][1] = 3; push_table_simple ($data, 'prediction_module'); diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php index 0601cc914e..c1fa32bc9b 100644 --- a/pandora_console/godmode/alerts/alert_list.php +++ b/pandora_console/godmode/alerts/alert_list.php @@ -417,8 +417,7 @@ $(document).ready (function () { $select = $("#id_agent_module").disable (); $select.siblings ("span#latest_value").hide (); $("option[value!=0]", $select).remove (); - }, - callbackAfter: function () { + return true; } }); diff --git a/pandora_console/include/javascript/jquery.pandora.controls.js b/pandora_console/include/javascript/jquery.pandora.controls.js index ed3c2306e2..954b01b2df 100644 --- a/pandora_console/include/javascript/jquery.pandora.controls.js +++ b/pandora_console/include/javascript/jquery.pandora.controls.js @@ -1,6 +1,6 @@ (function($) { var dummyFunc = function () { - return; + return true; }; $.extend ({ @@ -27,7 +27,8 @@ var $select = $(config.agentSelect).disable (); $(config.loading).show (); $("option[value!=0]", $select).remove (); - config.callbackBefore (this); + if (! config.callbackBefore (this)) + return; jQuery.post ("ajax.php", {"page" : "godmode/groups/group_list", @@ -81,7 +82,8 @@ var $select = $(config.moduleSelect).disable (); $(config.loading).show (); $("option[value!=0]", $select).remove (); - config.callbackBefore (this); + if (! config.callbackBefore (this)) + return; jQuery.post ('ajax.php', {"page": "operation/agentes/ver_agente", @@ -136,7 +138,8 @@ var $select = $(config.alertSelect).disable (); $(config.loading).show (); $("option[value!=0]", $select).remove (); - config.callbackBefore (this); + if (! config.callbackBefore (this)) + return; jQuery.post ('ajax.php', {"page": "godmode/alerts/alert_list", diff --git a/pandora_console/include/javascript/pandora_modules.js b/pandora_console/include/javascript/pandora_modules.js index 9134ad9fc4..822a8efdc9 100644 --- a/pandora_console/include/javascript/pandora_modules.js +++ b/pandora_console/include/javascript/pandora_modules.js @@ -148,17 +148,26 @@ function configure_modules_form () { }); $("form#module_form").submit (function () { - if ($("#text-name").attr ("value") == "") { + if ($("#text-name").val () == "") { $("#text-name").focus (); $("#message").showMessage (no_name_lang); return false; } + moduletype = $("#hidden-moduletype").val (); + if (moduletype == 5) { + if ($("#prediction_module").val () == null) { + $("#prediction_module").focus (); + $("#message").showMessage (no_module_lang); + return false; + } + } + module = $("#id_module_type").attr ("value"); if (id_modules_icmp.in_array (module) || id_modules_tcp.in_array (module) || id_modules_snmp.in_array (module)) { /* Network module */ - if ($("#text-ip_target").attr ("value") == "") { + if ($("#text-ip_target").val () == "") { $("#text-ip_target").focus (); $("#message").showMessage (no_target_lang); return false; @@ -177,4 +186,24 @@ function configure_modules_form () { $("#message").hide (); return true; }); + + $("#prediction_id_group").pandoraSelectGroupAgent ({ + agentSelect: "select#prediction_id_agent", + callbackBefore: function () { + $("#module_loading").show (); + $("#prediction_module option").remove (); + return true; + }, + callbackAfter: function (e) { + if ($("#prediction_id_agent").children ().length == 0) { + $("#module_loading").hide (); + return; + } + $("#prediction_id_agent").change (); + } + }); + + $("#prediction_id_agent").pandoraSelectAgentModule ({ + moduleSelect: "select#prediction_module" + }); } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 3c4aeae11e..70c2e9efba 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -780,9 +780,14 @@ table#simple select#id_plugin, table#network_component select#id_plugin { width: 270px; } +table#simple select#prediction_id_group, +table#simple select#prediction_id_agent, +table#simple select#prediction_module { + width: 50%; + display: block; +} table#simple input#text-plugin_parameter, table#simple input#text-snmp_oid, -table#simple select#prediction_module, table#source_table select, table#destiny_table select, table#target_table select, @@ -800,6 +805,11 @@ table#simple span#component { width: 45%; font-style: italic; } +table#simple label { + display: inline; + font-weight: normal; + font-style: italic; +} .clickable { cursor: pointer; }