From 8a1deb4b87b86133e92a7255161d5b3dd0e76707 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 19 Aug 2016 12:46:27 +0200 Subject: [PATCH] add graph agent new feature ticket integria: 3722 (cherry picked from commit dcb18bcbd2c2584400243f69515f6b17996dd691) --- pandora_console/include/functions_graph.php | 2 +- .../include/graphs/flot/pandora.flot.js | 26 +++++++++++++++-- .../operation/events/events.build_query.php | 19 ++++++++---- pandora_console/operation/events/events.php | 4 +++ .../operation/events/events_list.php | 29 +++++++++++++++++++ 5 files changed, 72 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 89423b925d..bd57cc32c1 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -3239,7 +3239,7 @@ function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $ho // Draw slicebar graph if ($config['flash_charts']) { - $out = flot_slicesbar_graph($data, $period, $width, $height, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl); + $out = flot_slicesbar_graph($data, $period, $width, $height, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', '', false, $id_agent); } else { $out = slicesbar_graph($data, $period, $width, $height, $colors, $config['fontpath'], $config['round_corner'], $homeurl); diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index ddadcc0d8a..0f6ee15339 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -729,8 +729,7 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, } } -function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumulate_data, intervaltick, water_mark, maxvalue, separator, separator2, graph_javascript) { - +function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumulate_data, intervaltick, water_mark, maxvalue, separator, separator2, graph_javascript, id_agent) { values = values.split(separator2); labels = labels.split(separator); legend = legend.split(separator); @@ -765,6 +764,7 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul }, grid: { hoverable: true, + clickable: true, borderWidth:1, borderColor: '#000', tickColor: '#fff' @@ -805,6 +805,28 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul } }); + $('#'+graph_id).bind('plotclick', function(event, pos, item) { + if (item) { + //from time + var from = legend[item.seriesIndex]; + //to time + var to = legend[item.seriesIndex+1]; + //current date + var dateObj = new Date(); + var month = dateObj.getUTCMonth() + 1; //months from 1-12 + var day = dateObj.getUTCDate(); + var year = dateObj.getUTCFullYear(); + newdate = year + "/" + month + "/" + day; + + if(!to){ + to= '12:00'; + } + window.location='index.php?sec=eventos&sec2=operation/events/events&id_agent='+id_agent+'&date_from='+newdate+'&time_from='+from+'&date_to='+newdate+'&time_to='+to+'&status=-1'; + } + }); + + + $('#'+graph_id).bind('mouseout',resetInteractivity); // Reset interactivity styles diff --git a/pandora_console/operation/events/events.build_query.php b/pandora_console/operation/events/events.build_query.php index dd01e94370..d66728be3b 100755 --- a/pandora_console/operation/events/events.build_query.php +++ b/pandora_console/operation/events/events.build_query.php @@ -166,13 +166,22 @@ if (($date_from == '') && ($date_to == '')) { } else { if ($date_from != '') { - $udate_from = strtotime($date_from . " 00:00:00"); - $sql_post .= " AND (utimestamp >= " . $udate_from . ")"; - + if($time_from != '') { + $udate_from = strtotime($date_from . " " . $time_from); + $sql_post .= " AND (utimestamp >= " . $udate_from . ")"; + } else { + $udate_from = strtotime($date_from . " 00:00:00"); + $sql_post .= " AND (utimestamp >= " . $udate_from . ")"; + } } if ($date_to != '') { - $udate_to = strtotime($date_to . " 23:59:59"); - $sql_post .= " AND (utimestamp <= " . $udate_to . ")"; + if($time_to != '') { + $udate_to = strtotime($date_to . " " . $time_to); + $sql_post .= " AND (utimestamp <= " . $udate_to . ")"; + } else { + $udate_to = strtotime($date_to . " 23:59:59"); + $sql_post .= " AND (utimestamp <= " . $udate_to . ")"; + } } } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 358cf27fdc..b7d3ce10a7 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -220,6 +220,8 @@ $id_name = (string) get_parameter('id_name', ''); $open_filter = (int) get_parameter('open_filter', 0); $date_from = (string)get_parameter('date_from', ''); $date_to = (string)get_parameter('date_to', ''); +$time_from = (string)get_parameter('time_from', ''); +$time_to = (string)get_parameter('time_to', ''); $server_id = (int)get_parameter('server_id', 0); $text_agent = (string) get_parameter("text_agent"); @@ -295,6 +297,8 @@ $params = "search=" . rawurlencode(io_safe_input($search)) . "&open_filter=" . $open_filter . "&date_from=" . $date_from . "&date_to=" . $date_to . + "&time_from=" . $time_from . + "&time_to=" . $time_to . "&pure=" . $config["pure"]; if ($meta) { diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index 0a75e74bda..1801bf1195 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -478,6 +478,15 @@ $data[1] .= html_print_input_text ('date_to', $date_to, '', 15, 10, true); $table_advanced->data[] = $data; $table_advanced->rowclass[] = ''; +$data[0] = __('Timestamp from:') . $jump; +$data[0] .= html_print_input_text('time_from', $time_from, '', 9, 7, true); + +$data[1] = __('Timestamp to:') . $jump; +$data[1] .= html_print_input_text('time_to', $time_to, '', 9, 7, true); + +$table_advanced->data[] = $data; +$table_advanced->rowclass[] = ''; + $data = array(); if (defined('METACONSOLE')) { @@ -1476,4 +1485,24 @@ function show_events_graph_dialog() { .show (); } /* ]]> */ + +//function datetime +function datetime_picker_callback() { + + $("#text-time_from, #text-time_to").timepicker({ + showSecond: true, + timeFormat: '', + timeOnlyTitle: '', + timeText: '', + hourText: '', + minuteText: '', + secondText: '', + currentText: '', + closeText: ''}); + + $("#text-date_from, #text-date_to").datepicker({dateFormat: ""}); + + $.datepicker.setDefaults($.datepicker.regional[ ""]); +} +datetime_picker_callback();