mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-11-18 05:42:41 +09:00
Fix test button
This commit is contained in:
@@ -313,14 +313,14 @@ class ItemController extends Controller
|
|||||||
|
|
||||||
$app_details = new $app();
|
$app_details = new $app();
|
||||||
$app_details->config = (object)$data;
|
$app_details->config = (object)$data;
|
||||||
$app_details->testConfig();
|
$app_details->test();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStats($id)
|
public function getStats($id)
|
||||||
{
|
{
|
||||||
$item = Item::find($id);
|
$item = Item::find($id);
|
||||||
|
|
||||||
$config = $item->config();
|
$config = $item->getconfig();
|
||||||
if(isset($config->type)) {
|
if(isset($config->type)) {
|
||||||
$application = new $config->type;
|
$application = new $config->type;
|
||||||
$application->config = $config;
|
$application->config = $config;
|
||||||
|
|||||||
@@ -140,16 +140,20 @@ class Item extends Model
|
|||||||
|
|
||||||
public function enhanced()
|
public function enhanced()
|
||||||
{
|
{
|
||||||
$details = $this->config();
|
$details = $this->getconfig();
|
||||||
$class = $details->type;
|
$class = $details->type;
|
||||||
$app = new $class;
|
$app = new $class;
|
||||||
return (bool)($app instanceof \App\EnhancedApps);
|
return (bool)($app instanceof \App\EnhancedApps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function config()
|
public function getconfig()
|
||||||
{
|
{
|
||||||
$config = json_decode($this->description);
|
$config = json_decode($this->description);
|
||||||
|
|
||||||
|
$explode = explode('\\', $config->type);
|
||||||
|
$config->name = end($explode);
|
||||||
|
|
||||||
|
|
||||||
$config->url = $this->url;
|
$config->url = $this->url;
|
||||||
if(isset($config->override_url) && !empty($config->override_url)) {
|
if(isset($config->override_url) && !empty($config->override_url)) {
|
||||||
$config->url = $config->override_url;
|
$config->url = $config->override_url;
|
||||||
|
|||||||
@@ -6,9 +6,23 @@ use GuzzleHttp\Client;
|
|||||||
abstract class SupportedApps
|
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)
|
public function execute($url, $requiresLoginFirst=false)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<div class="details">
|
<div class="details">
|
||||||
<div class="title{{ title_color($app->colour) }}">{{ $app->title }}</div>
|
<div class="title{{ title_color($app->colour) }}">{{ $app->title }}</div>
|
||||||
@if($app->enhanced())
|
@if($app->enhanced())
|
||||||
<div data-id="{{ $app->id }}" data-dataonly="{{ $app->config()->dataonly ?? '0' }}" class="livestats-container"></div>
|
<div data-id="{{ $app->id }}" data-dataonly="{{ $app->getconfig()->dataonly ?? '0' }}" class="livestats-container"></div>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<a class="link{{ title_color($app->colour) }}"{!! $app->link_target !!} href="{{ $app->link }}"><i class="fas {{ $app->link_icon }}"></i></a>
|
<a class="link{{ title_color($app->colour) }}"{!! $app->link_target !!} href="{{ $app->link }}"><i class="fas {{ $app->link_icon }}"></i></a>
|
||||||
|
|||||||
@@ -58,10 +58,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if(isset($item) && isset($item->config->view))
|
@if($item->enhanced())
|
||||||
<div id="sapconfig" style="display: block;">
|
<div id="sapconfig" style="display: block;">
|
||||||
@if(isset($item))
|
@if(isset($item))
|
||||||
@include('supportedapps.'.$item->config->view)
|
@include('SupportedApps::'.$item->getconfig()->name.'.config')
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
|
|||||||
Reference in New Issue
Block a user