first working(ish) app!

This commit is contained in:
Chris 2018-02-08 15:50:53 +00:00
parent 30aea8e361
commit 482831b9f9
10 changed files with 110 additions and 10 deletions

View file

@ -302,5 +302,22 @@ class ItemController extends Controller
$app_details->testConfig();
}
public function getStats($id)
{
$item = Item::find($id);
$config = json_decode($item->description);
if(isset($config->type)) {
$config->url = $item->url;
if(isset($config->override_url) && !empty($config->override_url)) {
$config->url = $config->override_url;
}
$app_details = new $config->type;
$app_details->config = $config;
echo $app_details->executeConfig();
}
}
}

View file

@ -15,6 +15,7 @@ class VerifyCsrfToken extends Middleware
//
'order',
'appload',
'test_config'
'test_config',
//'get_stats'
];
}

View file

@ -36,11 +36,19 @@ class Nzbget implements Contracts\Applications, Contracts\Livestats {
}
public function executeConfig()
{
$config = json_decode($this->config);
$url = $config->url;
$user = $config->username;
$pass = $config->password;
return null;
$res = $this->buildRequest('status');
$data = json_decode($res->getBody());
$queue_size = $data->result->RemainingSizeMB;
$current_speed = $data->result->DownloadRate;
$output = '
<ul class="livestats">
<li><span>Remaining</span><strong>'.$queue_size.'</strong></li>
<li><span>Speed</span><strong>'.$current_speed.'</strong></li>
</ul>
';
return $output;
}
public function buildRequest($endpoint)
{

25
public/css/app.css vendored
View file

@ -1095,6 +1095,31 @@ hr {
display: none;
}
.livestats-container .livestats {
margin: 8px -10px 0;
padding: 0;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
list-style: none;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
}
.livestats-container .livestats li {
text-align: center;
margin: 0 10px -10px;
}
.livestats-container .livestats span {
display: block;
text-transform: uppercase;
font-size: 11px;
font-weight: 500;
opacity: 0.5;
}
/*! Huebee v2.0.0
http://huebee.buzz
---------------------------------------------- */

11
public/js/app.js vendored
View file

@ -15,7 +15,18 @@ $.when( $.ready ).then(function() {
{
$('.message-container').fadeOut();
}, 3500);
}
if($('.livestats-container').length) {
$('.livestats-container').each(function(index){
var id = $(this).data('id');
var container = $(this);
$.get('/get_stats/'+id, function(data) {
//alert(data);
container.html(data);
})
});
}

View file

@ -1,4 +1,4 @@
{
"/css/app.css": "/css/app.css?id=d6ec6184a5279779b01a",
"/js/app.js": "/js/app.js?id=67b9d3b008c0a8da2fd6"
"/css/app.css": "/css/app.css?id=a260268fab1591f47ea4",
"/js/app.js": "/js/app.js?id=418d36daefa7f7979d93"
}

View file

@ -6,7 +6,18 @@ $.when( $.ready ).then(function() {
{
$('.message-container').fadeOut();
}, 3500);
}
if($('.livestats-container').length) {
$('.livestats-container').each(function(index){
var id = $(this).data('id');
var container = $(this);
$.get('/get_stats/'+id, function(data) {
//alert(data);
container.html(data);
})
});
}

View file

@ -722,3 +722,25 @@ hr {
.ui-helper-hidden-accessible {
display: none;
}
.livestats-container {
.livestats {
margin: 8px -10px 0;
padding: 0;
display: flex;
list-style: none;
justify-content: center;
li {
text-align: center;
margin: 0 10px -10px;
}
span {
display: block;
text-transform: uppercase;
font-size: 11px;
font-weight: 500;
opacity: 0.5;
}
}
}

View file

@ -5,8 +5,12 @@
@else
<i class="fas fa-app-store-ios"></i>
@endif
<div class="title">{{ $app->title }}</div>
<div class="details">
<div class="title">{{ $app->title }}</div>
@if(isset($app->description) && !empty($app->description))
<div data-id="{{ $app->id }}" class="livestats-container"></div>
@endif
</div>
<a class="link" href="{{ $app->url }}"><i class="fas fa-arrow-alt-to-right"></i></a>
</div>
<a class="item-edit" href="{{ route('items.edit', $app->id) }}"><i class="fas fa-pencil"></i></a>

View file

@ -24,6 +24,7 @@ Route::post('order', 'ItemController@setOrder')->name('items.order');
Route::post('appload', 'ItemController@appload')->name('appload');
Route::post('test_config', 'ItemController@testConfig')->name('test_config');
Route::get('/get_stats/{id}', 'ItemController@getStats')->name('get_stats');
Route::get('view/{name_view}', function ($name_view) {
return view('supportedapps.'.$name_view);