Fixes
This commit is contained in:
parent
268afe7006
commit
6e9f25d680
7 changed files with 72 additions and 38 deletions
|
@ -9,7 +9,12 @@ class Application extends Model
|
||||||
//
|
//
|
||||||
public function icon()
|
public function icon()
|
||||||
{
|
{
|
||||||
return asset($this->icon);
|
return $this->icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function iconView()
|
||||||
|
{
|
||||||
|
return asset('storage/'.$this->icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function defaultColour()
|
public function defaultColour()
|
||||||
|
@ -24,4 +29,6 @@ class Application extends Model
|
||||||
$class = '\App\SupportedApps\\'.$this->name.'\\'.$this->name;
|
$class = '\App\SupportedApps\\'.$this->name.'\\'.$this->name;
|
||||||
return $class;
|
return $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,6 @@ use GuzzleHttp\Client;
|
||||||
|
|
||||||
interface EnhancedApps
|
interface EnhancedApps
|
||||||
{
|
{
|
||||||
|
public function livestats();
|
||||||
|
|
||||||
}
|
}
|
|
@ -291,6 +291,7 @@ class ItemController extends Controller
|
||||||
|
|
||||||
// basic details
|
// basic details
|
||||||
$output['icon'] = $app_details->icon();
|
$output['icon'] = $app_details->icon();
|
||||||
|
$output['iconview'] = $app_details->iconView();
|
||||||
$output['colour'] = $app_details->defaultColour();
|
$output['colour'] = $app_details->defaultColour();
|
||||||
|
|
||||||
// live details
|
// live details
|
||||||
|
@ -319,15 +320,11 @@ class ItemController extends Controller
|
||||||
{
|
{
|
||||||
$item = Item::find($id);
|
$item = Item::find($id);
|
||||||
|
|
||||||
$config = json_decode($item->description);
|
$config = $item->config();
|
||||||
if(isset($config->type)) {
|
if(isset($config->type)) {
|
||||||
$config->url = $item->url;
|
$application = new $config->type;
|
||||||
if(isset($config->override_url) && !empty($config->override_url)) {
|
$application->config = $config;
|
||||||
$config->url = $config->override_url;
|
echo $application->livestats();
|
||||||
}
|
|
||||||
$app_details = new $config->type;
|
|
||||||
$app_details->config = $config;
|
|
||||||
echo $app_details->executeConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -345,10 +342,15 @@ class ItemController extends Controller
|
||||||
} else {
|
} else {
|
||||||
// check if there has been an update for this app
|
// check if there has been an update for this app
|
||||||
$localapp = $localapps->where('name', $app->name)->first();
|
$localapp = $localapps->where('name', $app->name)->first();
|
||||||
|
if($localapp) {
|
||||||
if($localapp->sha !== $app->sha) {
|
if($localapp->sha !== $app->sha) {
|
||||||
SupportedApps::getFiles($app);
|
SupportedApps::getFiles($app);
|
||||||
SupportedApps::saveApp($app, $localapp);
|
SupportedApps::saveApp($app, $localapp);
|
||||||
}
|
}
|
||||||
|
} else { // local folder, add to database
|
||||||
|
$application = new Application;
|
||||||
|
SupportedApps::saveApp($app, $application);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
40
app/Item.php
40
app/Item.php
|
@ -45,24 +45,6 @@ class Item extends Model
|
||||||
return $query->where('pinned', 1);
|
return $query->where('pinned', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConfigAttribute()
|
|
||||||
{
|
|
||||||
$output = null;
|
|
||||||
$view = null;
|
|
||||||
if(isset($this->description) && !empty($this->description)){
|
|
||||||
$output = json_decode($this->description);
|
|
||||||
$output = is_object($output) ? $output : new \stdClass();
|
|
||||||
if(isset($output->type) && !empty($output->type)) {
|
|
||||||
$class = $output->type;
|
|
||||||
$sap = new $class();
|
|
||||||
$view = $sap->configDetails();
|
|
||||||
$output->view = $view;
|
|
||||||
}
|
|
||||||
if(!isset($output->dataonly)) $output->dataonly = '0';
|
|
||||||
|
|
||||||
}
|
|
||||||
return (object)$output;
|
|
||||||
}
|
|
||||||
public static function checkConfig($config)
|
public static function checkConfig($config)
|
||||||
{
|
{
|
||||||
if(empty($config)) {
|
if(empty($config)) {
|
||||||
|
@ -156,6 +138,28 @@ class Item extends Model
|
||||||
return $query->where('type', $typeid);
|
return $query->where('type', $typeid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function enhanced()
|
||||||
|
{
|
||||||
|
$details = $this->config();
|
||||||
|
$class = $details->type;
|
||||||
|
$app = new $class;
|
||||||
|
return (bool)($app instanceof \App\EnhancedApps);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function config()
|
||||||
|
{
|
||||||
|
$config = json_decode($this->description);
|
||||||
|
|
||||||
|
$config->url = $this->url;
|
||||||
|
if(isset($config->override_url) && !empty($config->override_url)) {
|
||||||
|
$config->url = $config->override_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the user that owns the item.
|
* Get the user that owns the item.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5,7 +5,6 @@ use GuzzleHttp\Client;
|
||||||
|
|
||||||
abstract class SupportedApps
|
abstract class SupportedApps
|
||||||
{
|
{
|
||||||
public $config;
|
|
||||||
|
|
||||||
public function test($url, $requiresLoginFirst=false)
|
public function test($url, $requiresLoginFirst=false)
|
||||||
{
|
{
|
||||||
|
@ -14,9 +13,14 @@ abstract class SupportedApps
|
||||||
|
|
||||||
public function execute($url, $requiresLoginFirst=false)
|
public function execute($url, $requiresLoginFirst=false)
|
||||||
{
|
{
|
||||||
|
if($requiresLoginFirst) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]);
|
||||||
|
return $client->request('GET', $url);
|
||||||
|
}
|
||||||
|
|
||||||
public function login()
|
public function login()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -27,6 +31,18 @@ abstract class SupportedApps
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getLiveStats($status, $data)
|
||||||
|
{
|
||||||
|
$className = get_class($this);
|
||||||
|
$explode = explode('\\', $className);
|
||||||
|
$name = end($explode);
|
||||||
|
|
||||||
|
$html = view('SupportedApps::'.$name.'.livestats', $data)->with('data', $data)->render();
|
||||||
|
return json_encode(['status' => $status, 'html' => $html]);
|
||||||
|
//return
|
||||||
|
}
|
||||||
|
|
||||||
public static function getList()
|
public static function getList()
|
||||||
{
|
{
|
||||||
$list_url = 'https://apps.heimdall.site/list';
|
$list_url = 'https://apps.heimdall.site/list';
|
||||||
|
@ -60,11 +76,16 @@ abstract class SupportedApps
|
||||||
|
|
||||||
$app->name = $details->name;
|
$app->name = $details->name;
|
||||||
$app->sha = $details->sha;
|
$app->sha = $details->sha;
|
||||||
$app->icon = 'storage/supportedapps/'.$details->icon;
|
$app->icon = 'supportedapps/'.$details->icon;
|
||||||
$app->website = $details->website;
|
$app->website = $details->website;
|
||||||
$app->license = $details->license;
|
$app->license = $details->license;
|
||||||
$app->description = $details->description;
|
$app->description = $details->description;
|
||||||
$app->enhanced = $details->enhanced;
|
|
||||||
|
$appclass = $app->class();
|
||||||
|
$application = new $appclass;
|
||||||
|
$enhanced = (bool)($application instanceof \App\EnhancedApps);
|
||||||
|
|
||||||
|
$app->enhanced = $enhanced;
|
||||||
$app->tile_background = $details->tile_background;
|
$app->tile_background = $details->tile_background;
|
||||||
$app->save();
|
$app->save();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
@endif
|
@endif
|
||||||
<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(isset($app->config->enabled) && ((bool)$app->config->enabled === true))
|
@if($app->enhanced())
|
||||||
<div data-id="{{ $app->id }}" data-dataonly="{{ $app->config->dataonly or '0' }}" class="livestats-container"></div>
|
<div data-id="{{ $app->id }}" data-dataonly="{{ $app->config()->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>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
source: availableTags,
|
source: availableTags,
|
||||||
select: function( event, ui ) {
|
select: function( event, ui ) {
|
||||||
$.post('/appload', { app: ui.item.value }, function(data) {
|
$.post('/appload', { app: ui.item.value }, function(data) {
|
||||||
$('#appimage').html("<img src='"+data.icon+"' /><input type='hidden' name='icon' value='"+data.icon+"' />");
|
$('#appimage').html("<img src='"+data.iconview+"' /><input type='hidden' name='icon' value='"+data.icon+"' />");
|
||||||
$('input[name=colour]').val(data.colour);
|
$('input[name=colour]').val(data.colour);
|
||||||
hueb.setColor( data.colour );
|
hueb.setColor( data.colour );
|
||||||
$('input[name=pinned]').prop('checked', true);
|
$('input[name=pinned]').prop('checked', true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue