2012-09-14 Miguel de Dios <miguel.dedios@artica.es>

* include/javascript/pandora.js,
	extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql: cleaned source code
	style.
	
	* godmode/agentes/module_manager_editor_prediction.php,
	godmode/reporting/visual_console_builder.elements.php,
	godmode/reporting/reporting_builder.php,
	godmode/reporting/reporting_builder.item_editor.php,
	include/functions_ui.php: started to use the new function
	"ui_print_agent_autocomplete_input" to make more easy (and standar)
	the autocomplete agent input.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6975 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-09-14 17:54:33 +00:00
parent 8afc508476
commit 38411e1f7c
8 changed files with 225 additions and 181 deletions

View File

@ -1,3 +1,17 @@
2012-09-14 Miguel de Dios <miguel.dedios@artica.es>
* include/javascript/pandora.js,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql: cleaned source code
style.
* godmode/agentes/module_manager_editor_prediction.php,
godmode/reporting/visual_console_builder.elements.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php: started to use the new function
"ui_print_agent_autocomplete_input" to make more easy (and standar)
the autocomplete agent input.
2012-09-13 Miguel de Dios <miguel.dedios@artica.es>
* operation/incidents/incident_detail.php,

View File

@ -1,6 +1,6 @@
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `tnetflow_filter`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tnetflow_filter` (
`id_sg` int(10) unsigned NOT NULL auto_increment,
`id_name` varchar(600) NOT NULL default '0',
@ -16,9 +16,9 @@ CREATE TABLE IF NOT EXISTS `tnetflow_filter` (
PRIMARY KEY (`id_sg`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `tnetflow_report`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tnetflow_report` (
`id_report` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`id_name` varchar(150) NOT NULL default '',
@ -27,9 +27,9 @@ CREATE TABLE IF NOT EXISTS `tnetflow_report` (
PRIMARY KEY(`id_report`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `tnetflow_report_content`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tnetflow_report_content` (
`id_rc` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`id_report` INTEGER UNSIGNED NOT NULL default 0,
@ -46,20 +46,20 @@ CREATE TABLE IF NOT EXISTS `tnetflow_report_content` (
ON DELETE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `tincidencia`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
ALTER TABLE `tincidencia` ADD COLUMN `id_agent` int(10) unsigned NULL default 0;
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `tagente`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
ALTER TABLE `tagente` ADD COLUMN `url_address` mediumtext NULL;
ALTER TABLE `tagente` ADD COLUMN `quiet` tinyint(1) NOT NULL DEFAULT '0';
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `talert_special_days`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `talert_special_days` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`date` date NOT NULL DEFAULT '0000-00-00',
@ -68,9 +68,9 @@ CREATE TABLE IF NOT EXISTS `talert_special_days` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `talert_templates`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
ALTER TABLE `talert_templates` ADD COLUMN `special_day` tinyint(1) DEFAULT '0';
-- -----------------------------------------------------

View File

@ -23,7 +23,9 @@ $id_agente = get_parameter('id_agente', '');
$agent_name = get_parameter('agent_name', agents_get_name($id_agente));
$id_agente_modulo= get_parameter('id_agent_module',0);
$custom_integer_2 = get_parameter ('custom_integer_2', 0);
$sql = 'SELECT * FROM tagente_modulo WHERE id_agente_modulo = '.$id_agente_modulo;
$sql = 'SELECT *
FROM tagente_modulo
WHERE id_agente_modulo = '.$id_agente_modulo;
$row = db_get_row_sql($sql);
$is_service = false;
$is_synthetic = false;
@ -96,15 +98,26 @@ if ($module_service_synthetic_selector !== ENTERPRISE_NOT_HOOK) {
$data[0] = '';
}
$data[1] = '<div id="module_data" style="top:1em; float:left; width:50%;">';
$data[1] .= html_print_label(__("Agent"),'agent_name', true)."<br/>";
$sql = "SELECT id_agente, nombre FROM tagente";
// TODO: ACL Filter
//Image src with skins
$src_code = html_print_image('images/lightning.png', true, false, true);
$data[1] .= html_print_input_text_extended ('agent_name',$agent_name, 'text_agent_name', '', 30, 100, $is_service, '',
array('style' => 'background: url(' . $src_code . ') no-repeat right;'), true, false);
$data[1] .= '<a href="#" class="tip">&nbsp;<span>' . __("Type at least two characters to search") . '</span></a>&nbsp; <br/>';
$params = array();
$params['return'] = true;
$params['show_helptip'] = true;
$params['input_name'] = 'agent_name';
$params['value'] = $agent_name;
$params['javascript_is_function_select'] = true;
$params['selectbox_id'] = 'prediction_module';
$params['none_module_text'] = __('Select Module');
$params['use_hidden_input_idagent'] = true;
$params['hidden_input_idagent_id'] = 'hidden-id_agente';
$data[1] .= ui_print_agent_autocomplete_input($params);
$data[1] .= html_print_label(__("Module"),'prediction_module',true);
if($id_agente) {
$sql = "SELECT id_agente_modulo, nombre
@ -170,7 +183,6 @@ unset ($table_advanced->data[3]);
?>
<script type="text/javascript">
$(document).ready(function() {
agent_module_autocomplete ("#text_agent_name", "#id_agente", "#prediction_module");
<?php
enterprise_hook('setup_services_synth', array($is_service, $is_synthetic, $is_synthetic_avg, $is_netflow, $ops));
?>

View File

@ -502,12 +502,23 @@ html_print_input_hidden('id_item', $idItem);
else {
$agent_name = agents_get_name ($idAgent);
}
html_print_input_hidden('id_agent', $idAgent) .
html_print_input_text_extended ('agent', $agent_name,
'text-agent', '', 30, 100, false, '',
array('style' => 'background: url(images/lightning.png) no-repeat right;'))
. ui_print_help_tip(__("Type at least two characters to search"), false);
html_print_input_hidden('id_agent', $idAgent);
html_print_input_hidden ('server_name', $server_name);
$params = array();
$params['show_helptip'] = true;
$params['input_name'] = 'agent';
$params['value'] = $agent_name;
$params['javascript_is_function_select'] = true;
$params['selectbox_id'] = 'id_agent_module';
$params['add_none_module'] = false;
$params['use_hidden_input_idagent'] = true;
$params['hidden_input_idagent_id'] = 'hidden-id_agent';
$params['use_input_server'] = true;
$params['input_server_id'] = 'hidden-server_name';
ui_print_agent_autocomplete_input($params);
?>
</td>
</tr>
@ -659,12 +670,14 @@ html_print_input_hidden('id_item', $idItem);
</tr>
<tr id="row_servers" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Server'); ?></td>
<td style=""><?php
<td style="">
<?php
if ($config ['metaconsole'] != 1 or !defined('METACONSOLE'))
html_print_select ($servers, 'combo_server', $server_name, '', __('Select server'), 0, false, false, true, '', true);
else
html_print_select ($servers, 'combo_server', $server_name, '', __('Select server'), 0);
?></td>
?>
</td>
</tr>
<tr id="row_header" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Serialized header') . ui_print_help_tip(__("The separator character is |"), true);?></td>
@ -696,14 +709,16 @@ html_print_input_hidden('id_item', $idItem);
</tr>
<tr id="row_order_uptodown" style="" class="datos">
<td><?php echo __('Order');?></td>
<td><?php
<td>
<?php
echo __('Ascending');
html_print_radio_button ('radiobutton_order_uptodown', 2, '', $order_uptodown);
echo __('Descending');
html_print_radio_button ('radiobutton_order_uptodown', 1, '', $order_uptodown);
echo __('By agent name');
html_print_radio_button ('radiobutton_order_uptodown', 3, '', $order_uptodown);
?></td>
?>
</td>
</tr>
<tr id="row_quantity" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Quantity (n)'); ?></td>
@ -711,14 +726,16 @@ html_print_input_hidden('id_item', $idItem);
</tr>
<tr id="row_max_min_avg" style="" class="datos">
<td><?php echo __('Display');?></td>
<td><?php
<td>
<?php
echo __('Max');
html_print_radio_button ('radiobutton_max_min_avg', 1, '', $top_n);
echo __('Min');
html_print_radio_button ('radiobutton_max_min_avg', 2, '', $top_n);
echo __('Avg');
html_print_radio_button ('radiobutton_max_min_avg', 3, '', $top_n);
?></td>
?>
</td>
</tr>
<tr id="row_exception_condition_value" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Value'); ?></td>
@ -868,7 +885,20 @@ function print_SLA_list($width, $action, $idItem = null) {
<td>
<input id="hidden-id_agent_sla" name="id_agent_sla" value="" type="hidden">
<input id="hidden-server_name" name="server_name" value="" type="hidden">
<input style="background: transparent url(images/lightning.png) no-repeat right;" name="agent_sla" id="text-agent_sla" size="15" maxlength="20" type="text"><a href="#" class="tip">&nbsp;<span>Type at least two characters to search</span></a></td>
<?php
$params = array();
$params['show_helptip'] = true;
$params['input_name'] = 'agent_sla';
$params['value'] = '';
$params['use_hidden_input_idagent'] = true;
$params['hidden_input_idagent_id'] = 'hidden-id_agent_sla';
$params['javascript_is_function_select'] = true;
$params['selectbox_id'] = 'id_agent_module_sla';
$params['add_none_module'] = false;
$params['use_input_server'] = true;
$params['input_server_id'] = 'hidden-server_name';
ui_print_agent_autocomplete_input($params);
?>
<td><select id="id_agent_module_sla" name="id_agente_modulo_sla" disabled="disabled" style="max-width: 180px"><option value="0"><?php echo __('Select an Agent first'); ?></option></select></td>
<td><input name="sla_min" id="text-sla_min" size="10" maxlength="10" type="text"></td>
<td><input name="sla_max" id="text-sla_max" size="10" maxlength="10" type="text"></td>
@ -963,10 +993,24 @@ function print_General_list($width, $action, $idItem = null) {
<td>
<input id="hidden-id_agent_general" name="id_agent_general" value="" type="hidden">
<input id="hidden-server_name_general" name="server_name_general" value="" type="hidden">
<input style="background: transparent url(images/lightning.png) no-repeat right;" name="agent_general" id="text-agent_general" size="15" maxlength="20" type="text"><a href="#" class="tip">&nbsp;<span>Type at least two characters to search</span></a></td>
<?php
$params = array();
$params['show_helptip'] = true;
$params['input_name'] = 'agent_general';
$params['value'] = '';
$params['use_hidden_input_idagent'] = true;
$params['hidden_input_idagent_id'] = 'hidden-id_agent_general';
$params['javascript_is_function_select'] = true;
$params['selectbox_id'] = 'id_agent_module_general';
$params['add_none_module'] = false;
$params['use_input_server'] = true;
$params['input_server_id'] = 'hidden-server_name_general';
ui_print_agent_autocomplete_input($params);
?>
</td>
<td><select id="id_agent_module_general" name="id_agente_modulo_general" disabled="disabled" style="max-width: 180px"><option value="0"><?php echo __('Select an Agent first'); ?></option></select></td>
<?php $operation = array ('avg'=>'avg','max'=>'max','min'=>'min','sum'=>'sum'); ?>
<td><?php html_print_select ($operation, 'id_operation_module_general', 0, false, '', '', false, false, true, 'width: 200px', true); ?></td>
<td><?php html_print_select ($operation, 'id_operation_module_general', 0, false, '', '', false, false, true, 'width: 200px', false); ?></td>
<td style="text-align: center;"><a href="javascript: addGeneralRow();"><?php html_print_image("images/disk.png", false); ?></a></td>
</tr>
</tbody>
@ -986,10 +1030,6 @@ ui_require_javascript_file ('pandora_inventory', ENTERPRISE_DIR.'/include/javasc
?>
<script type="text/javascript">
$(document).ready (function () {
agent_module_autocomplete('#text-agent', '#hidden-id_agent', '#id_agent_module', '#hidden-server_name', undefined, <?php echo '"' . ui_get_full_url(false) . '"'; ?>);
agent_module_autocomplete('#text-agent_sla', '#hidden-id_agent_sla', '#id_agent_module_sla', '#hidden-server_name', undefined, <?php echo '"' . ui_get_full_url(false) . '"'; ?>);
agent_module_autocomplete('#text-agent_general', '#hidden-id_agent_general', '#id_agent_module_general', '#hidden-server_name_general', '#id_operation_module_general', <?php echo '"' . ui_get_full_url(false) . '"'; ?>);
chooseType();
chooseSQLquery();

View File

@ -196,7 +196,8 @@ switch ($action) {
case 'above':
if ($position_to_delete == 1) {
$resultOperationDB = false;
} else {
}
else {
$i = 1;
foreach ($items as $key => $item) {
if ($i < $position_to_delete) {
@ -209,11 +210,15 @@ switch ($action) {
case 'below':
if ($position_to_delete == $countItems) {
$resultOperationDB = false;
} else {
}
else {
$i = 1;
foreach ($items as $key => $item) {
if ($i > $position_to_delete) {
$resultOperationDB = db_process_sql_delete('treport_content', array('id_rc' => $item['id_rc']));
$resultOperationDB =
db_process_sql_delete(
'treport_content',
array('id_rc' => $item['id_rc']));
}
$i++;
}
@ -248,7 +253,10 @@ switch ($action) {
// Page header for metaconsole
if ($enterpriseEnable and defined('METACONSOLE')) {
// Bread crumbs
ui_meta_add_breadcrumb(array('link' => 'index.php?sec=reporting&sec2=' . $config['homedir'] . '/godmode/reporting/reporting_builder', 'text' => __('Reporting')));
ui_meta_add_breadcrumb(
array(
'link' => 'index.php?sec=reporting&sec2=' . $config['homedir'] . '/godmode/reporting/reporting_builder',
'text' => __('Reporting')));
ui_meta_print_page_header($nav_bar);
@ -1044,11 +1052,9 @@ switch ($action) {
}
// Sort functionality for metaconsole
else if ($config['metaconsole'] == 1) {
switch ($field) {
case 'agent':
case 'module':
$sql = "SELECT id_rc, id_agent, id_agent_module, server_name FROM treport_content WHERE %s ORDER BY server_name";
$sql = sprintf($sql, 'id_report = ' . $idReport, '%s');

View File

@ -184,9 +184,14 @@ foreach ($layoutDatas as $layoutData) {
$cell_content_enterprise = enterprise_visual_map_print_list_element('agent', $layoutData);
}
if ($cell_content_enterprise === false) {
$table->data[$i + 2][0] = '<a href="#" class="tip">&nbsp;<span>' . __("Type at least two characters to search.") . '</span></a>' .
html_print_input_text_extended ('agent_' . $idLayoutData, agents_get_name($layoutData['id_agent']), 'text-agent_' . $idLayoutData, '', 15, 100, false, '',
array('class' => 'text-agent', 'style' => 'background: #ffffff url(images/lightning.png) no-repeat right;'), true);
$params = array();
$params['return'] = true;
$params['show_helptip'] = true;
$params['input_name'] = 'agent_' . $idLayoutData;
$params['value'] = agents_get_name($layoutData['id_agent']);
$params['javascript_is_function_select'] = true;
$params['selectbox_id'] = 'module_' . $idLayoutData;
$table->data[$i + 2][0] = ui_print_agent_autocomplete_input($params);
}
else {
$table->data[$i + 2][0] = $cell_content_enterprise;
@ -281,8 +286,8 @@ ui_require_javascript_file ('wz_jsgraphics');
ui_require_javascript_file ('pandora_visual_console');
ui_require_jquery_file('ajaxqueue');
ui_require_jquery_file('bgiframe');
ui_require_jquery_file('autocomplete');
?>
<script type="text/javascript">
$(document).ready (function () {
$(".label_color").attachColorPicker();
@ -290,63 +295,4 @@ $(document).ready (function () {
});
var idText = $("#ip_text").html();
$(".text-agent").autocomplete(
"ajax.php",
{
minChars: 2,
scroll:true,
extraParams: {
page: "operation/agentes/exportdata",
all: "enabled",
search_agents: 1,
id_group: function() { return $("#group").val(); }
},
formatItem: function (data, i, total) {
if (total == 0)
$(".text-agent").css ('background-color', '#cc0000');
else
$(".text-agent").css ('background-color', '');
if (data == "")
return false;
return data[0]+'<br><span class="ac_extra_field">' + idText + ': '+data[1]+'</span>';
},
delay: 200
}
);
$(".text-agent").result (
function (event, data, formatted) {
var id = $(this).attr('id').replace('text-agent_', '');
selectAgent = true;
var agent_name = this.value;
$('#module_' + id).fadeOut ('normal', function () {
$('#module_' + id).empty ();
var inputs = [];
inputs.push ("filter=disabled = 0");
inputs.push ("agent_name=" + agent_name);
inputs.push ("get_agent_modules_json=1");
inputs.push ("page=operation/agentes/ver_agente");
jQuery.ajax ({
data: inputs.join ("&"),
type: 'GET',
url: action="ajax.php",
timeout: 10000,
dataType: 'json',
success: function (data) {
$('#module_' + id).append ($('<option></option>').attr ('value', 0).text ("--"));
jQuery.each (data, function (i, val) {
s = js_html_entity_decode (val['nombre']);
$('#module_' + id).append ($('<option></option>').attr ('value', val['id_agente_modulo']).text (s));
});
$('#module_' + id).fadeIn ('normal');
}
});
});
}
);
</script>

View File

@ -2073,6 +2073,11 @@ function ui_print_agent_autocomplete_input($parameters) {
$helptip_text = $parameters['helptip_text'];
}
$use_hidden_input_idagent = false; //Default value
if (isset($parameters['use_hidden_input_idagent'])) {
$use_hidden_input_idagent = $parameters['use_hidden_input_idagent'];
}
$print_hidden_input_idagent = false; //Default value
if (isset($parameters['print_hidden_input_idagent'])) {
$print_hidden_input_idagent = $parameters['print_hidden_input_idagent'];
@ -2085,7 +2090,7 @@ function ui_print_agent_autocomplete_input($parameters) {
$hidden_input_idagent_id = 'hidden-' . $input_name; //Default value
if (isset($parameters['hidden_input_idagent_id'])) {
$hidden_input_idagent_name = $parameters['hidden_input_idagent_id'];
$hidden_input_idagent_id = $parameters['hidden_input_idagent_id'];
}
$hidden_input_idagent_value = 0; //Default value
@ -2118,6 +2123,21 @@ function ui_print_agent_autocomplete_input($parameters) {
$add_none_module = $parameters['add_none_module'];
}
$none_module_text = '--'; //Default value
if (isset($parameters['none_module_text'])) {
$none_module_text = $parameters['none_module_text'];
}
$use_input_server = false; //Default value
if (isset($parameters['use_input_server'])) {
$use_input_server = $parameters['use_input_server'];
}
$input_server_id = false; //Default value
if (isset($parameters['input_server_id'])) {
$input_server_id = $parameters['input_server_id'];
}
// Javascript configurations
//-----------------------------------------
$javascript = true; //Default value
@ -2157,7 +2177,7 @@ function ui_print_agent_autocomplete_input($parameters) {
if (' . ((int)$add_none_module) . ') {
$("#' . $selectbox_id . '")
.append($("<option></option>")
.attr("value", 0).text("--"));
.attr("value", 0).text("' . $none_module_text . '"));
}
jQuery.each (data, function(i, val) {
@ -2226,6 +2246,7 @@ function ui_print_agent_autocomplete_input($parameters) {
select: function( event, ui ) {
var agent_name = ui.item.name;
var agent_id = ui.item.id;
var server_name = ui.item.ip;
//Put the name
$(this).val(agent_name);
@ -2234,10 +2255,15 @@ function ui_print_agent_autocomplete_input($parameters) {
' . $javascript_name_function_select . '(agent_name);
}
if (' . ((int)$print_hidden_input_idagent) . ') {
if ((' . ((int)$print_hidden_input_idagent) . ')
|| (' . ((int)$use_hidden_input_idagent) . ')) {
$("#' . $hidden_input_idagent_id . '").val(agent_id);
}
if (' . ((int)$use_input_server) . ') {
$("#' . $input_server_id . '").val(server_name);
}
return false;
}
})