Browse Source

first working(ish) app!

pull/21/head
Chris 7 years ago
parent
commit
482831b9f9
  1. 17
      app/Http/Controllers/ItemController.php
  2. 3
      app/Http/Middleware/VerifyCsrfToken.php
  3. 18
      app/SupportedApps/Nzbget.php
  4. 25
      public/css/app.css
  5. 11
      public/js/app.js
  6. 4
      public/mix-manifest.json
  7. 11
      resources/assets/js/app.js
  8. 22
      resources/assets/sass/_app.scss
  9. 8
      resources/views/item.blade.php
  10. 1
      routes/web.php

17
app/Http/Controllers/ItemController.php

@ -302,5 +302,22 @@ class ItemController extends Controller
$app_details->testConfig(); $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();
}
}
} }

3
app/Http/Middleware/VerifyCsrfToken.php

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

18
app/SupportedApps/Nzbget.php

@ -36,11 +36,19 @@ class Nzbget implements Contracts\Applications, Contracts\Livestats {
} }
public function executeConfig() public function executeConfig()
{ {
$config = json_decode($this->config); $res = $this->buildRequest('status');
$url = $config->url; $data = json_decode($res->getBody());
$user = $config->username;
$pass = $config->password; $queue_size = $data->result->RemainingSizeMB;
return null; $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) public function buildRequest($endpoint)
{ {

25
public/css/app.css

@ -1095,6 +1095,31 @@ hr {
display: none; 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 /*! Huebee v2.0.0
http://huebee.buzz http://huebee.buzz
---------------------------------------------- */ ---------------------------------------------- */

11
public/js/app.js

@ -15,7 +15,18 @@ $.when( $.ready ).then(function() {
{ {
$('.message-container').fadeOut(); $('.message-container').fadeOut();
}, 3500); }, 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);
})
});
} }

4
public/mix-manifest.json

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

11
resources/assets/js/app.js

@ -6,7 +6,18 @@ $.when( $.ready ).then(function() {
{ {
$('.message-container').fadeOut(); $('.message-container').fadeOut();
}, 3500); }, 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);
})
});
} }

22
resources/assets/sass/_app.scss

@ -721,4 +721,26 @@ hr {
.ui-helper-hidden-accessible { .ui-helper-hidden-accessible {
display: none; 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;
}
}
} }

8
resources/views/item.blade.php

@ -5,8 +5,12 @@
@else @else
<i class="fas fa-app-store-ios"></i> <i class="fas fa-app-store-ios"></i>
@endif @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> <a class="link" href="{{ $app->url }}"><i class="fas fa-arrow-alt-to-right"></i></a>
</div> </div>
<a class="item-edit" href="{{ route('items.edit', $app->id) }}"><i class="fas fa-pencil"></i></a> <a class="item-edit" href="{{ route('items.edit', $app->id) }}"><i class="fas fa-pencil"></i></a>

1
routes/web.php

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

Loading…
Cancel
Save