From 38411e1f7c6987a6e5f9550c5f6a1146ba3a895e Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Fri, 14 Sep 2012 17:54:33 +0000 Subject: [PATCH] 2012-09-14 Miguel de Dios * 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 --- pandora_console/ChangeLog | 14 ++ .../pandoradb_migrate_4.0.x_to_5.0.mysql.sql | 28 ++-- .../module_manager_editor_prediction.php | 30 ++-- .../reporting_builder.item_editor.php | 138 +++++++++++------- .../godmode/reporting/reporting_builder.php | 78 +++++----- .../visual_console_builder.elements.php | 84 ++--------- pandora_console/include/functions_ui.php | 32 +++- pandora_console/include/javascript/pandora.js | 2 +- 8 files changed, 225 insertions(+), 181 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index d1b0becc63..94308cde06 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,17 @@ +2012-09-14 Miguel de Dios + + * 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 * operation/incidents/incident_detail.php, diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql index bb82084f06..1d0095f216 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql @@ -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'; -- ----------------------------------------------------- diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index 417ae5faab..464605dbb1 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -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] = '
'; $data[1] .= html_print_label(__("Agent"),'agent_name', true)."
"; -$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] .= ' ' . __("Type at least two characters to search") . ' 
'; + +$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]); ?> + \ No newline at end of file diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 99105c68ff..2aa0f92cae 100644 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -184,7 +184,7 @@ switch ($action) { $pos_delete = (string)get_parameter('delete_m', 'below'); $countItems = db_get_sql('SELECT COUNT(id_rc) - FROM treport_content WHERE id_report = ' . $idReport); + FROM treport_content WHERE id_report = ' . $idReport); if (($countItems < $position_to_delete) || ($position_to_delete < 1)) { $resultOperationDB = false; @@ -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,14 +253,17 @@ 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_print_page_header($nav_bar); + 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); // Print header - ui_meta_print_header(__('Reporting'), "", $buttons); + ui_meta_print_header(__('Reporting'), "", $buttons); } - // Page header for normal console + // Page header for normal console else ui_print_page_header (__('Reporting').' » '.__('Custom reporting'), "images/reporting.png", false, "",false, $buttons); @@ -553,7 +561,7 @@ switch ($action) { $metaconsole_report = 1; else $metaconsole_report = 0; - + $idOrResult = db_process_sql_insert('treport', array('name' => $reportName, 'id_group' => $idGroupReport, @@ -1044,11 +1052,9 @@ switch ($action) { } // Sort functionality for metaconsole else if ($config['metaconsole'] == 1) { - switch ($field) { - case 'agent': - case 'module': - + 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'); @@ -1061,14 +1067,14 @@ switch ($action) { if (!empty($report_items)) { foreach ($report_items as $report_item) { - + $connection = metaconsole_get_connection($report_item['server_name']); if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); } - + switch ($field) { - case 'agent': + case 'agent': $agents_name = agents_get_agents(array('id_agente' => $report_item['id_agent']), 'nombre'); // Item without agent @@ -1089,18 +1095,18 @@ switch ($action) { $element_name = ''; else { $element_name = $module_name; - } - + } + break; - } + } metaconsole_restore_db_force(); - - $temp_sort[$report_item['id_rc']] = $element_name; + + $temp_sort[$report_item['id_rc']] = $element_name; } - - // Performes sorting + + // Performes sorting switch ($dir) { case 'up': asort($temp_sort); @@ -1117,9 +1123,9 @@ switch ($action) { } // Free resources - unset($temp_sort); - unset($report_items); - + unset($temp_sort); + unset($report_items); + } break; @@ -1136,15 +1142,15 @@ switch ($action) { $sql = sprintf($sql, 'DESC'); break; } - - $ids = db_get_all_rows_sql($sql); + + $ids = db_get_all_rows_sql($sql); break; } - + } - + $count = 1; $resultOperationDB = true; foreach($ids as $id) { @@ -1157,7 +1163,7 @@ switch ($action) { $count = $count + 1; } - + break; default: switch ($config["dbtype"]) { @@ -1270,7 +1276,7 @@ $buttons = array( 'text' => '' . html_print_image("images/config.png", true, array ("title" => __('Item editor'))) .'') ); - + if ($enterpriseEnable) { $buttons = reporting_enterprise_add_Tabs($buttons, $idReport); } @@ -1278,7 +1284,7 @@ if ($enterpriseEnable) { $buttons['view'] = array('active' => false, 'text' => '' . html_print_image("images/reporting.png", true, array ("title" => __('View report'))) .''); - + $buttons[$activeTab]['active'] = true; if ($idReport != 0) { @@ -1296,11 +1302,11 @@ else { 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_print_page_header($nav_bar); // Print header - ui_meta_print_header(__('Reporting'). $textReportName, "", $buttons); + ui_meta_print_header(__('Reporting'). $textReportName, "", $buttons); } else ui_print_page_header(__('Reporting') . $textReportName, "images/reporting_edit.png", false, "reporting_" . $activeTab . "_tab", true, $buttons); diff --git a/pandora_console/godmode/reporting/visual_console_builder.elements.php b/pandora_console/godmode/reporting/visual_console_builder.elements.php index df6559042c..39e8800da1 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.elements.php +++ b/pandora_console/godmode/reporting/visual_console_builder.elements.php @@ -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] = ' ' . __("Type at least two characters to search.") . '' . - 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,72 +286,13 @@ 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'); ?> + diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index f196d5b1f4..90905cd425 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -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($("") - .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; } }) diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index d85c926f55..2f27cd35d1 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -454,7 +454,7 @@ function agent_module_autocomplete (id_agent_name, id_agent_id, id_agent_module_ homedir_path = ''; if (homedir == undefined) homedir_path = '.'; - else + else homedir_path = homedir; $(id_agent_name).autocomplete({