diff --git a/app/SupportedApps/Nzbget.php b/app/SupportedApps/Nzbget.php index 0fe5a92b..407efc7b 100644 --- a/app/SupportedApps/Nzbget.php +++ b/app/SupportedApps/Nzbget.php @@ -39,19 +39,24 @@ class Nzbget implements Contracts\Applications, Contracts\Livestats { } public function executeConfig() { + $output = ''; $res = $this->buildRequest('status'); $data = json_decode($res->getBody()); //$data->result->RemainingSizeMB = '10000000'; //$data->result->DownloadRate = '100000000'; - $queue_size = format_bytes($data->result->RemainingSizeMB*1000*1000, false, ' ', ''); - $current_speed = format_bytes($data->result->DownloadRate, false, ' '); + $size = $data->result->RemainingSizeMB; + $rate = $data->result->DownloadRate; + $queue_size = format_bytes($size*1000*1000, false, ' ', ''); + $current_speed = format_bytes($rate, false, ' '); - $output = ' - - '; + if($size > 0 || $rate > 0) { + $output = ' + + '; + } return $output; } public function buildRequest($endpoint) diff --git a/public/js/app.js b/public/js/app.js index 41bea75b..9fe33a66 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -21,15 +21,21 @@ $.when( $.ready ).then(function() { $('.livestats-container').each(function(index){ var id = $(this).data('id'); var container = $(this); - (function worker() { + var max_timer = 30000; + var timer = 1000; + (function worker() { $.ajax({ url: '/get_stats/'+id, success: function(data) { container.html(data); + if(data != '') timer = 1000; + else { + if(timer < max_timer) timer += 2000; + } }, complete: function() { // Schedule the next request when the current one's complete - setTimeout(worker, 5000); + setTimeout(worker, timer); } }); })(); diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index dd62e8a1..70caf5ac 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -12,15 +12,21 @@ $.when( $.ready ).then(function() { $('.livestats-container').each(function(index){ var id = $(this).data('id'); var container = $(this); - (function worker() { + var max_timer = 30000; + var timer = 1000; + (function worker() { $.ajax({ url: '/get_stats/'+id, success: function(data) { container.html(data); + if(data != '') timer = 1000; + else { + if(timer < max_timer) timer += 2000; + } }, complete: function() { // Schedule the next request when the current one's complete - setTimeout(worker, 5000); + setTimeout(worker, timer); } }); })();