2013-03-04 Miguel de Dios <miguel.dedios@artica.es>

* godmode/reporting/reporting_builder.item_editor.php,
	include/functions_ui.php, include/functions_reporting.php,
	include/constants.php, include/ajax/reporting.ajax.php,
	include/ajax/agent.php, operation/agentes/ver_agente.php: fixed the
	graphs and the autocomplete.
	
	Fixes: #3606284




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7771 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-03-04 14:31:30 +00:00
parent 6cb75be3b3
commit 4b678aa371
8 changed files with 234 additions and 58 deletions

View File

@ -1,3 +1,13 @@
2013-03-04 Miguel de Dios <miguel.dedios@artica.es>
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/functions_reporting.php,
include/constants.php, include/ajax/reporting.ajax.php,
include/ajax/agent.php, operation/agentes/ver_agente.php: fixed the
graphs and the autocomplete.
Fixes: #3606284
2013-03-04 Sergio Martin <sergio.martin@artica.es> 2013-03-04 Sergio Martin <sergio.martin@artica.es>
* include/functions_alerts.php: Update the fired * include/functions_alerts.php: Update the fired

View File

@ -626,6 +626,7 @@ html_print_input_hidden('id_item', $idItem);
html_print_input_hidden('id_agent', $idAgent); html_print_input_hidden('id_agent', $idAgent);
html_print_input_hidden ('server_name', $server_name); html_print_input_hidden ('server_name', $server_name);
html_print_input_hidden ('id_server', '');
$params = array(); $params = array();
@ -1043,9 +1044,13 @@ function print_SLA_list($width, $action, $idItem = null) {
continue; continue;
} }
} }
$idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); $idAgent = db_get_value_filter('id_agente',
'tagente_modulo',
array('id_agente_modulo' => $item['id_agent_module']));
$nameAgent = agents_get_name ($idAgent); $nameAgent = agents_get_name ($idAgent);
$nameModule = db_get_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); $nameModule = db_get_value_filter('nombre',
'tagente_modulo',
array('id_agente_modulo' => $item['id_agent_module']));
$server_name_element = ''; $server_name_element = '';
if ($meta && $server_name != '') if ($meta && $server_name != '')
@ -1093,9 +1098,9 @@ function print_SLA_list($width, $action, $idItem = null) {
$params['javascript_is_function_select'] = true; $params['javascript_is_function_select'] = true;
$params['selectbox_id'] = 'id_agent_module_sla'; $params['selectbox_id'] = 'id_agent_module_sla';
$params['add_none_module'] = false; $params['add_none_module'] = false;
$params['use_input_server'] = true;
$params['input_server_id'] = 'hidden-server_name';
if ($meta) { if ($meta) {
$params['use_input_id_server'] = true;
$params['input_id_server_id'] = 'hidden-id_server';
$params['disabled_javascript_on_blur_function'] = true; $params['disabled_javascript_on_blur_function'] = true;
} }
ui_print_agent_autocomplete_input($params); ui_print_agent_autocomplete_input($params);
@ -1209,9 +1214,9 @@ function print_General_list($width, $action, $idItem = null) {
$params['javascript_is_function_select'] = true; $params['javascript_is_function_select'] = true;
$params['selectbox_id'] = 'id_agent_module_general'; $params['selectbox_id'] = 'id_agent_module_general';
$params['add_none_module'] = false; $params['add_none_module'] = false;
$params['use_input_server'] = true;
$params['input_server_id'] = 'hidden-server_name_general';
if ($meta) { if ($meta) {
$params['use_input_id_server'] = true;
$params['input_id_server_id'] = 'hidden-id_server';
$params['disabled_javascript_on_blur_function'] = true; $params['disabled_javascript_on_blur_function'] = true;
} }
ui_print_agent_autocomplete_input($params); ui_print_agent_autocomplete_input($params);
@ -1480,7 +1485,7 @@ function deleteGeneralRow(id_row) {
function addSLARow() { function addSLARow() {
var nameAgent = $("input[name=agent_sla]").val(); var nameAgent = $("input[name=agent_sla]").val();
var idAgent = $("input[name=id_agent_sla]").val(); var idAgent = $("input[name=id_agent_sla]").val();
var serverName = $("input[name=server_name]").val(); var serverId = $("input[name=id_server]").val();
var idModule = $("#id_agent_module_sla").val(); var idModule = $("#id_agent_module_sla").val();
var nameModule = $("#id_agent_module_sla :selected").text(); var nameModule = $("#id_agent_module_sla :selected").text();
var slaMin = $("input[name=sla_min]").val(); var slaMin = $("input[name=sla_min]").val();
@ -1527,7 +1532,7 @@ function addSLARow() {
params.push("sla_min=" + slaMin); params.push("sla_min=" + slaMin);
params.push("sla_max=" + slaMax); params.push("sla_max=" + slaMax);
params.push("sla_limit=" + slaLimit); params.push("sla_limit=" + slaLimit);
params.push("server_name=" + serverName); params.push("server_id=" + serverId);
params.push("page=include/ajax/reporting.ajax"); params.push("page=include/ajax/reporting.ajax");
jQuery.ajax ({ jQuery.ajax ({
@ -1550,7 +1555,7 @@ function addSLARow() {
$(".delete_button", row).attr('href', 'javascript: deleteSLARow(' + data['id'] + ');'); $(".delete_button", row).attr('href', 'javascript: deleteSLARow(' + data['id'] + ');');
$("#list_sla").append($(row).html()); $("#list_sla").append($(row).html());
$("input[name=id_agent_sla]").val(''); $("input[name=id_agent_sla]").val('');
$("input[name=server_name]").val(''); $("input[name=id_server]").val('');
$("input[name=agent_sla]").val(''); $("input[name=agent_sla]").val('');
$("#id_agent_module_sla").empty(); $("#id_agent_module_sla").empty();
$("#id_agent_module_sla").attr('disabled', 'true'); $("#id_agent_module_sla").attr('disabled', 'true');
@ -1570,7 +1575,7 @@ function addSLARow() {
function addGeneralRow() { function addGeneralRow() {
var nameAgent = $("input[name=agent_general]").val(); var nameAgent = $("input[name=agent_general]").val();
var idAgent = $("input[name=id_agent_general]").val(); var idAgent = $("input[name=id_agent_general]").val();
var serverName = $("input[name=server_name_general]").val(); var serverId = $("input[name=id_server]").val();
var idModule = $("#id_agent_module_general").val(); var idModule = $("#id_agent_module_general").val();
var operation = $("#id_operation_module_general").val(); var operation = $("#id_operation_module_general").val();
var nameModule = $("#id_agent_module_general :selected").text(); var nameModule = $("#id_agent_module_general :selected").text();
@ -1626,7 +1631,7 @@ function addGeneralRow() {
params.push("add_general=1"); params.push("add_general=1");
params.push("id=" + $("input[name=id_item]").val()); params.push("id=" + $("input[name=id_item]").val());
params.push("id_module=" + idModule); params.push("id_module=" + idModule);
params.push("server_name_general=" + serverName); params.push("id_server=" + serverId);
params.push("operation=" + operation); params.push("operation=" + operation);
params.push("page=include/ajax/reporting.ajax"); params.push("page=include/ajax/reporting.ajax");
@ -1650,7 +1655,7 @@ function addGeneralRow() {
$("#list_general").append($(row).html()); $("#list_general").append($(row).html());
$("input[name=id_agent_general]").val(''); $("input[name=id_agent_general]").val('');
$("input[name=server_name_general]").val(''); $("input[name=id_server]").val('');
$("input[name=agent_general]").val(''); $("input[name=agent_general]").val('');
$("#id_operation_module_general").val('avg'); $("#id_operation_module_general").val('avg');
$("#id_agent_module_general").empty(); $("#id_agent_module_general").empty();

View File

@ -242,7 +242,8 @@ elseif ($search_agents && ($config['metaconsole'] == 1) && defined('METACONSOLE'
$data[] = array('id' => $agent['id_agente'], $data[] = array('id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']), 'name' => io_safe_output($agent['nombre']),
'ip' => io_safe_output($agent['direccion']), 'ip' => io_safe_output($agent['direccion']),
'filter' => 'agent'); 'filter' => 'agent',
'id_server' => $server['id']);
} }
} }
@ -265,7 +266,8 @@ elseif ($search_agents && ($config['metaconsole'] == 1) && defined('METACONSOLE'
$data[] = array('id' => $agent['id_agente'], $data[] = array('id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']), 'name' => io_safe_output($agent['nombre']),
'ip' => io_safe_output($agent['direccion']), 'ip' => io_safe_output($agent['direccion']),
'filter' => 'address'); 'filter' => 'address',
'id_server' => $server['id']);
} }
} }
@ -282,13 +284,15 @@ elseif ($search_agents && ($config['metaconsole'] == 1) && defined('METACONSOLE'
$filter_description[] = '(UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(comentarios) LIKE UPPER(\'%'.$string.'%\'))'; $filter_description[] = '(UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(comentarios) LIKE UPPER(\'%'.$string.'%\'))';
break; break;
} }
$agents = agents_get_agents($filter_description, array ('id_agente', 'nombre', 'direccion')); $agents = agents_get_agents($filter_description,
array ('id_agente', 'nombre', 'direccion'));
if ($agents !== false) { if ($agents !== false) {
foreach ($agents as $agent) { foreach ($agents as $agent) {
$data[] = array('id' => $agent['id_agente'], $data[] = array('id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']), 'name' => io_safe_output($agent['nombre']),
'ip' => io_safe_output($agent['direccion']), 'ip' => io_safe_output($agent['direccion']),
'filter' => 'description'); 'filter' => 'description',
'id_server' => $server['id']);
} }
} }
//Restore db connection //Restore db connection

View File

@ -65,7 +65,17 @@ if ($add_sla) {
$sla_limit = get_parameter('sla_limit', 0); $sla_limit = get_parameter('sla_limit', 0);
$sla_max = get_parameter('sla_max', 0); $sla_max = get_parameter('sla_max', 0);
$sla_min = get_parameter('sla_min', 0); $sla_min = get_parameter('sla_min', 0);
$server_name = get_parameter('server_name', ''); $server_id = (int)get_parameter('server_id', 0);
$include_enterprise = enterprise_include("include/functions_metaconsole.php");
if ($include_enterprise !== ENTERPRISE_NOT_HOOK) {
$connection = metaconsole_get_connection_by_id($server_id);
}
if (empty($connection)) {
$connection = array();
$connection['server_name'] = '';
}
$result = db_process_sql_insert('treport_content_sla_combined', array( $result = db_process_sql_insert('treport_content_sla_combined', array(
'id_report_content' => $id, 'id_report_content' => $id,
@ -73,7 +83,7 @@ if ($add_sla) {
'sla_max' => $sla_max, 'sla_max' => $sla_max,
'sla_min' => $sla_min, 'sla_min' => $sla_min,
'sla_limit' => $sla_limit, 'sla_limit' => $sla_limit,
'server_name' => $server_name)); 'server_name' => $connection['server_name']));
if ($result === false) { if ($result === false) {
$data['correct'] = 0; $data['correct'] = 0;
@ -89,13 +99,23 @@ if ($add_sla) {
if ($add_general) { if ($add_general) {
$id_module = get_parameter('id_module', 0); $id_module = get_parameter('id_module', 0);
$server_name = get_parameter('server_name_general', ''); $id_server = (int)get_parameter('id_server', 0);
$operation = get_parameter('operation', ''); $operation = get_parameter('operation', '');
$include_enterprise = enterprise_include("include/functions_metaconsole.php");
if ($include_enterprise !== ENTERPRISE_NOT_HOOK) {
$connection = metaconsole_get_connection_by_id($id_server);
}
if (empty($connection)) {
$connection = array();
$connection['server_name'] = '';
}
$result = db_process_sql_insert('treport_content_item', array( $result = db_process_sql_insert('treport_content_item', array(
'id_report_content' => $id, 'id_report_content' => $id,
'id_agent_module' => $id_module, 'id_agent_module' => $id_module,
'server_name' => $server_name, 'server_name' => $connection['server_name'],
'operation' => $operation)); 'operation' => $operation));
if ($result === false) { if ($result === false) {

View File

@ -258,4 +258,13 @@ define ('SERVER_TYPE_WEB', 9);
define ('SERVER_TYPE_EVENT', 10); define ('SERVER_TYPE_EVENT', 10);
define ('SERVER_TYPE_ENTERPRISE_ICMP', 11); define ('SERVER_TYPE_ENTERPRISE_ICMP', 11);
define ('SERVER_TYPE_ENTERPRISE_SNMP', 12); define ('SERVER_TYPE_ENTERPRISE_SNMP', 12);
/* REPORTS */
define ('REPORT_TOP_N_MAX', 1);
define ('REPORT_TOP_N_MIN', 2);
define ('REPORT_TOP_N_AVG', 0);
define ('REPORT_TOP_N_ONLY_GRAPHS', 2);
define ('REPORT_TOP_N_SHOW_TABLE_GRAPS', 1);
define ('REPORT_TOP_N_ONLY_TABLE', 0);
?> ?>

View File

@ -4831,17 +4831,15 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$top_n = $content['top_n']; $top_n = $content['top_n'];
switch ($top_n) { switch ($top_n) {
//Max case REPORT_TOP_N_MAX:
case 1:
$type_top_n = __('Max'); $type_top_n = __('Max');
break; break;
//Min case REPORT_TOP_N_MIN:
case 2:
$type_top_n = __('Min'); $type_top_n = __('Min');
break; break;
//Nothing or Average case REPORT_TOP_N_AVG:
case 0: //If nothing is selected then it will be shown the average data default:
case 3: //If nothing is selected then it will be shown the average data
$type_top_n = __('Avg'); $type_top_n = __('Avg');
break; break;
} }
@ -4879,7 +4877,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
break; break;
} }
if ($show_graph == 0 || $show_graph == 1) { if ($show_graph != REPORT_TOP_N_ONLY_GRAPHS) {
$table1->width = '99%'; $table1->width = '99%';
$table1->data = array (); $table1->data = array ();
$table1->head = array (); $table1->head = array ();
@ -4911,17 +4909,15 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
switch ($top_n) { switch ($top_n) {
//Max case REPORT_TOP_N_MAX:
case 1:
$value = reporting_get_agentmodule_data_max ($row['id_agent_module'], $content['period']); $value = reporting_get_agentmodule_data_max ($row['id_agent_module'], $content['period']);
break; break;
//Min case REPORT_TOP_N_MIN:
case 2:
$value = reporting_get_agentmodule_data_min ($row['id_agent_module'], $content['period']); $value = reporting_get_agentmodule_data_min ($row['id_agent_module'], $content['period']);
break; break;
//Nothing or Average case REPORT_TOP_N_AVG:
case 0: //If nothing is selected then it will be shown the average data default:
case 3: //If nothing is selected then it will be shown the average data
$value = reporting_get_agentmodule_data_average ($row['id_agent_module'], $content['period']); $value = reporting_get_agentmodule_data_average ($row['id_agent_module'], $content['period']);
break; break;
} }
@ -5044,18 +5040,23 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$table->colspan[3][0] = 3; $table->colspan[3][0] = 3;
$data = array(); $data = array();
if ($show_graph == 1 || $show_graph == 2) { if ($show_graph != REPORT_TOP_N_ONLY_TABLE) {
$data[0] = pie3d_graph(false, $data_pie_graph, $data[0] = pie3d_graph(false, $data_pie_graph,
$sizgraph_w, $sizgraph_h, __("other"), ui_get_full_url(false) . '/', $config['homedir'] . "/images/logo_vertical_water.png", $sizgraph_w, $sizgraph_h, __("other"),
ui_get_full_url(false, true, false, false) . '/', $config['homedir'] . "/images/logo_vertical_water.png",
$config['fontpath'], $config['font_size']); $config['fontpath'], $config['font_size']);
array_push ($table->data, $data); array_push ($table->data, $data);
//Display bars graph //Display bars graph
$table->colspan[4][0] = 3; $table->colspan[4][0] = 3;
$table->style[0] .= 'text-align:center'; $table->style[0] .= 'text-align:center';
$height = count($data_pie_graph)*20+35; $height = count($data_pie_graph)*20+35;
$data = array(); $data = array();
$data[0] = hbar_graph(false, $data_hbar, $sizgraph_w, $height, array(), array(), "", "", true, ui_get_full_url(false) . '/', $config['homedir'] . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size'], true, 1, true); $data[0] = hbar_graph(false, $data_hbar, $sizgraph_w,
$height, array(), array(), "", "", true,
ui_get_full_url(false, true, false, false) . '/', $config['homedir'] . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size'], true, 1, true);
array_push ($table->data, $data); array_push ($table->data, $data);
} }

View File

@ -2379,57 +2379,68 @@ function ui_print_agent_autocomplete_input($parameters) {
$return = $parameters['return']; $return = $parameters['return'];
} }
$input_name = uniqid('agent_autocomplete_'); //Default value $input_name = uniqid('agent_autocomplete_'); //Default value
if (isset($parameters['input_name'])) { if (isset($parameters['input_name'])) {
$input_name = $parameters['input_name']; $input_name = $parameters['input_name'];
} }
$input_id = 'text-' . $input_name; //Default value $input_id = 'text-' . $input_name; //Default value
if (isset($parameters['input_id'])) { if (isset($parameters['input_id'])) {
$input_id = $parameters['input_id']; $input_id = $parameters['input_id'];
} }
$selectbox_group = ''; //Default value $selectbox_group = ''; //Default value
if (isset($parameters['selectbox_group'])) { if (isset($parameters['selectbox_group'])) {
$selectbox_group = $parameters['selectbox_group']; $selectbox_group = $parameters['selectbox_group'];
} }
//Default value //Default value
$icon_image = html_print_image('images/lightning.png', true, false, true); $icon_image = html_print_image('images/lightning.png', true, false, true);
if (isset($parameters['icon_image'])) { if (isset($parameters['icon_image'])) {
$icon_image = $parameters['icon_image']; $icon_image = $parameters['icon_image'];
} }
$value = ''; //Default value $value = ''; //Default value
if (isset($parameters['value'])) { if (isset($parameters['value'])) {
$value = $parameters['value']; $value = $parameters['value'];
} }
$show_helptip = true; //Default value $show_helptip = true; //Default value
if (isset($parameters['show_helptip'])) { if (isset($parameters['show_helptip'])) {
$show_helptip = $parameters['show_helptip']; $show_helptip = $parameters['show_helptip'];
} }
$helptip_text = __("Type at least two characters to search."); //Default value $helptip_text = __("Type at least two characters to search."); //Default value
if (isset($parameters['helptip_text'])) { if (isset($parameters['helptip_text'])) {
$helptip_text = $parameters['helptip_text']; $helptip_text = $parameters['helptip_text'];
} }
$use_hidden_input_idagent = false; //Default value $use_hidden_input_idagent = false; //Default value
if (isset($parameters['use_hidden_input_idagent'])) { if (isset($parameters['use_hidden_input_idagent'])) {
$use_hidden_input_idagent = $parameters['use_hidden_input_idagent']; $use_hidden_input_idagent = $parameters['use_hidden_input_idagent'];
} }
$print_hidden_input_idagent = false; //Default value $print_hidden_input_idagent = false; //Default value
if (isset($parameters['print_hidden_input_idagent'])) { if (isset($parameters['print_hidden_input_idagent'])) {
$print_hidden_input_idagent = $parameters['print_hidden_input_idagent']; $print_hidden_input_idagent = $parameters['print_hidden_input_idagent'];
} }
$hidden_input_idagent_name = uniqid('agent_autocomplete_idagent_'); //Default value $hidden_input_idagent_name = uniqid('agent_autocomplete_idagent_'); //Default value
if (isset($parameters['hidden_input_idagent_name'])) { if (isset($parameters['hidden_input_idagent_name'])) {
$hidden_input_idagent_name = $parameters['hidden_input_idagent_name']; $hidden_input_idagent_name = $parameters['hidden_input_idagent_name'];
} }
$hidden_input_idagent_id = 'hidden-' . $input_name; //Default value $hidden_input_idagent_id = 'hidden-' . $input_name; //Default value
if (isset($parameters['hidden_input_idagent_id'])) { if (isset($parameters['hidden_input_idagent_id'])) {
$hidden_input_idagent_id = $parameters['hidden_input_idagent_id']; $hidden_input_idagent_id = $parameters['hidden_input_idagent_id'];
@ -2440,61 +2451,103 @@ function ui_print_agent_autocomplete_input($parameters) {
$hidden_input_idagent_value = $parameters['hidden_input_idagent_value']; $hidden_input_idagent_value = $parameters['hidden_input_idagent_value'];
} }
$size = 30; //Default value $size = 30; //Default value
if (isset($parameters['size'])) { if (isset($parameters['size'])) {
$size = $parameters['size']; $size = $parameters['size'];
} }
$maxlength = 100; //Default value $maxlength = 100; //Default value
if (isset($parameters['maxlength'])) { if (isset($parameters['maxlength'])) {
$maxlength = $parameters['maxlength']; $maxlength = $parameters['maxlength'];
} }
$disabled = false; //Default value $disabled = false; //Default value
if (isset($parameters['disabled'])) { if (isset($parameters['disabled'])) {
$disabled = $parameters['disabled']; $disabled = $parameters['disabled'];
} }
$selectbox_id = 'id_agent_module'; //Default value $selectbox_id = 'id_agent_module'; //Default value
if (isset($parameters['selectbox_id'])) { if (isset($parameters['selectbox_id'])) {
$selectbox_id = $parameters['selectbox_id']; $selectbox_id = $parameters['selectbox_id'];
} }
$add_none_module = true; //Default value $add_none_module = true; //Default value
if (isset($parameters['add_none_module'])) { if (isset($parameters['add_none_module'])) {
$add_none_module = $parameters['add_none_module']; $add_none_module = $parameters['add_none_module'];
} }
$none_module_text = '--'; //Default value $none_module_text = '--'; //Default value
if (isset($parameters['none_module_text'])) { if (isset($parameters['none_module_text'])) {
$none_module_text = $parameters['none_module_text']; $none_module_text = $parameters['none_module_text'];
} }
$print_input_server = false; //Default value $print_input_server = false; //Default value
if (isset($parameters['print_input_server'])) { if (isset($parameters['print_input_server'])) {
$print_input_server = $parameters['print_input_server']; $print_input_server = $parameters['print_input_server'];
} }
$print_input_id_server = false; //Default value
if (isset($parameters['print_input_id_server'])) {
$print_input_id_server = $parameters['print_input_id_server'];
}
$use_input_server = false; //Default value $use_input_server = false; //Default value
if (isset($parameters['use_input_server'])) { if (isset($parameters['use_input_server'])) {
$use_input_server = $parameters['use_input_server']; $use_input_server = $parameters['use_input_server'];
} }
$use_input_id_server = false; //Default value
if (isset($parameters['use_input_id_server'])) {
$use_input_id_server = $parameters['use_input_id_server'];
}
$input_server_name = uniqid('server_'); //Default value $input_server_name = uniqid('server_'); //Default value
if (isset($parameters['input_server_name'])) { if (isset($parameters['input_server_name'])) {
$input_server_name = $parameters['input_server_name']; $input_server_name = $parameters['input_server_name'];
} }
$input_id_server_name = uniqid('server_'); //Default value
if (isset($parameters['input_id_server_id'])) {
$input_id_server_id = $parameters['input_id_server_id'];
}
$input_server_id = 'hidden-' . $input_server_name; //Default value $input_server_id = 'hidden-' . $input_server_name; //Default value
if (isset($parameters['input_server_id'])) { if (isset($parameters['input_server_id'])) {
$input_server_id = $parameters['input_server_id']; $input_server_id = $parameters['input_server_id'];
} }
$input_id_server_id = 'hidden-' . $input_id_server_name; //Default value
if (isset($parameters['input_id_server_id'])) {
$input_id_server_id = $parameters['input_id_server_id'];
}
$input_server_value = ''; //Default value $input_server_value = ''; //Default value
if (isset($parameters['input_server_value'])) { if (isset($parameters['input_server_value'])) {
$input_server_value = $parameters['input_server_value']; $input_server_value = $parameters['input_server_value'];
} }
$input_id_server_value = ''; //Default value
if (isset($parameters['input_id_server_value'])) {
$input_id_server_value = $parameters['input_id_server_value'];
}
$metaconsole_enabled = false; //Default value $metaconsole_enabled = false; //Default value
if (isset($parameters['metaconsole_enabled'])) { if (isset($parameters['metaconsole_enabled'])) {
$metaconsole_enabled = $parameters['metaconsole_enabled']; $metaconsole_enabled = $parameters['metaconsole_enabled'];
@ -2507,6 +2560,12 @@ function ui_print_agent_autocomplete_input($parameters) {
$metaconsole_enabled = false; $metaconsole_enabled = false;
} }
$spinner_image = html_print_image('images/spinner.gif', true, false, true);
if (isset($parameters['spinner_image'])) {
$spinner_image = $parameters['spinner_image'];
}
// Javascript configurations // Javascript configurations
//------------------------------------------------------------------ //------------------------------------------------------------------
$javascript_ajax_page = ui_get_full_url('ajax.php', false, false, false, false); //Default value $javascript_ajax_page = ui_get_full_url('ajax.php', false, false, false, false); //Default value
@ -2514,6 +2573,8 @@ function ui_print_agent_autocomplete_input($parameters) {
$javascript_ajax_page = $parameters['javascript_ajax_page']; $javascript_ajax_page = $parameters['javascript_ajax_page'];
} }
$javascript_function_action_after_select = ''; //Default value $javascript_function_action_after_select = ''; //Default value
$javascript_function_action_after_select_js_call = ''; //Default value $javascript_function_action_after_select_js_call = ''; //Default value
if (isset($parameters['javascript_function_action_after_select'])) { if (isset($parameters['javascript_function_action_after_select'])) {
@ -2522,6 +2583,8 @@ function ui_print_agent_autocomplete_input($parameters) {
$javascript_function_action_after_select . '();'; $javascript_function_action_after_select . '();';
} }
if (isset($parameters['javascript_function_action_after_select_js_call'])) { if (isset($parameters['javascript_function_action_after_select_js_call'])) {
if ($javascript_function_action_after_select_js_call != if ($javascript_function_action_after_select_js_call !=
$parameters['javascript_function_action_after_select_js_call']) { $parameters['javascript_function_action_after_select_js_call']) {
@ -2530,6 +2593,8 @@ function ui_print_agent_autocomplete_input($parameters) {
} }
} }
$javascript_function_action_into_source = ''; //Default value $javascript_function_action_into_source = ''; //Default value
$javascript_function_action_into_source_js_call = ''; //Default value $javascript_function_action_into_source_js_call = ''; //Default value
if (isset($parameters['javascript_function_action_into_source'])) { if (isset($parameters['javascript_function_action_into_source'])) {
@ -2538,6 +2603,8 @@ function ui_print_agent_autocomplete_input($parameters) {
$javascript_function_action_into_source . '();'; $javascript_function_action_into_source . '();';
} }
if (isset($parameters['javascript_function_action_into_source_js_call'])) { if (isset($parameters['javascript_function_action_into_source_js_call'])) {
if ($javascript_function_action_into_source_js_call != if ($javascript_function_action_into_source_js_call !=
$parameters['javascript_function_action_into_source_js_call']) { $parameters['javascript_function_action_into_source_js_call']) {
@ -2546,23 +2613,30 @@ function ui_print_agent_autocomplete_input($parameters) {
} }
} }
$javascript = true; //Default value $javascript = true; //Default value
if (isset($parameters['javascript'])) { if (isset($parameters['javascript'])) {
$javascript = $parameters['javascript']; $javascript = $parameters['javascript'];
} }
$javascript_is_function_select = false; //Default value $javascript_is_function_select = false; //Default value
if (isset($parameters['javascript_is_function_select'])) { if (isset($parameters['javascript_is_function_select'])) {
$javascript_is_function_select = $parameters['javascript_is_function_select']; $javascript_is_function_select = $parameters['javascript_is_function_select'];
} }
$javascript_name_function_select = 'function_select_' . $input_name; //Default value $javascript_name_function_select = 'function_select_' . $input_name; //Default value
if (isset($parameters['javascript_name_function_select'])) { if (isset($parameters['javascript_name_function_select'])) {
$javascript_name_function_select = $parameters['javascript_name_function_select']; $javascript_name_function_select = $parameters['javascript_name_function_select'];
} }
$javascript_code_function_select = '';
$javascript_code_function_select .= '
$javascript_code_function_select = '
function function_select_' . $input_name . '(agent_name) { function function_select_' . $input_name . '(agent_name) {
$("#' . $selectbox_id . '").empty (); $("#' . $selectbox_id . '").empty ();
@ -2578,9 +2652,18 @@ function ui_print_agent_autocomplete_input($parameters) {
} }
if (' . ((int)$metaconsole_enabled) . ') { if (' . ((int)$metaconsole_enabled) . ') {
if ((' . ((int)$use_input_server) . ')
|| (' . ((int)$print_input_server) . ')) {
inputs.push ("server_name=" + $("#' . $input_server_id . '").val()); inputs.push ("server_name=" + $("#' . $input_server_id . '").val());
} }
if ((' . ((int)$use_input_id_server) . ')
|| (' . ((int)$print_input_id_server) . ')) {
inputs.push ("server_id=" + $("#' . $input_id_server_id . '").val());
}
}
if ((' . ((int)$print_hidden_input_idagent) . ') if ((' . ((int)$print_hidden_input_idagent) . ')
|| (' . ((int)$use_hidden_input_idagent) . ')) { || (' . ((int)$use_hidden_input_idagent) . ')) {
@ -2619,13 +2702,19 @@ function ui_print_agent_autocomplete_input($parameters) {
$javascript_code_function_select = $parameters['javascript_code_function_select']; $javascript_code_function_select = $parameters['javascript_code_function_select'];
} }
//============ INIT javascript_change_ajax_params ==================
//Default value //Default value
$javascript_page = 'include/ajax/agent'; $javascript_page = 'include/ajax/agent';
if (isset($parameters['javascript_page'])) { if (isset($parameters['javascript_page'])) {
$javascript_page = $parameters['javascript_page']; $javascript_page = $parameters['javascript_page'];
} }
$javascript_change_ajax_params_original = array('page' => '"' . $javascript_page . '"',
$javascript_change_ajax_params_original = array(
'page' => '"' . $javascript_page . '"',
'search_agents' => 1, 'search_agents' => 1,
'id_group' => 'function() { 'id_group' => 'function() {
var group_id = 0; var group_id = 0;
@ -2676,12 +2765,10 @@ function ui_print_agent_autocomplete_input($parameters) {
$javascript_change_ajax_params_text .= '"' . $key . '":' . $param_ajax; $javascript_change_ajax_params_text .= '"' . $key . '":' . $param_ajax;
} }
$javascript_change_ajax_params_text .= '};'; $javascript_change_ajax_params_text .= '};';
//============ END javascript_change_ajax_params ===================
$spinner_image = html_print_image('images/spinner.gif', true, false, true);
$javascript_function_change = ''; //Default value $javascript_function_change = ''; //Default value
$javascript_function_change .=' $javascript_function_change .='
function set_functions_change_autocomplete_' . $input_name . '() { function set_functions_change_autocomplete_' . $input_name . '() {
@ -2714,7 +2801,7 @@ function ui_print_agent_autocomplete_input($parameters) {
else { else {
//Check if other terms cached start with same //Check if other terms cached start with same
//letters. //letters.
//TODO: At the moment disabled //TODO: At the moment DISABLED CODE
/* /*
for (i = 1; i < term.length; i++) { for (i = 1; i < term.length; i++) {
var term_match = term.substr(0, term.length - i); var term_match = term.substr(0, term.length - i);
@ -2772,7 +2859,9 @@ function ui_print_agent_autocomplete_input($parameters) {
select: function( event, ui ) { select: function( event, ui ) {
var agent_name = ui.item.name; var agent_name = ui.item.name;
var agent_id = ui.item.id; var agent_id = ui.item.id;
var server_name; var server_name = "";
var server_id = "";
if (' . ((int)$metaconsole_enabled) . ') { if (' . ((int)$metaconsole_enabled) . ') {
server_name = ui.item.server; server_name = ui.item.server;
@ -2782,6 +2871,12 @@ function ui_print_agent_autocomplete_input($parameters) {
} }
if ((' . ((int)$use_input_id_server) . ')
|| (' . ((int)$print_input_id_server) . ')) {
server_id = ui.item.id_server;
}
//Put the name //Put the name
$(this).val(agent_name); $(this).val(agent_name);
@ -2797,6 +2892,12 @@ function ui_print_agent_autocomplete_input($parameters) {
$("#' . $input_server_id . '").val(server_name); $("#' . $input_server_id . '").val(server_name);
} }
//Put the server id into the hidden input
if ((' . ((int)$use_input_id_server) . ')
|| (' . ((int)$print_input_id_server) . ')) {
$("#' . $input_id_server_id . '").val(server_id);
}
//Call the function to select (example fill the modules) //Call the function to select (example fill the modules)
if (' . ((int)$javascript_is_function_select) . ') { if (' . ((int)$javascript_is_function_select) . ') {
' . $javascript_name_function_select . '(agent_name); ' . $javascript_name_function_select . '(agent_name);
@ -2905,6 +3006,12 @@ function ui_print_agent_autocomplete_input($parameters) {
$("#' . $input_server_id . '").val(""); $("#' . $input_server_id . '").val("");
} }
//Put the server id into the hidden input
if ((' . ((int)$use_input_id_server) . ')
|| (' . ((int)$print_input_id_server) . ')) {
$("#' . $input_id_server_id . '").val("");
}
return; return;
} }
@ -2948,7 +3055,8 @@ function ui_print_agent_autocomplete_input($parameters) {
var agent_name = data[0].name; var agent_name = data[0].name;
var agent_id = data[0].id; var agent_id = data[0].id;
var server_name; var server_name = "";
var server_id = "";
if (' . ((int)$metaconsole_enabled) . ') { if (' . ((int)$metaconsole_enabled) . ') {
server_name = data[0].server; server_name = data[0].server;
@ -2957,6 +3065,11 @@ function ui_print_agent_autocomplete_input($parameters) {
server_name = data[0].ip; server_name = data[0].ip;
} }
if ((' . ((int)$use_input_id_server) . ')
|| (' . ((int)$print_input_id_server) . ')) {
server_id = data[0].id_server;
}
if ((' . ((int)$print_hidden_input_idagent) . ') if ((' . ((int)$print_hidden_input_idagent) . ')
|| (' . ((int)$use_hidden_input_idagent) . ')) { || (' . ((int)$use_hidden_input_idagent) . ')) {
$("#' . $hidden_input_idagent_id . '").val(agent_id); $("#' . $hidden_input_idagent_id . '").val(agent_id);
@ -2968,6 +3081,12 @@ function ui_print_agent_autocomplete_input($parameters) {
$("#' . $input_server_id . '").val(server_name); $("#' . $input_server_id . '").val(server_name);
} }
//Put the server id into the hidden input
if ((' . ((int)$use_input_id_server) . ')
|| (' . ((int)$print_input_id_server) . ')) {
$("#' . $input_id_server_id . '").val(server_id);
}
//Call the function to select (example fill the modules) //Call the function to select (example fill the modules)
if (' . ((int)$javascript_is_function_select) . ') { if (' . ((int)$javascript_is_function_select) . ') {
' . $javascript_name_function_select . '(agent_name); ' . $javascript_name_function_select . '(agent_name);
@ -3021,6 +3140,11 @@ function ui_print_agent_autocomplete_input($parameters) {
$input_server_value, $input_server_id, true); $input_server_value, $input_server_id, true);
} }
if ($print_input_id_server) {
$html .= html_print_input_hidden_extended($input_id_server_name,
$input_id_server_value, $input_id_server_id, true);
}
//Write the javascript //Write the javascript
if ($javascript) { if ($javascript) {
if ($javascript_tags) { if ($javascript_tags) {

View File

@ -319,6 +319,7 @@ if (is_ajax ()) {
$indexed = (bool) get_parameter ('indexed', true); $indexed = (bool) get_parameter ('indexed', true);
$agentName = (string) get_parameter ('agent_name', null); $agentName = (string) get_parameter ('agent_name', null);
$server_name = (string) get_parameter ('server_name', null); $server_name = (string) get_parameter ('server_name', null);
$server_id = (int) get_parameter ('server_id', 0);
/* This will force to get local modules although metaconsole is active, by default get all modules from all nodes */ /* This will force to get local modules although metaconsole is active, by default get all modules from all nodes */
$force_local_modules = (int) get_parameter ('force_local_modules', 0); $force_local_modules = (int) get_parameter ('force_local_modules', 0);
@ -333,19 +334,21 @@ if (is_ajax ()) {
if (enterprise_include_once ('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { if (enterprise_include_once ('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) {
$connection = metaconsole_get_connection($server_name); $connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) == NOERR) { if ($server_id > 0) {
$connection = metaconsole_get_connection_by_id($server_id);
}
if (metaconsole_load_external_db($connection) == NOERR) {
/* Get all agents if no agent was given */ /* Get all agents if no agent was given */
if ($id_agent == 0) if ($id_agent == 0)
$id_agent = array_keys ( $id_agent = array_keys (
agents_get_group_agents ( agents_get_group_agents (
array_keys (users_get_groups ()), $search, "none")); array_keys (users_get_groups ()), $search, "none"));
$agent_modules = agents_get_modules ($id_agent, $agent_modules = agents_get_modules ($id_agent,
($fields != '' ? explode (',', $fields) : "*"), ($fields != '' ? explode (',', $fields) : "*"),
($filter != '' ? $filter : false), $indexed); ($filter != '' ? $filter : false), $indexed);
} }
// Restore db connection // Restore db connection
metaconsole_restore_db(); metaconsole_restore_db();