From 1bb1011868f7253d95e13aaad85dd4d352b241f8 Mon Sep 17 00:00:00 2001 From: zarzuelo <zarzuelo@gmail.com> Date: Fri, 7 Dec 2012 14:25:40 +0000 Subject: [PATCH] 2012-12-07 Sergio Martin <sergio.martin@artica.es> * include/javascript/pandora_modules.js godmode/agentes/module_manager_editor_common.php godmode/agentes/configurar_agente.php godmode/modules/manage_network_components_form.php godmode/modules/manage_network_components_form_common.php godmode/modules/manage_network_components.php: Added id_category to network components and module editors git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7238 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 10 +++++++++ .../godmode/agentes/configurar_agente.php | 3 ++- .../agentes/module_manager_editor_common.php | 4 ++++ .../modules/manage_network_components.php | 11 +++++++--- .../manage_network_components_form.php | 3 +++ .../manage_network_components_form_common.php | 11 ++++++++++ .../include/javascript/pandora_modules.js | 22 +++++++++++++++---- 7 files changed, 56 insertions(+), 8 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e3c3fc4280..9a3c61707a 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2012-12-07 Sergio Martin <sergio.martin@artica.es> + + * include/javascript/pandora_modules.js + godmode/agentes/module_manager_editor_common.php + godmode/agentes/configurar_agente.php + godmode/modules/manage_network_components_form.php + godmode/modules/manage_network_components_form_common.php + godmode/modules/manage_network_components.php: Added id_category + to network components and module editors + 2012-12-07 Ramon Novoa <rnovoa@artica.es> * include/functions_graph.php, diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 54b9192bff..b06bb917cf 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -986,7 +986,8 @@ if ($create_module) { 'unknown_instructions' => $unknown_instructions, 'critical_inverse' => $critical_inverse, 'warning_inverse' => $warning_inverse, - 'cron_interval' => $cron_interval); + 'cron_interval' => $cron_interval, + 'id_category' => $id_category); if ($prediction_module == 3 && $serialize_ops == '') { $id_agent_module = false; diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 50dcadc2c9..b9d7d1af90 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -385,6 +385,10 @@ if (check_acl ($config['id_user'], 0, "PM")) { $table_advanced->data[13][1] = html_print_select(categories_get_all_categories('forselect'), 'id_category', $id_category, '', __('None'), 0, true); $table_advanced->colspan[13][1] = 4; } +else { + // Store in a hidden field if is not visible to avoid delete the value + $table_advanced->data[12][4] .= html_print_input_hidden ('id_category', $id_category, true); +} ?> <script type="text/javascript"> diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index 990753261b..7067739db2 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -29,6 +29,7 @@ if (! check_acl ($config['id_user'], 0, "PM")) { ui_print_page_header (__('Module management').' » '.__('Network component management'), "", false, "network_component", true); require_once ('include/functions_network_components.php'); +include_once("include/functions_categories.php"); $type = (int) get_parameter ('type'); $name = (string) get_parameter ('name'); @@ -81,6 +82,7 @@ $warning_instructions = (string) get_parameter('warning_instructions'); $unknown_instructions = (string) get_parameter('unknown_instructions'); $critical_inverse = (int) get_parameter('critical_inverse'); $warning_inverse = (int) get_parameter('warning_inverse'); +$id_category = (int) get_parameter('id_category'); $snmp_version = (string) get_parameter('snmp_version'); $snmp3_auth_user = (string) get_parameter('snmp3_auth_user'); @@ -173,7 +175,8 @@ if ($create_component) { 'warning_instructions' => $warning_instructions, 'unknown_instructions' => $unknown_instructions, 'critical_inverse' => $critical_inverse, - 'warning_inverse' => $warning_inverse)); + 'warning_inverse' => $warning_inverse, + 'id_category' => $id_category)); } else { $id = ''; @@ -251,7 +254,8 @@ if ($update_component) { 'warning_instructions' => $warning_instructions, 'unknown_instructions' => $unknown_instructions, 'critical_inverse' => $critical_inverse, - 'warning_inverse' => $warning_inverse)); + 'warning_inverse' => $warning_inverse, + 'id_category' => $id_category)); } else { $result = ''; @@ -367,7 +371,8 @@ $url = ui_get_url_refresh (array ('offset' => false, 'warning_instructions' => false, 'unknown_instructions' => false, 'critical_inverse' => false, - 'warning_inverse' => false)); + 'warning_inverse' => false, + 'id_category' => false)); $search_id_group = (int) get_parameter ('search_id_group'); diff --git a/pandora_console/godmode/modules/manage_network_components_form.php b/pandora_console/godmode/modules/manage_network_components_form.php index 401c6acfd7..c72c1c22ef 100644 --- a/pandora_console/godmode/modules/manage_network_components_form.php +++ b/pandora_console/godmode/modules/manage_network_components_form.php @@ -66,6 +66,7 @@ if ($create_network_from_module) { $unknown_instructions = $data_module["unknown_instructions"]; $critical_inverse = $data_module["critical_inverse"]; $warning_inverse = $data_module["warning_inverse"]; + $id_category = $data_module["id_category"]; } $id_component_type = (int) get_parameter ('id_component_type'); @@ -114,6 +115,7 @@ if (isset ($id)) { $unknown_instructions = $component["unknown_instructions"]; $critical_inverse = $component["critical_inverse"]; $warning_inverse = $component["warning_inverse"]; + $id_category = $component["id_category"]; if ($type >= 15 && $type <= 18) { // New support for snmp v3 @@ -160,6 +162,7 @@ if (isset ($id)) { $unknown_instructions = ''; $critical_inverse = 0; $warning_inverse = 0; + $id_category = 0; $snmp_version = 1; $snmp3_auth_user = ''; diff --git a/pandora_console/godmode/modules/manage_network_components_form_common.php b/pandora_console/godmode/modules/manage_network_components_form_common.php index ff50b05c15..2cb06e97b0 100644 --- a/pandora_console/godmode/modules/manage_network_components_form_common.php +++ b/pandora_console/godmode/modules/manage_network_components_form_common.php @@ -134,4 +134,15 @@ $table->data[8][2] = $table->data[8][3] = ''; $table->data[9][0] = __('Unknown instructions'). ui_print_help_tip(__("Instructions when the status is unknown"), true); $table->data[9][1] = html_print_textarea ('unknown_instructions', 2, 65, $unknown_instructions, '', true); $table->data[9][2] = $table->data[9][3] = ''; + +if (check_acl ($config['id_user'], 0, "PM")) { + $table->data[10][0] = __('Category'); + $table->data[10][1] = html_print_select(categories_get_all_categories('forselect'), 'id_category', $id_category, '', __('None'), 0, true); + $table->data[10][2] = $table->data[9][3] = ''; +} +else { + // Store in a hidden field if is not visible to avoid delete the value + $table->data[9][2] .= html_print_input_hidden ('id_category', $id_category, true); +} + ?> diff --git a/pandora_console/include/javascript/pandora_modules.js b/pandora_console/include/javascript/pandora_modules.js index 0c7e8182eb..53e7d70cf0 100644 --- a/pandora_console/include/javascript/pandora_modules.js +++ b/pandora_console/include/javascript/pandora_modules.js @@ -137,7 +137,15 @@ function configure_modules_form () { $("#text-warning_inverse").attr ("value", (data["warning_inverse"] == 0) ? 0 : data["warning_inverse"]); $("#component_loading").hide (); $("#id_module_type").change (); - + if($("#id_category").is("select")) { + $("#id_category option[value="+data["id_category"]+"]").select (1); + console.log('select'); + } + else { + $("#hidden-id_category").val(data["id_category"]); + console.log('hidden'); + } + // Delete macro fields $('.macro_field').remove(); @@ -145,7 +153,7 @@ function configure_modules_form () { var legend = ''; // If exist macros, load the fields - if(data["macros"] != '') { + if(data["macros"] != '' && data["macros"] != null) { $('#hidden-macros').val(Base64.encode(data["macros"])); var obj = jQuery.parseJSON(data["macros"]); @@ -259,14 +267,20 @@ function configure_modules_form () { $("#text-warning_inverse").attr ("value", (data["warning_inverse"] == 0) ? 0 : data["warning_inverse"]); $("#component_loading").hide (); $("#id_module_type").change (); - + if($("#id_category").is("select")) { + $("#id_category option[value="+data["id_category"]+"]").select (1); + } + else { + $("#hidden-id_category").val(data["id_category"]); + } + // Delete macro fields $('.macro_field').remove(); $('#hidden-macros').val(''); // If exist macros, load the fields - if(data["macros"] != '') { + if(data["macros"] != '' && data["macros"] != null) { $('#hidden-macros').val(Base64.encode(data["macros"])); var obj = jQuery.parseJSON(data["macros"]);