add graph agent new feature ticket integria: 3722

This commit is contained in:
daniel 2016-08-19 12:46:27 +02:00
parent e32c606fb0
commit dcb18bcbd2
6 changed files with 74 additions and 10 deletions

View File

@ -3319,7 +3319,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);

View File

@ -724,8 +724,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);
@ -760,6 +759,7 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul
},
grid: {
hoverable: true,
clickable: true,
borderWidth:1,
borderColor: '#000',
tickColor: '#fff'
@ -800,6 +800,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

View File

@ -758,7 +758,7 @@ function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $lon
return $return;
}
function flot_slicesbar_graph ($graph_data, $period, $width, $height, $legend, $colors, $fontpath, $round_corner, $homeurl, $watermark = '', $adapt_key = '', $stat_win = false) {
function flot_slicesbar_graph ($graph_data, $period, $width, $height, $legend, $colors, $fontpath, $round_corner, $homeurl, $watermark = '', $adapt_key = '', $stat_win = false, $id_agent = 0) {
global $config;
include_javascript_dependencies_flot_graph();
@ -878,7 +878,7 @@ function flot_slicesbar_graph ($graph_data, $period, $width, $height, $legend, $
// Javascript code
$return .= "<script type='text/javascript'>";
$return .= "//<![CDATA[\n";
$return .= "pandoraFlotSlicebar('$graph_id', '$values', '$datacolor', '$labels', '$legend', '$acumulate_data', $intervaltick, false, $max, '$separator', '$separator2')";
$return .= "pandoraFlotSlicebar('$graph_id', '$values', '$datacolor', '$labels', '$legend', '$acumulate_data', $intervaltick, false, $max, '$separator', '$separator2', '', $id_agent)";
$return .= "\n//]]>";
$return .= "</script>";

View File

@ -160,13 +160,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 . ")";
}
}
}

View File

@ -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)) .
"&amp;open_filter=" . $open_filter .
"&amp;date_from=" . $date_from .
"&amp;date_to=" . $date_to .
"&amp;time_from=" . $time_from .
"&amp;time_to=" . $time_to .
"&amp;pure=" . $config["pure"];
if ($meta) {

View File

@ -481,6 +481,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'))
{
@ -1498,4 +1507,24 @@ function show_events_graph_dialog() {
.show ();
}
/* ]]> */
//function datetime
function datetime_picker_callback() {
$("#text-time_from, #text-time_to").timepicker({
showSecond: true,
timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
timeOnlyTitle: '<?php echo __('Choose time');?>',
timeText: '<?php echo __('Time');?>',
hourText: '<?php echo __('Hour');?>',
minuteText: '<?php echo __('Minute');?>',
secondText: '<?php echo __('Second');?>',
currentText: '<?php echo __('Now');?>',
closeText: '<?php echo __('Close');?>'});
$("#text-date_from, #text-date_to").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
}
datetime_picker_callback();
</script>