From 4351f55225b0ba8790d8fa8df46e7b1177cf885b Mon Sep 17 00:00:00 2001 From: Kode Date: Sun, 28 Oct 2018 10:59:59 +0000 Subject: [PATCH] updates --- app/EnhancedApps.php | 2 +- app/Http/Controllers/ItemController.php | 4 +-- app/Item.php | 2 +- app/SupportedApps.php | 44 ++++++++++++++++--------- public/css/app.css | 15 ++++++++- public/js/app.js | 2 +- public/mix-manifest.json | 4 +-- resources/assets/js/app.js | 2 +- resources/assets/sass/_app.scss | 8 ++++- resources/views/items/form.blade.php | 3 +- resources/views/items/preview.blade.php | 2 +- 11 files changed, 60 insertions(+), 28 deletions(-) diff --git a/app/EnhancedApps.php b/app/EnhancedApps.php index 7962a6fb..fb137715 100644 --- a/app/EnhancedApps.php +++ b/app/EnhancedApps.php @@ -7,6 +7,6 @@ interface EnhancedApps { public function test(); public function livestats(); - public function apiUrl($endpoint); + public function url($endpoint); } \ No newline at end of file diff --git a/app/Http/Controllers/ItemController.php b/app/Http/Controllers/ItemController.php index 0c53e522..bfbe9675 100644 --- a/app/Http/Controllers/ItemController.php +++ b/app/Http/Controllers/ItemController.php @@ -335,8 +335,8 @@ class ItemController extends Controller $item = Item::find($id); $config = $item->getconfig(); - if(isset($config->type)) { - $application = new $config->type; + if(isset($item->class)) { + $application = new $item->class; $application->config = $config; echo $application->livestats(); } diff --git a/app/Item.php b/app/Item.php index 7f67cb8b..dc16a6b9 100644 --- a/app/Item.php +++ b/app/Item.php @@ -159,7 +159,7 @@ class Item extends Model $config = json_decode($this->description); - $explode = explode('\\', $config->type); + $explode = explode('\\', $this->class); $config->name = end($explode); diff --git a/app/SupportedApps.php b/app/SupportedApps.php index 8cdc0b0c..55b7685d 100644 --- a/app/SupportedApps.php +++ b/app/SupportedApps.php @@ -6,33 +6,47 @@ use GuzzleHttp\Client; abstract class SupportedApps { - public function appTest($url, $requiresLoginFirst=false) + protected $jar = false; + protected $method = 'GET'; + + public function appTest($url, $attrs = []) { - $res = $this->execute($url, $requiresLoginFirst); + $res = $this->execute($url, $attrs); switch($res->getStatusCode()) { case 200: - echo 'Successfully connected to the API'; + $status = 'Successfully communicated with the API'; break; case 401: - echo 'Failed: Invalid credentials'; + $status = 'Failed: Invalid credentials'; break; case 404: - echo 'Failed: Please make sure your URL is correct and that there is a trailing slash'; + $status = 'Failed: Please make sure your URL is correct and that there is a trailing slash'; break; default: - echo 'Something went wrong... Code: '.$res->getStatusCode(); + $status = 'Something went wrong... Code: '.$res->getStatusCode(); break; } + return (object)[ + 'code' => $res->getStatusCode(), + 'status' => $status, + 'response' => $res->getBody(), + ]; } - public function execute($url, $requiresLoginFirst=false) + public function execute($url, $attrs = []) { - if($requiresLoginFirst) { - - } - - $client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]); - return $client->request('GET', $url); + $vars = [ + 'http_errors' => false, + 'timeout' => 15, + 'connect_timeout' => 15, + ]; + $client = new Client($vars); + + try { + return $client->request($this->method, $url, $attrs); + } catch (\GuzzleHttp\Exception\ServerException $e) { + echo (string) $e->getResponse()->getBody(); + } } public function login() @@ -61,14 +75,14 @@ abstract class SupportedApps { $list_url = 'https://apps.heimdall.site/list'; $client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]); - return $client->request('GET', $list_url); + return $client->request($this->method, $list_url); } public static function getFiles($app) { $zipurl = $app->files; $client = new Client(['http_errors' => false, 'timeout' => 60, 'connect_timeout' => 15]); - $res = $client->request('GET', $zipurl); + $res = $client->request($this->method, $zipurl); if(!file_exists(app_path('SupportedApps'))) { mkdir(app_path('SupportedApps'), 0777, true); diff --git a/public/css/app.css b/public/css/app.css index d7d2c312..94e157e0 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -1252,7 +1252,7 @@ hr { } .livestats-container .livestats { - margin: 5px 0px -5px; + margin: 5px 0px 0px; padding: 0; display: -webkit-box; display: -ms-flexbox; @@ -1277,11 +1277,24 @@ hr { font-weight: 500; opacity: 0.5; line-height: 1; + display: -webkit-box; + display: -ms-flexbox; + display: flex; } .livestats-container .livestats strong { display: block; line-height: 1; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.livestats-container .livestats strong span { + margin-left: 4px; } input:-webkit-autofill, diff --git a/public/js/app.js b/public/js/app.js index 52125eae..0df87257 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -135,7 +135,7 @@ $.when( $.ready ).then(function() { var data = {}; data['url'] = apiurl; - $('input.config-item').each(function(index){ + $('.config-item').each(function(index){ var config = $(this).data('config'); data[config] = $(this).val(); }); diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 4e471a32..01fb9221 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -1,4 +1,4 @@ { - "/css/app.css": "/css/app.css?id=d501edaf8c9cc02c173d", - "/js/app.js": "/js/app.js?id=32cbf6f4924b46ae7e05" + "/css/app.css": "/css/app.css?id=22a39cc94a111a82ce68", + "/js/app.js": "/js/app.js?id=8dc4a6ea723d0df7469d" } \ No newline at end of file diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 66d47554..6deed36a 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -126,7 +126,7 @@ $.when( $.ready ).then(function() { var data = {}; data['url'] = apiurl; - $('input.config-item').each(function(index){ + $('.config-item').each(function(index){ var config = $(this).data('config'); data[config] = $(this).val(); }); diff --git a/resources/assets/sass/_app.scss b/resources/assets/sass/_app.scss index c85285c6..fd30c47e 100644 --- a/resources/assets/sass/_app.scss +++ b/resources/assets/sass/_app.scss @@ -852,7 +852,7 @@ hr { .livestats-container { .livestats { - margin: 5px 0px -5px; + margin: 5px 0px 0px; padding: 0; display: flex; list-style: none; @@ -871,10 +871,16 @@ hr { font-weight: 500; opacity: 0.5; line-height: 1; + display: flex; } strong { display: block; line-height: 1; + display: flex; + align-items: center; + span { + margin-left: 4px; + } } } diff --git a/resources/views/items/form.blade.php b/resources/views/items/form.blade.php index 0e21eb1a..bc6dcc2e 100644 --- a/resources/views/items/form.blade.php +++ b/resources/views/items/form.blade.php @@ -22,14 +22,13 @@
{!! csrf_field() !!} - {!! Form::hidden('class', '') !!}
{!! Form::text('title', null, array('placeholder' => __('app.apps.title'), 'id' => 'appname', 'class' => 'form-control')) !!}
- {!! Form::select('class', App\Application::applist(), null, array('class' => 'form-control')) !!} + {!! Form::select('class', App\Application::applist(), null, array('class' => 'form-control config-item', 'data-config' => 'type')) !!}
diff --git a/resources/views/items/preview.blade.php b/resources/views/items/preview.blade.php index f9f50e4a..568e52d3 100644 --- a/resources/views/items/preview.blade.php +++ b/resources/views/items/preview.blade.php @@ -11,7 +11,7 @@
{{ $item->title ?? '' }}
@if($item->enhanced()) -
+
@endif
link_target !!} href="{{ $item->link }}">