From 1b5cadfa43ffe583a16f4eeffb285fd98fee43d9 Mon Sep 17 00:00:00 2001 From: cigamit Date: Sat, 2 Apr 2016 16:25:18 -0500 Subject: [PATCH] make legacy realtime work in mrtg view --- graph_realtime.php | 34 +++++++++++++++++----------------- include/global_arrays.php | 2 +- include/realtime.js | 19 +++++++++++++++---- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/graph_realtime.php b/graph_realtime.php index f254fb0899..971382be8c 100644 --- a/graph_realtime.php +++ b/graph_realtime.php @@ -135,7 +135,7 @@ /* construct the image name */ $graph_data_array['export_realtime'] = read_config_option('realtime_cache_path') . '/user_' . session_id() . '_lgi_' . get_request_var('local_graph_id') . '.png'; - $graph_data_array['output_flag'] = RRDTOOL_OUTPUT_GRAPH_DATA; + $graph_data_array['output_flag'] = RRDTOOL_OUTPUT_GRAPH_DATA; rrdtool_function_graph(get_request_var('local_graph_id'), '', $graph_data_array); @@ -148,11 +148,11 @@ /* send text information back to browser as well as image information */ $return_array = array( 'local_graph_id' => get_request_var('local_graph_id'), - 'top' => get_request_var('top'), - 'left' => get_request_var('left'), - 'ds_step' => (isset($_SESSION['sess_realtime_ds_step']) ? $_SESSION['sess_realtime_ds_step']:$graph_data_array['ds_step']), - 'graph_start' => (isset($_SESSION['sess_realtime_graph_start']) ? $_SESSION['sess_realtime_graph_start']:$graph_data_array['graph_start']), - 'data' => (isset($data) ? $data:'') + 'top' => get_request_var('top'), + 'left' => get_request_var('left'), + 'ds_step' => (isset($_SESSION['sess_realtime_ds_step']) ? $_SESSION['sess_realtime_ds_step']:$graph_data_array['ds_step']), + 'graph_start' => (isset($_SESSION['sess_realtime_graph_start']) ? $_SESSION['sess_realtime_graph_start']:$graph_data_array['graph_start']), + 'data' => (isset($data) ? $data:'') ); print json_encode($return_array); @@ -245,7 +245,7 @@
- Timespan + Window - Interval + Refresh
- seconds left. + seconds left.
@@ -291,36 +291,36 @@ var ds_step = 0; var sizeset = false; var count = 0; - var browser = ""; + var browser = ''; function countdown_update() { ds_step--; if (ds_step < 0) { - ds_step = $("#ds_step").val(); + ds_step = $('#ds_step').val(); imageOptionsChanged('countdown'); sizeset = false; } - $('#countdown').html( '' + ds_step + ' seconds left.'); + $('#countdown').html(ds_step + ' seconds left.'); browser = realtimeDetectBrowser(); /* set the window size */ - height = $(".graphimage").height(); - width = $(".graphimage").width(); + height = $('.graphimage').height(); + width = $('.graphimage').width(); if (height > 40) { - if (browser == "IE") { + if (browser == 'IE') { width = width + 30; height = height + 110; }else{ width = width + 40; - height = height + 165; + height = height + 170; } if (sizeset == false) { - if (browser == "FF") { + if (browser == 'FF') { window.outerHeight = height; window.outerWidth = width; }else{ diff --git a/include/global_arrays.php b/include/global_arrays.php index f0cd724b9d..3a2c176592 100644 --- a/include/global_arrays.php +++ b/include/global_arrays.php @@ -1075,7 +1075,7 @@ $realtime_refresh = array( 5 => __('%d Seconds', 5), 10 => __('%d Seconds', 10), - 15 => __('%d Seconds', 25), + 15 => __('%d Seconds', 15), 20 => __('%d Seconds', 20), 30 => __('%d Seconds', 30), 60 => __('1 Minute'), diff --git a/include/realtime.js b/include/realtime.js index 2b652dcc58..db3008525e 100644 --- a/include/realtime.js +++ b/include/realtime.js @@ -7,7 +7,7 @@ var originalRefresh = 0; var timeOffset; var realtimeTimer; var rtWidth = 0; -var rtheight = 0; +var rtHeight = 0; var url; function realtimeDetectBrowser() { @@ -30,12 +30,23 @@ function imageOptionsChanged(action) { graph_start = $("#graph_start").val(); graph_end = 0; ds_step = $("#ds_step").val(); + local_graph_id = $('#local_graph_id').val(); - url="?top=0&left=0&action="+action+"&graph_start=-"+graph_start+"&ds_step="+ds_step+"&count="+count; + if (rtWidth == 0) { + rtWidth = $(window).width(); + } + + if (rtHeight == 0) { + rtHeight = $(window).height()+50; + } + + url="?top=0&left=0&action="+action+"&local_graph_id="+local_graph_id+"&graph_start=-"+graph_start+"&ds_step="+ds_step+"&count="+count; Pace.stop; - $.get(url); + $.getJSON(url, function(data) { + $('#image').empty().append(''); + }); } function stopRealtime() { @@ -127,7 +138,7 @@ function realtimeGrapher() { }); } } - + if (inRealtime == false) { stopRealtime(); } else {