From 7d119bfe5a7d6fa88f78fd25cc8ff73247aec08c Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Mon, 15 Jul 2019 17:41:20 +0200 Subject: [PATCH] Added feature to autorefresh in events view with datatables - #4330 --- pandora_console/general/header.php | 63 +++++++++++++++++---- pandora_console/operation/events/events.php | 20 +++++++ 2 files changed, 73 insertions(+), 10 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index a093596b2b..cb39abc999 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -670,21 +670,49 @@ if ($config['menu_type'] == 'classic') { + + var autorefresh_draw = ''; $("#header_autorefresh").css('padding-right', '5px'); - var refr_time = ; - var t = new Date(); - t.setTime (t.getTime () + parseInt()); - $("#refrcounter").countdown ({ - until: t, - layout: '%M%nn%M:%S%nn%S', - labels: ['', '', '', '', '', '', ''], - onExpiry: function () { + if(autorefresh_draw == true) { + var refresh_interval = parseInt(''); + var until_time=''; + + function events_refresh() { + until_time = new Date(); + until_time.setTime (until_time.getTime () + parseInt()); + + $("#refrcounter").countdown ({ + until: until_time, + layout: '%M%nn%M:%S%nn%S', + labels: ['', '', '', '', '', '', ''], + onExpiry: function () { + dt_events.draw(true); + } + }); + } + // Start the countdown when page is loaded (first time). + events_refresh(); + // Repeat countdown according to refresh_interval. + setInterval(events_refresh, refresh_interval); + } else { + var refr_time = ; + var t = new Date(); + t.setTime (t.getTime () + parseInt()); + $("#refrcounter").countdown ({ + until: t, + layout: '%M%nn%M:%S%nn%S', + labels: ['', '', '', '', '', '', ''], + onExpiry: function () { href = $("a.autorefresh").attr ("href"); href = href + refr_time; $(document).attr ("location", href); } }); + } @@ -694,8 +722,23 @@ if ($config['menu_type'] == 'classic') { $("#combo_refr").toggle (); $("select#ref").change (function () { href = $("a.autorefresh").attr ("href"); - $(document).attr ("location", href + this.value); - }); + + if(autorefresh_draw == true){ + inputs = $("#events_form :input"); + values = {}; + inputs.each(function() { + values[this.name] = $(this).val(); + }) + + var newValue = btoa(JSON.stringify(values)); + console.log(newValue); + $(document).attr("location", href+'&fb64=' + newValue + '&refr=' + this.value); + + } else { + console.log('recargo'); + $(document).attr ("location", href + this.value); + } + }); return false; }); diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 9561872288..b316bea7ff 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1469,6 +1469,11 @@ echo "
'; echo ''; + +if ($_GET['refr'] || $do_refresh === true) { + $autorefresh_draw = true; +} + ?>