diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index ddd240aef3..bbd65b8f87 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2009-09-07 Miguel de Dios + + * include/javascript/pandora_modules.js: add events for selects in + local modules form: + * godmode/agentes/module_manager_editor.php: add ajax request for local + modules form. + 2009-09-04 Sancho Lerena * pandoradb.sql: Commented server type codes. diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index c589122e83..b2c26456b8 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -20,6 +20,8 @@ if (is_ajax ()) { $snmp_walk = (bool) get_parameter ('snmp_walk'); $get_module_component = (bool) get_parameter ('get_module_component'); $get_module_components = (bool) get_parameter ('get_module_components'); + $get_module_local_components = (bool) get_parameter('get_module_local_components'); + $get_module_local_component = (bool) get_parameter('get_module_local_component'); if ($get_module_component) { $id_component = (int) get_parameter ('id_module_component'); @@ -44,6 +46,25 @@ if (is_ajax ()) { return; } + if ($get_module_local_components) { + require_once ($config['homedir'].'/'.ENTERPRISE_DIR.'/include/functions_local_components.php'); + + $id_module_group = (int) get_parameter ('id_module_component_group'); + $localComponents = get_local_components(array('id_network_component_group' => $id_module_group), array('id', 'name')); + + echo json_encode($localComponents); + return; + } + + if ($get_module_local_component) { + $id_component = (int) get_parameter ('id_module_component'); + + $component = get_db_row ('tlocal_component', 'id', $id_component); + + echo json_encode ($component); + return; + } + if ($snmp_walk) { $ip_target = (string) get_parameter ('ip_target'); $snmp_community = (string) get_parameter ('snmp_community'); diff --git a/pandora_console/include/javascript/pandora_modules.js b/pandora_console/include/javascript/pandora_modules.js index 8ddd09ae24..84da5ff724 100644 --- a/pandora_console/include/javascript/pandora_modules.js +++ b/pandora_console/include/javascript/pandora_modules.js @@ -19,6 +19,65 @@ function configure_modules_form () { } }); + $("#local_component_group").change (function () { + + var $select = $("#local_component").hide (); + $("#component").hide (); + if (this.value == 0) + return; + $("#component_loading").show (); + $(".error, #no_component").hide (); + $("option[value!=0]", $select).remove (); + jQuery.post ("ajax.php", + {"page" : "godmode/agentes/module_manager_editor", + "get_module_local_components" : 1, + "id_module_component_group" : this.value, + "id_module_component_type" : $("#hidden-id_module_component_type").attr ("value") + }, + function (data, status) { + if (data == false) { + $("#component_loading").hide (); + $("span#no_component").show (); + return; + } + jQuery.each (data, function (i, val) { + option = $("") + .attr ("value", val['id']) + .append (val['name']); + $select.append (option); + }); + $("#component_loading").hide (); + $select.show (); + $("#component").show (); + }, + "json" + ); + + } + ); + + + $("#local_component").change (function () { + if (this.value == 0) + return; + $("#component_loading").show (); + $(".error").hide (); + jQuery.post ("ajax.php", + {"page" : "godmode/agentes/module_manager_editor", + "get_module_local_component" : 1, + "id_module_component" : this.value + }, + function (data, status) { + $("#text-name").attr ("value", html_entity_decode (data["name"])); + $("#textarea_description").attr ("value", html_entity_decode (data["description"])); + $("#textarea_configuration_data").attr ("value", html_entity_decode (data["data"])); + $("#component_loading").hide (); + $("#id_module_type").change (); + }, + "json" + ); + }); + $("#network_component_group").change (function () { var $select = $("#network_component").hide (); $("#component").hide ();