From 2adf9511218f10a30cd11cc9f881ae0c937a16f7 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 30 Oct 2017 15:45:31 +0100 Subject: [PATCH] Added free search values to data table --- pandora_console/include/ajax/module.php | 22 ++++++++++++------- pandora_console/include/functions_modules.php | 20 +++++++++++------ .../operation/agentes/estado_monitores.php | 6 +++++ 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 32de285b11..a174c84ba5 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -123,12 +123,16 @@ if ($get_module_detail) { $time_from = (string) get_parameter ('time_from', date ('h:iA')); $date_to = (string) get_parameter ('date_to', date ('Y-m-j')); $time_to = (string) get_parameter ('time_to', date ('h:iA')); + $freesearch = (string) get_parameter ('freesearch', ''); $formtable->width = '98%'; $formtable->class = "databox"; $formtable->data = array (); $formtable->size = array (); + $moduletype_name = modules_get_moduletype_name( + modules_get_agentmodule_type($module_id)); + $periods = array(SECONDS_5MINUTES =>__('5 minutes'), SECONDS_30MINUTES =>__('30 minutes'), SECONDS_1HOUR =>__('1 hour'), @@ -148,13 +152,18 @@ if ($get_module_detail) { "selection_mode", 'fromnow', '', $selection_mode, false, '', 'style="margin-right: 15px;"', true) . __("Choose a time from now"); $formtable->data[0][1] = html_print_select ($periods, 'period', $period, '', '', 0, true, false, false); - $formtable->data[0][2] = ''; + if (preg_match("/_string/", $moduletype_name)) { + $formtable->data[0][2] = __('Free search') . ' '; + $formtable->data[0][2] .= html_print_input_text ('freesearch', $freesearch, '', 25, null, true); + } else { + $freesearch = ''; + $formtable->data[0][2] = ''; + } + $formtable->cellstyle[0][3] = 'vertical-align: middle;'; $formtable->data[0][3] = "" . html_print_image ("images/refresh.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . ""; - $formtable->rowspan[0][3] = 2; - $formtable->cellstyle[0][3] = 'vertical-align: middle;'; $formtable->data[1][0] = html_print_radio_button_extended( "selection_mode", 'range','', $selection_mode, false, '', @@ -177,9 +186,6 @@ if ($get_module_detail) { html_print_table($formtable); - $moduletype_name = modules_get_moduletype_name( - modules_get_agentmodule_type($module_id)); - $offset = (int) get_parameter("offset"); $block_size = (int) $config["block_size"]; @@ -222,10 +228,10 @@ if ($get_module_detail) { } $count = modules_get_agentmodule_data ($module_id, $period, - $date, true, $conexion); + $date, true, $conexion, 'ASC', $freesearch); $module_data = modules_get_agentmodule_data ($module_id, $period, - $date, false, $conexion, 'DESC'); + $date, false, $conexion, 'DESC', $freesearch); if (empty($module_data)) { $result = array(); diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index bcdeb6819c..0c522ceece 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -1720,7 +1720,8 @@ function modules_get_next_data ($id_agent_module, $utimestamp = 0, $string = 0) * @return array The module value and the timestamp */ function modules_get_agentmodule_data ($id_agent_module, $period, - $date = 0, $trash=false, $conexion = false, $order = 'ASC') { + $date = 0, $trash=false, $conexion = false, $order = 'ASC', + $freesearch = '') { global $config; $module = db_get_row('tagente_modulo', 'id_agente_modulo', @@ -1742,12 +1743,17 @@ function modules_get_agentmodule_data ($id_agent_module, $period, case 17: //async_string case 23: - $sql = sprintf ("SELECT datos AS data, utimestamp - FROM tagente_datos_string - WHERE id_agente_modulo = %d - AND utimestamp > %d AND utimestamp <= %d - ORDER BY utimestamp %s", - $id_agent_module, $datelimit, $date, $order); + $sql = sprintf ( + "SELECT datos AS data, utimestamp FROM tagente_datos_string + WHERE id_agente_modulo = %d + %s + AND utimestamp > %d AND utimestamp <= %d + ORDER BY utimestamp %s", + $id_agent_module, + !empty($freesearch) ? " AND datos REGEXP '" . $freesearch . "' " : "", + $datelimit, $date, + $order + ); break; //log4x case 24: diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index f5c870dc83..0d6e9b8c6b 100755 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -364,6 +364,12 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri extra_parameters = '&selection_mode=' + selection_mode + '&date_from=' + date_from + '&date_to=' + date_to + '&time_from=' + time_from + '&time_to=' + time_to; } + + // Get the free text in both options + var freesearch = $('#text-freesearch').val(); + if (freesearch == null) freesearch = ''; + extra_parameters += '&freesearch=' + freesearch; + title = ; $.ajax({ type: "POST",