From 8fb04851c4062bee40da6963037a17993855b31f Mon Sep 17 00:00:00 2001 From: juanmanuelr Date: Tue, 10 Apr 2012 15:33:26 +0000 Subject: [PATCH] 2012-04-10 Juan Manuel Ramon * include/ajax/reporting.ajax.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/graph_builder.main.php godmode/reporting/reporting_builder.php godmode/reporting/reporting_builder.item_editor.php: Several fixes in metaconsole reports. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5926 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 9 + .../godmode/reporting/graph_builder.main.php | 2 - .../reporting_builder.item_editor.php | 172 +++++++++++++++++- .../reporting_builder.list_items.php | 2 +- .../godmode/reporting/reporting_builder.php | 10 +- .../include/ajax/reporting.ajax.php | 33 +++- 6 files changed, 218 insertions(+), 10 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 49aed0977c..92e7c723b7 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2012-04-10 Juan Manuel Ramon + + * include/ajax/reporting.ajax.php + godmode/reporting/reporting_builder.list_items.php + godmode/reporting/graph_builder.main.php + godmode/reporting/reporting_builder.php + godmode/reporting/reporting_builder.item_editor.php: Several fixes + in metaconsole reports. + 2012-04-10 Sergio Martin * include/functions_agents.php: Fixed an error when try diff --git a/pandora_console/godmode/reporting/graph_builder.main.php b/pandora_console/godmode/reporting/graph_builder.main.php index 68585c674e..2fbc2bfab7 100644 --- a/pandora_console/godmode/reporting/graph_builder.main.php +++ b/pandora_console/godmode/reporting/graph_builder.main.php @@ -127,8 +127,6 @@ echo ""; echo "".__('Height').""; echo ""; echo ""; - -$period_label = $periods[$period]; echo ""; echo ""; diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index c4c832c09a..84a67658fd 100644 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -497,7 +497,30 @@ html_print_input_hidden('id_item', $idItem); @@ -552,6 +575,8 @@ html_print_input_hidden('id_item', $idItem); if ($config['metaconsole'] == 1) { $graphs = array(); $graphs = metaconsole_get_custom_graphs(); + $value_selected = $idCustomGraph . '|' . $server_name; + html_print_select($graphs, 'id_custom_graph', $value_selected, 'change_custom_graph();', __('None'), 0); } else { switch ($config["dbtype"]) { @@ -563,14 +588,37 @@ html_print_input_hidden('id_item', $idItem); $query_sql = 'SELECT id_graph, name FROM tgraph WHERE private = 0 OR (private = 1 AND id_user = \''.$config["id_user"].'\')'; break; } + html_print_select_from_sql($query_sql, 'id_custom_graph', $idCustomGraph, 'change_custom_graph();', __('None'), 0); } - html_print_select_from_sql($query_sql, 'id_custom_graph', $idCustomGraph, 'change_custom_graph();', '--', 0); $style_button_create_custom_graph = 'style="display: none;"'; $style_button_edit_custom_graph = ''; if (empty($idCustomGraph)) { $style_button_create_custom_graph = ''; $style_button_edit_custom_graph = 'style="display: none;"'; + // Select the target server + if ($config['metaconsole'] == 1) { + $metaconsole_connections = enterprise_hook('metaconsole_get_connection_names'); + if ($metaconsole_connections === false) { + $metaconsole_connections = array(); + } + $result_servers = array(); + foreach ($metaconsole_connections as $metaconsole_element){ + $connection_data = enterprise_hook('metaconsole_get_connection', array($metaconsole_element)); + $result_servers[$connection_data['server_name']] = $connection_data['server_name']; + } + // Print select combo with metaconsole servers + if (!empty($result_servers)) { + echo ''; + } + else { + // If there are not metaconsole servers don't allow to create new custom graphs + $style_button_create_custom_graph = 'style="display: none;"'; + } + } } echo " "; html_print_button(__("Create"), 'create_graph', false, @@ -926,21 +974,137 @@ $(document).ready (function () { }); function create_custom_graph() { - window.location.href = "index.php?sec=greporting&sec2=godmode/reporting/graph_builder&create=Create graph"; + + var target_server = $("#meta_servers").val(); + // If target server is not selected + if (target_server == 0) { + $("#meta_target_servers").fadeOut ('normal'); + $("#meta_target_servers").fadeIn ('normal'); + $("#meta_target_servers").css('display', 'inline'); + } + else { + + var hash_data; + var params1 = []; + params1.push("get_metaconsole_hash_data=1"); + params1.push("server_name=" + target_server); + params1.push("page=include/ajax/reporting.ajax"); + jQuery.ajax ({ + data: params1.join ("&"), + type: 'POST', + url: action="ajax.php", + async: false, + timeout: 10000, + success: function (data) { + hash_data = data; + } + }); + + var server_url; + var params1 = []; + params1.push("get_metaconsole_server_url=1"); + params1.push("server_name=" + target_server); + params1.push("page=include/ajax/reporting.ajax"); + jQuery.ajax ({ + data: params1.join ("&"), + type: 'POST', + url: action="ajax.php", + async: false, + timeout: 10000, + success: function (data) { + server_url = data; + } + }); + + window.location.href = server_url + "/index.php?sec=reporting&sec2=godmode/reporting/graph_builder&create=Create graph" + hash_data; + } + + window.location.href = "index.php?sec=reporting&sec2=godmode/reporting/graph_builder&create=Create graph"; + } function edit_custom_graph() { var id_graph = $("#id_custom_graph").val(); - window.location.href = "index.php?sec=greporting&sec2=godmode/reporting/graph_builder&edit_graph=1&id=" + id_graph; + + var agent_server_temp; + var id_element_graph; + var id_server; + + if (id_graph.indexOf("|") != -1){ + agent_server_temp = id_graph.split('|'); + id_element_graph = agent_server_temp[0]; + id_server = agent_server_temp[1]; + } + + var hash_data; + var params1 = []; + params1.push("get_metaconsole_hash_data=1"); + params1.push("server_name=" + id_server); + params1.push("page=include/ajax/reporting.ajax"); + jQuery.ajax ({ + data: params1.join ("&"), + type: 'POST', + url: action="ajax.php", + async: false, + timeout: 10000, + success: function (data) { + hash_data = data; + } + }); + + var server_url; + var params1 = []; + params1.push("get_metaconsole_server_url=1"); + params1.push("server_name=" + id_server); + params1.push("page=include/ajax/reporting.ajax"); + jQuery.ajax ({ + data: params1.join ("&"), + type: 'POST', + url: action="ajax.php", + async: false, + timeout: 10000, + success: function (data) { + server_url = data; + } + }); + + window.location.href = server_url + "/index.php?sec=greporting&sec2=godmode/reporting/graph_builder&edit_graph=1&id=" + id_element_graph + hash_data; + + window.location.href = "index.php?sec=greporting&sec2=godmode/reporting/graph_builder&edit_graph=1&id=" + id_graph; + } function change_custom_graph() { //Hidden the button create or edit custom graph if ($("#id_custom_graph").val() != "0") { + $("#meta_servers").val(0); + $("#meta_target_servers").css('display', 'none'); $("#button-create_graph").css("display", "none"); $("#button-edit_graph").css("display", ""); } else { + $("#meta_servers").val(0); + $("#meta_target_servers").css('display', 'none'); $("#button-create_graph").css("display", ""); $("#button-edit_graph").css("display", "none"); } diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index ccdd586cf9..2a74dd81d9 100644 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -320,7 +320,7 @@ foreach ($items as $item) { } $row[6] .= '' . html_print_image("images/wrench_orange.png", true, array("title" => __('Edit'))) . ''; $row[6] .= '  '; - $row[6] .= '' . html_print_image("images/cross.png", true, array("title" => __('Delete'))) .''; + $row[6] .= '' . html_print_image("images/cross.png", true, array("title" => __('Delete'))) .''; $table->data[] = $row; $count++; diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 360c251f22..30cb2f26be 100644 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -427,7 +427,10 @@ switch ($action) { $values['id_agent'] = get_parameter('id_agent'); $values['id_gs'] = get_parameter('id_custom_graph'); - $values['id_agent_module'] = get_parameter('id_agent_module'); + if (($type == 'alert_report_agent') or ($type == 'event_report_agent')) + $values['id_agent_module'] = ''; + else + $values['id_agent_module'] = get_parameter('id_agent_module'); $values['only_display_wrong'] = get_parameter('checkbox_only_display_wrong'); $values['monday'] = get_parameter('monday', 0); $values['tuesday'] = get_parameter('tuesday', 0); @@ -550,7 +553,10 @@ switch ($action) { $values['id_agent'] = get_parameter('id_agent'); $values['id_gs'] = get_parameter('id_custom_graph'); - $values['id_agent_module'] = get_parameter('id_agent_module'); + if (($values['type'] == 'alert_report_agent') or ($values['type'] == 'event_report_agent')) + $values['id_agent_module'] = ''; + else + $values['id_agent_module'] = get_parameter('id_agent_module'); switch ($config['dbtype']) { case "mysql": case "postgresql": diff --git a/pandora_console/include/ajax/reporting.ajax.php b/pandora_console/include/ajax/reporting.ajax.php index 76a342801a..831a97aac6 100644 --- a/pandora_console/include/ajax/reporting.ajax.php +++ b/pandora_console/include/ajax/reporting.ajax.php @@ -33,6 +33,8 @@ $add_sla = get_parameter('add_sla', 0); $add_general = get_parameter('add_general', 0); $id = get_parameter('id', 0); $truncate_text = get_parameter ('truncate_text', 0); +$get_metaconsole_hash_data = get_parameter('get_metaconsole_hash_data', 0); +$get_metaconsole_server_url = get_parameter('get_metaconsole_server_url', 0); if ($delete_sla_item) { $result = db_process_sql_delete('treport_content_sla_combined', array('id' => (int)$id)); @@ -138,4 +140,33 @@ if ($truncate_text) { return ui_print_truncate_text ($text, 20, true, false); } -?> \ No newline at end of file +if ($get_metaconsole_hash_data) { + $server_name = get_parameter('server_name'); + + enterprise_include_once('include/functions_metaconsole.php'); + + $server = enterprise_hook('metaconsole_get_connection', array($server_name)); + + $pwd = $server["auth_token"]; // Create HASH login info + $user = $config["id_user"]; + $hashdata = $user.$pwd; + $hashdata = md5($hashdata); + $url_hash = "&loginhash=auto&loginhash_data=$hashdata&loginhash_user=$user"; + + echo $url_hash; + return; +} + +if ($get_metaconsole_server_url) { + $server_name = get_parameter('server_name'); + + enterprise_include_once('include/functions_metaconsole.php'); + + $server = enterprise_hook('metaconsole_get_connection', array($server_name)); + + echo $server["server_url"]; + return; +} + + +?>