Initial start of replacing apps list to use github generated list

This commit is contained in:
Kode 2022-03-14 15:56:36 +00:00
parent 371f52f92e
commit 4c63b66dbf
12 changed files with 106 additions and 24 deletions

View file

@ -39,23 +39,49 @@ class Application extends Model
public function class()
{
$name = $this->name;
$name = preg_replace('/\PL/u', '', $name);
$name = preg_replace('/[^\p{L}\p{N}]/u', '', $name);
$class = '\App\SupportedApps\\'.$name.'\\'.$name;
return $class;
}
public static function apps()
{
$json = json_decode(file_get_contents(storage_path('app/supportedapps.json'))) ?? [];
$apps = collect($json->apps);
$sorted = $apps->sortBy('name', SORT_NATURAL|SORT_FLAG_CASE);
return $sorted;
}
public static function autocomplete()
{
$apps = self::apps();
$list = [];
foreach($apps as $app) {
$list[] = (object)[
'label' => $app->name,
'value' => $app->appid
];
}
return $list;
}
public static function single($appid)
{
$apps = self::apps();
$app = $apps->where('appid', $appid)->first();
$classname = preg_replace('/[^\p{L}\p{N}]/u', '', $app->name);
$app->class = '\App\SupportedApps\\'.$classname.'\\'.$classname;
return $app;
}
public static function applist()
{
$list = [];
$all = self::orderBy('name')->get()->sortBy('name', SORT_NATURAL|SORT_FLAG_CASE);
$list['null'] = 'None';
foreach($all as $app) {
$name = $app->name;
// $name = preg_replace('/\PL/u', '', $name);
$name = preg_replace('/[^\p{L}\p{N}]/u', '', $name);
$list['\App\SupportedApps\\'.$name.'\\'.$name] = $app->name;
$apps = self::apps();
foreach($apps as $app) {
$list[$app->appid] = $app->name;
}
return $list;
}

View file

@ -73,7 +73,7 @@ function getLinkTargetAttribute()
function className($name)
{
$name = preg_replace('/\PL/u', '', $name);
$name = preg_replace('/[^\p{L}\p{N}]/u', '', $name);
return $name;
}

View file

@ -319,7 +319,8 @@ class ItemController extends Controller
public function appload(Request $request)
{
$output = [];
$appname = $request->input('app');
$appid = $request->input('app');
/*$appname = $request->input('app');
//die($appname);
$app_details = Application::where('name', $appname)->firstOrFail();
@ -338,7 +339,15 @@ class ItemController extends Controller
$output['config'] = className($app_details->name).'.config';
} else {
$output['config'] = null;
}
}*/
$app = Application::single($appid);
$output = (array)$app;
$output['config'] = null;
$output['colour'] = ($app->tile_background == 'light') ? '#fafbfc' : '#161b1f';
$output['iconview'] = 'https://raw.githubusercontent.com/linuxserver/Heimdall-Apps/master/' . preg_replace('/[^\p{L}\p{N}]/u', '', $app->name) . '/' . $app->icon;
;
return json_encode($output);
}

View file

@ -7,6 +7,7 @@ use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Storage;
use App\Application;
use App\SupportedApps;
@ -32,8 +33,11 @@ class ProcessApps implements ShouldQueue
public function handle()
{
$localapps = Application::all();
$list = json_decode(SupportedApps::getList()->getBody());
$validapps = [];
$json = SupportedApps::getList()->getBody();
Storage::disk('local')->put('supportedapps.json', $json);
/* $validapps = [];
foreach($list->apps as $app) {
$validapps[] = $app->appid;
@ -58,7 +62,7 @@ class ProcessApps implements ShouldQueue
}
}
}
}*/
//$delete = Application::whereNotIn('appid', $validapps)->delete(); // delete any apps not in list
// removed the delete so local apps can be added

View file

@ -107,7 +107,8 @@ abstract class SupportedApps
public static function getList()
{
$list_url = 'https://apps.heimdall.site/list';
// $list_url = 'https://apps.heimdall.site/list';
$list_url = 'https://appslist.heimdall.site/list.json';
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]);
return $client->request('GET', $list_url);
}

