From 0c83c40a555f29bd5fb43cc59103052b80c1066e Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Wed, 29 Aug 2012 11:58:36 +0000 Subject: [PATCH] 2012-08-29 Sergio Martin * include/styles/pandora_legacy.css include/styles/pandora.css include/javascript/pandora_modules.js godmode/agentes/module_manager_editor_common.php godmode/agentes/configurar_agente.php godmode/agentes/module_manager_editor.php godmode/servers/plugin.php: Add macros to the local modules like the wizard or plugin modules. Fix some little bugs of interface git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6920 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 11 ++++++ .../godmode/agentes/configurar_agente.php | 22 +++++++++++- .../godmode/agentes/module_manager_editor.php | 15 ++++---- .../agentes/module_manager_editor_common.php | 36 +++++++++++++++++-- pandora_console/godmode/servers/plugin.php | 2 ++ .../include/javascript/pandora_modules.js | 30 ++++++++++++++++ pandora_console/include/styles/pandora.css | 5 ++- .../include/styles/pandora_legacy.css | 5 ++- 8 files changed, 113 insertions(+), 13 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 9ef079613b..efc5f3f9e3 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2012-08-29 Sergio Martin + + * include/styles/pandora_legacy.css + include/styles/pandora.css + include/javascript/pandora_modules.js + godmode/agentes/module_manager_editor_common.php + godmode/agentes/configurar_agente.php + godmode/agentes/module_manager_editor.php + godmode/servers/plugin.php: Add macros to the local modules like + the wizard or plugin modules. Fix some little bugs of interface + 2012-08-29 Miguel de Dios * pandoradb.sql, pandoradb.postgreSQL.sql, pandoradb.oracle.sql, diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 4986c48b44..7b7cdf4c51 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -711,6 +711,26 @@ if ($update_module || $create_module) { } $macros = json_encode($macros); + + $macros_for_data = config_agents_get_macros_data_conf($_POST); + + $conf_array = explode("\n",$configuration_data); + foreach($conf_array as $line) { + if(preg_match("/^module_name\s*(.*)/", $line, $match)) { + $new_configuration_data .= "module_name $name\n"; + } + // We delete from conf all the module macros starting with _field + else if(!preg_match("/^module_macro_field.*/", $line, $match)) { + $new_configuration_data .= "$line\n"; + } + } + + if($macros_for_data != '') { + // Add macros to configuration file + $new_configuration_data = str_replace('module_end', $macros_for_data."module_end", $new_configuration_data); + } + + $configuration_data = $new_configuration_data; } // Services are an enterprise feature, @@ -1231,4 +1251,4 @@ switch ($tab) { } break; } -?> \ No newline at end of file +?> diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 8ae165ab54..19a65a89ea 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -367,13 +367,8 @@ echo ''; echo '
'; html_print_table ($table_simple); -echo ''; -echo __('Advanced options').' ' .html_print_image ("images/down.png", true, array ("title" => __('Advanced options'))); -echo ''; +ui_toggle(html_print_table ($table_advanced, true), __('Advanced options')); -echo ''; // Submit echo '
'; @@ -459,7 +454,11 @@ $(document).ready (function () { $("#simple-configuration_data").hide(); } else { - $("#simple-configuration_data").show(); + // If exists macros dont show configuration data because + // this visibility is controled by a form button + if($('#hidden-macros').val() == '') { + $("#simple-configuration_data").show(); + } } } @@ -471,4 +470,4 @@ $(document).ready (function () { }); }); /* ]]> */ - \ No newline at end of file + diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index b1fb7dc47a..6bfbca6c89 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -159,7 +159,22 @@ else } if (!$edit) { - $table_simple->data[1][1] = ''.modules_get_moduletype_description ($id_module_type).''; + $sql = sprintf ('SELECT id_tipo, nombre + FROM ttipo_modulo + WHERE id_tipo = %s + ORDER BY descripcion', + $id_module_type); + + $type_names = db_get_all_rows_sql($sql); + + $type_names_hash = array(); + foreach($type_names as $tn) { + $type_names_hash[$tn['id_tipo']] = $tn['nombre']; + } + + $table_simple->data[1][1] = ''.modules_get_moduletype_description ($id_module_type).' ('.$type_names_hash[$id_module_type].')'; + + $table_simple->data[1][1] .= html_print_input_hidden('type_names',base64_encode(json_encode($type_names_hash)),true); } else { if (isset($id_module_type)) { @@ -174,8 +189,25 @@ else { WHERE categoria IN (%s) ORDER BY descripcion', implode (',', $categories)); + $table_simple->data[1][1] = html_print_select_from_sql ($sql, 'id_module_type', $idModuleType, '', '', '', true, false, false, $disabledBecauseInPolicy, false, false, 100); + + // Store the relation between id and name of the types on a hidden field + $sql = sprintf ('SELECT id_tipo, nombre + FROM ttipo_modulo + WHERE categoria IN (%s) + ORDER BY descripcion', + implode (',', $categories)); + + $type_names = db_get_all_rows_sql($sql); + + $type_names_hash = array(); + foreach($type_names as $tn) { + $type_names_hash[$tn['id_tipo']] = $tn['nombre']; + } + + $table_simple->data[1][1] .= html_print_input_hidden('type_names',base64_encode(json_encode($type_names_hash)),true); } $table_simple->data[1][2] = __('Module group'); @@ -350,4 +382,4 @@ $(document).ready (function () { }); }); /* ]]> */ - \ No newline at end of file + diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index 68697a7360..56fd2baab1 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -111,6 +111,8 @@ if (($create != "") OR ($view != "")) { $table->colspan['plugin_desc'][1] = 3; $table->data['plugin_desc'] = $data; + echo '
'; + echo '
'.__('General').''; html_print_table($table); echo '
'; diff --git a/pandora_console/include/javascript/pandora_modules.js b/pandora_console/include/javascript/pandora_modules.js index 7e5c08afed..40005cd383 100644 --- a/pandora_console/include/javascript/pandora_modules.js +++ b/pandora_console/include/javascript/pandora_modules.js @@ -98,6 +98,35 @@ function configure_modules_form () { $("#text-unit").attr("value", (data["unit"] == '') ? '' : data["unit"]) $("#component_loading").hide (); $("#id_module_type").change (); + + // Delete macro fields + $('.macro_field').remove(); + + $('#hidden-macros').val(''); + + var legend = ''; + // If exist macros, load the fields + if(data["macros"] != '') { + $('#hidden-macros').val(Base64.encode(data["macros"])); + + var obj = jQuery.parseJSON(data["macros"]); + $.each(obj, function(k,macro) { + add_macro_field(macro, 'simple-macro'); + legend += macro['macro']+" = "+ macro['desc']+"
"; + }); + $('#configuration_data_legend').html(legend); + + $('#simple-show_configuration_data').show(); + $('#simple-hide_configuration_data').hide(); + $('#configuration_data_legend').show(); + $('#simple-configuration_data').hide(); + } + else { + $('#simple-show_configuration_data').hide(); + $('#simple-hide_configuration_data').hide(); + $('#configuration_data_legend').hide(); + $('#simple-configuration_data').show(); + } }, "json" ); @@ -169,6 +198,7 @@ function configure_modules_form () { $("#id_module_group option[value="+data["id_module_group"]+"]").select (1); $("#max_timeout").attr ("value", data["max_timeout"]); $("#id_plugin option[value="+data["id_plugin"]+"]").select (1); + $("#id_plugin").trigger('change'); $("#text-plugin_user").attr ("value", js_html_entity_decode (data["plugin_user"])); $("#password-plugin_pass").attr ("value", js_html_entity_decode (data["plugin_pass"])); $("#text-plugin_parameter").attr ("value", js_html_entity_decode (data["plugin_parameter"])); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 27d59276d7..0541df6f0d 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -367,7 +367,7 @@ input.sub[disabled] { input.next, input.upd, input.ok, input.wand, input.delete, input.cog, input.target, input.search, input.copy, input.add, input.graph, input.percentile, input.binary, input.camera, input.config, -input.cancel { +input.cancel, input.default { padding-right: 21px; } @@ -419,6 +419,9 @@ input.camera { input.config { background: #e5e5e5 url(../../images/config.png) no-repeat 98% 3px; } +input.default { + background: #e5e5e5 url(../../images/default_list.png) no-repeat 98% 3px; +} #toolbox { diff --git a/pandora_console/include/styles/pandora_legacy.css b/pandora_console/include/styles/pandora_legacy.css index 7f784fef26..2b69829911 100644 --- a/pandora_console/include/styles/pandora_legacy.css +++ b/pandora_console/include/styles/pandora_legacy.css @@ -360,7 +360,7 @@ input.sub[disabled] { input.next, input.upd, input.ok, input.wand, input.delete, input.cog, input.target, input.search, input.copy, input.add, input.graph, input.percentile, input.binary, -input.camera, input.config, input.cancel { +input.camera, input.config, input.cancel, input.default { padding-right: 21px; } input.delete_min, input.graph_min, input.percentile_min, input.percentile_item_min, input.binary_min, @@ -415,6 +415,9 @@ input.camera { input.config { background: #e5e5e5 url(../../images/config.png) no-repeat 98% 3px; } +input.default { + background: #e5e5e5 url(../../images/default_list.png) no-repeat 98% 3px; +} input.delete_min { background: #e5e5e5 url(../../images/cross.png) no-repeat center; }