closes #122, closes #82,

This commit is contained in:
KodeStar 2018-03-05 19:38:23 +00:00
parent 8b4583c59c
commit ca2e135cba
14 changed files with 81 additions and 38 deletions

View file

@ -39,25 +39,27 @@ class Nzbget implements Contracts\Applications, Contracts\Livestats {
}
public function executeConfig()
{
$output = '';
$html = '';
$active = 'inactive';
$res = $this->buildRequest('status');
$data = json_decode($res->getBody());
//$data->result->RemainingSizeMB = '10000000';
//$data->result->DownloadRate = '100000000';
$size = $data->result->RemainingSizeMB;
$rate = $data->result->DownloadRate;
$queue_size = format_bytes($size*1000*1000, false, ' <span>', '</span>');
$current_speed = format_bytes($rate, false, ' <span>');
if($data) {
$size = $data->result->RemainingSizeMB;
$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 = '
$active = ($size > 0 || $rate > 0) ? 'active' : 'inactive';
$html = '
<ul class="livestats">
<li><span class="title">Queue</span><strong>'.$queue_size.'</strong></li>
<li><span class="title">Speed</span><strong>'.$current_speed.'/s</span></strong></li>
</ul>
';
}
return $output;
return json_encode(['status' => $active, 'html' => $html]);
}
public function buildRequest($endpoint)
{
@ -73,7 +75,7 @@ class Nzbget implements Contracts\Applications, Contracts\Livestats {
$api_url = $rebuild_url.'/jsonrpc/'.$endpoint;
$client = new Client(['http_errors' => false]);
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]);
$res = $client->request('GET', $api_url);
return $res;

View file

@ -39,17 +39,18 @@ class Pihole implements Contracts\Applications, Contracts\Livestats {
public function executeConfig()
{
$output = '';
$html = '';
$active = 'active';
$res = $this->buildRequest();
$data = json_decode($res->getBody());
$output = '
$html = '
<ul class="livestats">
<li><span class="title">Domains<br />Blocked</span><strong>'.$data->domains_being_blocked.'</strong></li>
<li><span class="title">Blocked<br />Today</span><strong>'.$data->ads_blocked_today.'</span></strong></li>
</ul>
';
return $output;
return json_encode(['status' => $active, 'html' => $html]);
}
public function buildRequest()
@ -62,7 +63,7 @@ class Pihole implements Contracts\Applications, Contracts\Livestats {
$api_url = $url.'/api.php';
//die( $api_url.' --- ');
$client = new Client(['http_errors' => false]);
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]);
$res = $client->request('GET', $api_url);
return $res;

View file

@ -44,18 +44,19 @@ class Plexpy implements Contracts\Applications, Contracts\Livestats {
}
public function executeConfig()
{
$output = '';
$html = '';
$active = 'active';
$res = $this->buildRequest('get_activity');
$data = json_decode($res->getBody());
$stream_count = $data->response->data->stream_count;
$output = '
$html = '
<ul class="livestats">
<li><span class="title">Stream Count</span><strong>'.$stream_count.'</strong></li>
</ul>
';
return $output;
return json_encode(['status' => $active, 'html' => $html]);
}
public function buildRequest($endpoint)
{
@ -67,7 +68,7 @@ class Plexpy implements Contracts\Applications, Contracts\Livestats {
$api_url = $url.'/api/v2?apikey='.$apikey.'&cmd='.$endpoint;
$client = new Client(['http_errors' => false]);
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]);
$res = $client->request('GET', $api_url);
return $res;

View file

