diff --git a/app/Http/Controllers/ItemController.php b/app/Http/Controllers/ItemController.php index 84da8a74..e65041d3 100644 --- a/app/Http/Controllers/ItemController.php +++ b/app/Http/Controllers/ItemController.php @@ -313,14 +313,14 @@ class ItemController extends Controller $app_details = new $app(); $app_details->config = (object)$data; - $app_details->testConfig(); + $app_details->test(); } public function getStats($id) { $item = Item::find($id); - $config = $item->config(); + $config = $item->getconfig(); if(isset($config->type)) { $application = new $config->type; $application->config = $config; diff --git a/app/Item.php b/app/Item.php index 286804bf..3c5715e9 100644 --- a/app/Item.php +++ b/app/Item.php @@ -140,15 +140,19 @@ class Item extends Model public function enhanced() { - $details = $this->config(); + $details = $this->getconfig(); $class = $details->type; $app = new $class; return (bool)($app instanceof \App\EnhancedApps); } - public function config() + public function getconfig() { $config = json_decode($this->description); + + $explode = explode('\\', $config->type); + $config->name = end($explode); + $config->url = $this->url; if(isset($config->override_url) && !empty($config->override_url)) { diff --git a/app/SupportedApps.php b/app/SupportedApps.php index 338868bd..e99be134 100644 --- a/app/SupportedApps.php +++ b/app/SupportedApps.php @@ -6,9 +6,23 @@ use GuzzleHttp\Client; abstract class SupportedApps { - public function test($url, $requiresLoginFirst=false) + public function appTest($url, $requiresLoginFirst=false) { - + $res = $this->execute($url, $requiresLoginFirst); + switch($res->getStatusCode()) { + case 200: + echo 'Successfully connected to the API'; + break; + case 401: + echo 'Failed: Invalid credentials'; + break; + case 404: + echo 'Failed: Please make sure your URL is correct and that there is a trailing slash'; + break; + default: + echo 'Something went wrong... Code: '.$res->getStatusCode(); + break; + } } public function execute($url, $requiresLoginFirst=false) diff --git a/resources/views/item.blade.php b/resources/views/item.blade.php index bb8b15cf..2b2d543e 100644 --- a/resources/views/item.blade.php +++ b/resources/views/item.blade.php @@ -8,7 +8,7 @@