Added free search values to data table

This commit is contained in:
fermin831 2017-10-30 15:45:31 +01:00
parent 9ecc68bfe7
commit 2adf951121
3 changed files with 33 additions and 15 deletions

View File

@ -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] = "<a href='javascript: show_module_detail_dialog(" . $module_id .", ". $agentId.", \"" . $server_name .
"\", 0, -1,\"" . modules_get_agentmodule_name( $module_id ) . "\")'>" .
html_print_image ("images/refresh.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) .
"</a>";
$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();

View File

@ -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:

View File

@ -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 = <?php echo "\"" . __("Module: ") . "\"" ?>;
$.ajax({
type: "POST",