@ -40,6 +40,7 @@ class Runeaudio implements Contracts\Applications, Contracts\Livestats {
public function executeConfig()
{
$output = '';
$active = 'active';
$artist = '';
$song_title = '';
$res = $this->buildRequest('currentsong');
@ -71,7 +72,7 @@ class Runeaudio implements Contracts\Applications, Contracts\Livestats {
$output = $output.'</ul>';
return $output;
return json_encode(['status' => $active, 'html' => $output]);
}
public function buildRequest($endpoint)
@ -84,7 +85,7 @@ class Runeaudio implements Contracts\Applications, Contracts\Livestats {
$api_url = $url.'/command/?cmd='.$endpoint;
//die( $api_url.' --- ');
$client = new Client(['http_errors' => false]);
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]);
$res = $client->request('GET', $api_url);
return $res;

View file

@ -44,25 +44,27 @@ class Sabnzbd implements Contracts\Applications, Contracts\Livestats {
}
public function executeConfig()
{
$output = '';
$html = '';
$active = 'inactive';
$res = $this->buildRequest('queue');
$data = json_decode($res->getBody());
//$data->result->RemainingSizeMB = '10000000';
//$data->result->DownloadRate = '100000000';
$size = $data->queue->mbleft;
$rate = $data->queue->kbpersec;
$queue_size = format_bytes($size*1000*1000, false, ' <span>', '</span>');
$current_speed = format_bytes($rate*1000, false, ' <span>');
if($data) {
$size = $data->queue->mbleft;
$rate = $data->queue->kbpersec;
$queue_size = format_bytes($size*1000*1000, false, ' <span>', '</span>');
$current_speed = format_bytes($rate*1000, false, ' <span>');
if($size > 0 || $rate > 0) {
$output = '
<ul class="livestats">
<li><span class="title">Queue</span><strong>'.$queue_size.'</strong></li>
<li><span class="title">Speed</span><strong>'.$current_speed.'/s</span></strong></li>
</ul>
$active = ($size > 0 || $rate > 0) ? 'active' : 'inactive';
$html = '
<ul class="livestats">
<li><span class="title">Queue</span><strong>'.$queue_size.'</strong></li>
<li><span class="title">Speed</span><strong>'.$current_speed.'/s</span></strong></li>
</ul>
';
}
return $output;
return json_encode(['status' => $active, 'html' => $html]);
}
public function buildRequest($endpoint)
{
@ -70,12 +72,15 @@ class Sabnzbd implements Contracts\Applications, Contracts\Livestats {
$url = $config->url;
$apikey = $config->apikey;
//print_r($config);
//die();
$url = rtrim($url, '/');
$api_url = $url.'/api?output=json&apikey='.$apikey.'&mode='.$endpoint;
//die( $api_url.' --- ');
$client = new Client(['http_errors' => false]);
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]);
$res = $client->request('GET', $api_url);
return $res;

7
public/js/app.js vendored
View file

@ -28,9 +28,10 @@ $.when( $.ready ).then(function() {
(function worker() {
$.ajax({
url: '/get_stats/'+id,
dataType: 'json',
success: function(data) {
container.html(data);
if(data != '') timer = increaseby;
container.html(data.html);
if(data.status == 'active') timer = increaseby;
else {
if(timer < max_timer) timer += 2000;
}
@ -130,7 +131,7 @@ $.when( $.ready ).then(function() {
var apiurl = $('#create input[name=url]').val();
var override_url = $('#create input[name=override_url]');
var override_url = $('#override_url');
if(override_url.length && override_url.val() != '') {
apiurl = override_url;
}

View file

@ -19,9 +19,10 @@ $.when( $.ready ).then(function() {
(function worker() {
$.ajax({
url: '/get_stats/'+id,
dataType: 'json',
success: function(data) {
container.html(data);
if(data != '') timer = increaseby;
container.html(data.html);
if(data.status == 'active') timer = increaseby;
else {
if(timer < max_timer) timer += 2000;
}
@ -121,7 +122,7 @@ $.when( $.ready ).then(function() {
var apiurl = $('#create input[name=url]').val();
var override_url = $('#create input[name=override_url]');
var override_url = $('#override_url');
if(override_url.length && override_url.val() != '') {
apiurl = override_url;
}

View file

@ -65,6 +65,7 @@ return [
'apps.add_tag' => 'Add tag',
'apps.tag_name' => 'Tag name',
'apps.tags' => 'Tags',
'apps.override' => 'If different to main url',
'url' => 'Url',
'title' => 'Title',

View file

@ -1,6 +1,11 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }})</h2>
<div class="items">
<input type="hidden" data-config="type" class="config-item" name="config[type]" value="\App\SupportedApps\Nzbget" />
<div class="input">
<label>{{ strtoupper(__('app.url')) }}</label>
{!! Form::text('config[override_url]', null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
</div>
<div class="input">
<label>{{ __('app.apps.username') }}</label>
{!! Form::text('config[username]', null, array('placeholder' => __('app.apps.username'), 'data-config' => 'username', 'class' => 'form-control config-item')) !!}

View file

@ -2,6 +2,11 @@
<div class="items">
<input type="hidden" data-config="type" class="config-item" name="config[type]" value="\App\SupportedApps\Pihole" />
<input type="hidden" data-config="dataonly" class="config-item" name="config[dataonly]" value="1" />
<div class="input">
<label>{{ strtoupper(__('app.url')) }}</label>
{!! Form::text('config[override_url]', null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
</div>
<div class="input">
<label>{{ __('app.apps.enable') }}</label>
{!! Form::hidden('config[enabled]', '0') !!}

View file

@ -1,6 +1,10 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }})</h2>
<div class="items">
<input type="hidden" data-config="type" class="config-item" name="config[type]" value="\App\SupportedApps\Plexpy" />
<div class="input">
<label>{{ strtoupper(__('app.url')) }}</label>
{!! Form::text('config[override_url]', null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
</div>
<div class="input">
<label>{{ __('app.apps.apikey') }}</label>
{!! Form::text('config[apikey]', null, array('placeholder' => __('app.apps.apikey'), 'data-config' => 'apikey', 'class' => 'form-control config-item')) !!}

View file

@ -1,6 +1,11 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }})</h2>
<div class="items">
<input type="hidden" data-config="type" class="config-item" name="config[type]" value="\App\SupportedApps\Proxmox" />
<div class="input">
<label>{{ strtoupper(__('app.url')) }}</label>
{!! Form::text('config[override_url]', null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
</div>
<div class="input">
<label>{{ __('app.apps.username') }}</label>
{!! Form::text('config[username]', null, array('placeholder' => __('app.apps.username'), 'data-config' => 'username', 'class' => 'form-control config-item')) !!}

View file

@ -2,6 +2,11 @@
<div class="items">
<input type="hidden" data-config="type" class="config-item" name="config[type]" value="\App\SupportedApps\Runeaudio" />
<input type="hidden" data-config="dataonly" class="config-item" name="config[dataonly]" value="1" />
<div class="input">
<label>{{ strtoupper(__('app.url')) }}</label>
{!! Form::text('config[override_url]', null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
</div>
<div class="input">
<label>{{ __('app.apps.enable') }}</label>
{!! Form::hidden('config[enabled]', '0') !!}

View file

@ -1,6 +1,12 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }})</h2>
<div class="items">
<input type="hidden" data-config="type" class="config-item" name="config[type]" value="\App\SupportedApps\Sabnzbd" />
<div class="input">
<label>{{ strtoupper(__('app.url')) }}</label>
{!! Form::text('config[override_url]', null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
</div>
<div class="input">
<label>{{ __('app.apps.apikey') }}</label>
{!! Form::text('config[apikey]', null, array('placeholder' => __('app.apps.apikey'), 'data-config' => 'apikey', 'class' => 'form-control config-item')) !!}