18
public/css/app.css vendored
View file

@ -1,3 +1,4 @@
@charset "UTF-8";
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
html {
font-family: sans-serif;
@ -420,6 +421,23 @@ body {
line-height: 30px;
display: none;
}
.item-container .tooltip {
padding: 25px;
border-radius: 5px;
background: #00000038;
color: white;
position: absolute;
bottom: 120px;
left: 0;
right: 0;
font-size: 13px;
-webkit-backdrop-filter: blur(8px);
backdrop-filter: blur(8px);
display: none;
}
.item-container:hover .tooltip {
display: block;
}
.black {
color: #000 !important;

View file

@ -1,4 +1,4 @@
{
"/css/app.css": "/css/app.css?id=bafda2139c75830558d2",
"/js/app.js": "/js/app.js?id=0ff185efa8c02e94999e"
"/css/app.css": "/css/app.css?id=7de7134287f332b33a25",
"/js/app.js": "/js/app.js?id=d04c0e0d819506e10194"
}

View file

@ -201,6 +201,24 @@ body {
line-height: 30px;
display: none;
}
.tooltip {
padding: 25px;
border-radius: 5px;
background: #00000038;
color: white;
position: absolute;
bottom: 120px;
left: 0;
right: 0;
font-size: 13px;
backdrop-filter: blur(8px);
display: none;
}
&:hover {
.tooltip {
display: block;
}
}
}
.black {
color: #000!important;

View file

@ -14,5 +14,5 @@
<a rel="noopener noreferrer" title="{{ App\Item::getApplicationDescription($app->class) }}" class="link{{ title_color($app->colour) }}"{!! $app->link_target !!} href="{{ $app->link }}"><i class="fas {{ $app->link_icon }}"></i></a>
</div>
<a class="item-edit" href="{{ route($app->link_type.'.edit', [ $app->id ]) }}"><i class="fas fa-pencil"></i></a>
@if(App\Item::getApplicationDescription($app->class) !== '')<div class="tooltip">{{ App\Item::getApplicationDescription($app->class) }}</div>@endif
</section>

View file

@ -19,13 +19,15 @@
});
})
var availableTags = @json(App\Application::all()->pluck('name'));
var availableTags = @json(App\Application::autocomplete());
console.log(availableTags)
$( "#appname" ).autocomplete({
source: availableTags,
select: function( event, ui ) {
var appvalue = ui.item.value;
appload(appvalue);
event.preventDefault();
// appload(ui.item.value);
$( "#appname" ).val(ui.item.label)
$('#apptype').val(ui.item.value).change()
}
});
// initial load
@ -38,7 +40,7 @@
$('#tile-preview .title').html($(this).val());
})
$('#apptype').on('change', function(e) {
appload($(this).find('option:selected').text());
appload($(this).find('option:selected').val());
});
$('#appcolour').on('change', function(e) {
$('#tile-preview .item').css('backgroundColor', $(this).val());
@ -56,7 +58,7 @@
// Main details
$('#appimage').html("<img src='"+data.iconview+"' /><input type='hidden' name='icon' value='"+data.icon+"' />");
$('input[name=colour]').val(data.colour);
$('select[name=class]').val(data.class);
$('select[name=class]').val(data.appid);
hueb.setColor( data.colour );
$('input[name=pinned]').prop('checked', true);
// Preview details

View file

@ -23,6 +23,9 @@ Route::get('/autologin/{uuid}', 'Auth\LoginController@autologin')->name('user.au
Route::get('/', 'ItemController@dash')->name('dash');
Route::get('check_app_list', 'ItemController@checkAppList')->name('applist');
Route::get('single/{appid}', function($appid) {
return json_encode(\App\Application::single($appid));
})->name('single');
Route::resources([
'items' => 'ItemController',

File diff suppressed because one or more lines are too long