mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-11-27 02:29:57 +09:00
Change code to wind down checks when no doing anything
This commit is contained in:
@@ -39,19 +39,24 @@ class Nzbget implements Contracts\Applications, Contracts\Livestats {
|
|||||||
}
|
}
|
||||||
public function executeConfig()
|
public function executeConfig()
|
||||||
{
|
{
|
||||||
|
$output = '';
|
||||||
$res = $this->buildRequest('status');
|
$res = $this->buildRequest('status');
|
||||||
$data = json_decode($res->getBody());
|
$data = json_decode($res->getBody());
|
||||||
//$data->result->RemainingSizeMB = '10000000';
|
//$data->result->RemainingSizeMB = '10000000';
|
||||||
//$data->result->DownloadRate = '100000000';
|
//$data->result->DownloadRate = '100000000';
|
||||||
$queue_size = format_bytes($data->result->RemainingSizeMB*1000*1000, false, ' <span>', '</span>');
|
$size = $data->result->RemainingSizeMB;
|
||||||
$current_speed = format_bytes($data->result->DownloadRate, false, ' <span>');
|
$rate = $data->result->DownloadRate;
|
||||||
|
$queue_size = format_bytes($size*1000*1000, false, ' <span>', '</span>');
|
||||||
|
$current_speed = format_bytes($rate, false, ' <span>');
|
||||||
|
|
||||||
|
if($size > 0 || $rate > 0) {
|
||||||
$output = '
|
$output = '
|
||||||
<ul class="livestats">
|
<ul class="livestats">
|
||||||
<li><span class="title">Queue</span><strong>'.$queue_size.'</strong></li>
|
<li><span class="title">Queue</span><strong>'.$queue_size.'</strong></li>
|
||||||
<li><span class="title">Speed</span><strong>'.$current_speed.'/s</span></strong></li>
|
<li><span class="title">Speed</span><strong>'.$current_speed.'/s</span></strong></li>
|
||||||
</ul>
|
</ul>
|
||||||
';
|
';
|
||||||
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
public function buildRequest($endpoint)
|
public function buildRequest($endpoint)
|
||||||
|
|||||||
8
public/js/app.js
vendored
8
public/js/app.js
vendored
@@ -21,15 +21,21 @@ $.when( $.ready ).then(function() {
|
|||||||
$('.livestats-container').each(function(index){
|
$('.livestats-container').each(function(index){
|
||||||
var id = $(this).data('id');
|
var id = $(this).data('id');
|
||||||
var container = $(this);
|
var container = $(this);
|
||||||
|
var max_timer = 30000;
|
||||||
|
var timer = 1000;
|
||||||
(function worker() {
|
(function worker() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/get_stats/'+id,
|
url: '/get_stats/'+id,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
container.html(data);
|
container.html(data);
|
||||||
|
if(data != '') timer = 1000;
|
||||||
|
else {
|
||||||
|
if(timer < max_timer) timer += 2000;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
// Schedule the next request when the current one's complete
|
// Schedule the next request when the current one's complete
|
||||||
setTimeout(worker, 5000);
|
setTimeout(worker, timer);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
8
resources/assets/js/app.js
vendored
8
resources/assets/js/app.js
vendored
@@ -12,15 +12,21 @@ $.when( $.ready ).then(function() {
|
|||||||
$('.livestats-container').each(function(index){
|
$('.livestats-container').each(function(index){
|
||||||
var id = $(this).data('id');
|
var id = $(this).data('id');
|
||||||
var container = $(this);
|
var container = $(this);
|
||||||
|
var max_timer = 30000;
|
||||||
|
var timer = 1000;
|
||||||
(function worker() {
|
(function worker() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/get_stats/'+id,
|
url: '/get_stats/'+id,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
container.html(data);
|
container.html(data);
|
||||||
|
if(data != '') timer = 1000;
|
||||||
|
else {
|
||||||
|
if(timer < max_timer) timer += 2000;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
// Schedule the next request when the current one's complete
|
// Schedule the next request when the current one's complete
|
||||||
setTimeout(worker, 5000);
|
setTimeout(worker, timer);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user