work on applications
This commit is contained in:
parent
40d6808067
commit
4fb59385b7
|
@ -7,4 +7,25 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
class Application extends Model
|
class Application extends Model
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
public function icon()
|
||||||
|
{
|
||||||
|
$path = public_path('storage/apps/'.$this->icon);
|
||||||
|
if(!file_exists($path)) {
|
||||||
|
Storage::putFileAs('apps', new File(app_path('Apps/'.$this->name.'/'.$this->icon)), $this->icon);
|
||||||
|
}
|
||||||
|
return asset('storage/apps/'.$this->icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defaultColour()
|
||||||
|
{
|
||||||
|
// check if light or dark
|
||||||
|
if($this->tile_background == 'light') return '#fafbfc';
|
||||||
|
return '#161b1f';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function class()
|
||||||
|
{
|
||||||
|
$class = '\App\SupportedApps\\'.$this->name;
|
||||||
|
return $class;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
0
app/Apps/.gitignore
vendored
0
app/Apps/.gitignore
vendored
11
app/EnhancedApps.php
Normal file
11
app/EnhancedApps.php
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?php namespace App;
|
||||||
|
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
|
||||||
|
interface EnhancedApps {
|
||||||
|
{
|
||||||
|
public $config;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -273,16 +273,6 @@ class ItemController extends Controller
|
||||||
->with('success',__('app.alert.success.item_restored'));
|
->with('success',__('app.alert.success.item_restored'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSupportedAppByKey($app)
|
|
||||||
{
|
|
||||||
$output = false;
|
|
||||||
$all_supported = Item::supportedList();
|
|
||||||
if(array_key_exists($app, $all_supported)) {
|
|
||||||
$output = new $all_supported[$app];
|
|
||||||
}
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return details for supported apps
|
* Return details for supported apps
|
||||||
*
|
*
|
||||||
|
@ -291,20 +281,21 @@ class ItemController extends Controller
|
||||||
public function appload(Request $request)
|
public function appload(Request $request)
|
||||||
{
|
{
|
||||||
$output = [];
|
$output = [];
|
||||||
$app = $request->input('app');
|
$appname = $request->input('app');
|
||||||
|
|
||||||
|
$app_details = Application::where('name', $appname)->firstOrFail();
|
||||||
|
$app = new $appname->class();
|
||||||
|
|
||||||
if(($app_details = $this->isSupportedAppByKey($app)) !== false) {
|
|
||||||
// basic details
|
// basic details
|
||||||
$output['icon'] = $app_details->icon();
|
$output['icon'] = $app_details->icon();
|
||||||
$output['colour'] = $app_details->defaultColour();
|
$output['colour'] = $app_details->defaultColour();
|
||||||
|
|
||||||
// live details
|
// live details
|
||||||
if($app_details instanceof \App\SupportedApps\Contracts\Livestats) {
|
if($app_details instanceof \App\SupportedApps\EnhancedApps) {
|
||||||
$output['config'] = $app_details->configDetails();
|
$output['config'] = $app->configDetails();
|
||||||
} else {
|
} else {
|
||||||
$output['config'] = null;
|
$output['config'] = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return json_encode($output);
|
return json_encode($output);
|
||||||
}
|
}
|
||||||
|
|
76
app/Item.php
76
app/Item.php
|
@ -34,82 +34,6 @@ class Item extends Model
|
||||||
*/
|
*/
|
||||||
protected $dates = ['deleted_at'];
|
protected $dates = ['deleted_at'];
|
||||||
|
|
||||||
public static function supportedList()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'AirSonic' => \App\SupportedApps\AirSonic::class,
|
|
||||||
'Cardigann' => \App\SupportedApps\Cardigann::class,
|
|
||||||
'CouchPotato' => \App\SupportedApps\CouchPotato::class,
|
|
||||||
'Bazarr' => \App\SupportedApps\Bazarr::class,
|
|
||||||
'Bitwarden' => \App\SupportedApps\Bitwarden::class,
|
|
||||||
'Booksonic' => \App\SupportedApps\Booksonic::class,
|
|
||||||
'BookStack' => \App\SupportedApps\BookStack::class,
|
|
||||||
'Deluge' => \App\SupportedApps\Deluge::class,
|
|
||||||
'Dokuwiki' => \App\SupportedApps\Dokuwiki::class,
|
|
||||||
'Duplicati' => \App\SupportedApps\Duplicati::class,
|
|
||||||
'Emby' => \App\SupportedApps\Emby::class,
|
|
||||||
'Flood' => \App\SupportedApps\Flood::class,
|
|
||||||
'FreshRSS' => \App\SupportedApps\FreshRSS::class,
|
|
||||||
'Gitea' => \App\SupportedApps\Gitea::class,
|
|
||||||
'Glances' => \App\SupportedApps\Glances::class,
|
|
||||||
'Grafana' => \App\SupportedApps\Grafana::class,
|
|
||||||
'Graylog' => \App\SupportedApps\Graylog::class,
|
|
||||||
'Headphones' => \App\SupportedApps\Headphones::class,
|
|
||||||
'Home Assistant' => \App\SupportedApps\HomeAssistant::class,
|
|
||||||
'Jackett' => \App\SupportedApps\Jackett::class,
|
|
||||||
'Jdownloader' => \App\SupportedApps\Jdownloader::class,
|
|
||||||
'Krusader' => \App\SupportedApps\Krusader::class,
|
|
||||||
'LibreNMS' => \App\SupportedApps\LibreNMS::class,
|
|
||||||
'Lidarr' => \App\SupportedApps\Lidarr::class,
|
|
||||||
'Mailcow' => \App\SupportedApps\Mailcow::class,
|
|
||||||
'Mcmyadmin' => \App\SupportedApps\Mcmyadmin::class,
|
|
||||||
'Medusa' => \App\SupportedApps\Medusa::class,
|
|
||||||
'Monica' => \App\SupportedApps\Monica::class,
|
|
||||||
'MusicBrainz' => \App\SupportedApps\MusicBrainz::class,
|
|
||||||
'Mylar' => \App\SupportedApps\Mylar::class,
|
|
||||||
'NZBGet' => \App\SupportedApps\Nzbget::class,
|
|
||||||
'Netdata' => \App\SupportedApps\Netdata::class,
|
|
||||||
'Nextcloud' => \App\SupportedApps\Nextcloud::class,
|
|
||||||
'Now Showing' => \App\SupportedApps\NowShowing::class,
|
|
||||||
'Nzbhydra' => \App\SupportedApps\Nzbhydra::class,
|
|
||||||
'OPNSense' => \App\SupportedApps\Opnsense::class,
|
|
||||||
'Ombi' => \App\SupportedApps\Ombi::class,
|
|
||||||
'Openhab' => \App\SupportedApps\Openhab::class,
|
|
||||||
'OpenMediaVault' => \App\SupportedApps\OpenMediaVault::class,
|
|
||||||
'Pihole' => \App\SupportedApps\Pihole::class,
|
|
||||||
'Plex' => \App\SupportedApps\Plex::class,
|
|
||||||
'Plexpy' => \App\SupportedApps\Plexpy::class,
|
|
||||||
'Plexrequests' => \App\SupportedApps\Plexrequests::class,
|
|
||||||
'Portainer' => \App\SupportedApps\Portainer::class,
|
|
||||||
'Proxmox' => \App\SupportedApps\Proxmox::class,
|
|
||||||
'Radarr' => \App\SupportedApps\Radarr::class,
|
|
||||||
'Rancher' => \App\SupportedApps\Rancher::class,
|
|
||||||
'Runeaudio' => \App\SupportedApps\Runeaudio::class,
|
|
||||||
'Sabnzbd' => \App\SupportedApps\Sabnzbd::class,
|
|
||||||
'Sickrage' => \App\SupportedApps\Sickrage::class,
|
|
||||||
'Sonarr' => \App\SupportedApps\Sonarr::class,
|
|
||||||
'Syncthing' => \App\SupportedApps\Syncthing::class,
|
|
||||||
'Tautulli' => \App\SupportedApps\Tautulli::class,
|
|
||||||
'Transmission' => \App\SupportedApps\Transmission::class,
|
|
||||||
'Traefik' => \App\SupportedApps\Traefik::class,
|
|
||||||
'tt-rss' => \App\SupportedApps\Ttrss::class,
|
|
||||||
'TVheadend' => \App\SupportedApps\TVheadend::class,
|
|
||||||
'UniFi' => \App\SupportedApps\Unifi::class,
|
|
||||||
'unRAID' => \App\SupportedApps\Unraid::class,
|
|
||||||
'pfSense' => \App\SupportedApps\Pfsense::class,
|
|
||||||
'pyLoad' => \App\SupportedApps\pyLoad::class,
|
|
||||||
'ruTorrent' => \App\SupportedApps\ruTorrent::class,
|
|
||||||
'Virtualmin' => \App\SupportedApps\Virtualmin::class,
|
|
||||||
'Watcher3' => \App\SupportedApps\Watcher3::class,
|
|
||||||
'Webmin' => \App\SupportedApps\Webmin::class,
|
|
||||||
'WebTools' => \App\SupportedApps\WebTools::class,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
public static function supportedOptions()
|
|
||||||
{
|
|
||||||
return array_keys(self::supportedList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scope a query to only include pinned items.
|
* Scope a query to only include pinned items.
|
||||||
*
|
*
|
||||||
|
|
|
@ -229,6 +229,9 @@ return [
|
||||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||||
'View' => Illuminate\Support\Facades\View::class,
|
'View' => Illuminate\Support\Facades\View::class,
|
||||||
|
|
||||||
|
'SupportedApps' => App\SupportedApps::class,
|
||||||
|
'EnhancedApps' => App\EnhancedApps::class,
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -14,14 +14,16 @@ class CreateApplicationsTable extends Migration
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('applications', function (Blueprint $table) {
|
Schema::create('applications', function (Blueprint $table) {
|
||||||
|
|
||||||
$table->increments('id');
|
$table->increments('id');
|
||||||
$table->string('name')->unique();
|
$table->string('name')->unique();
|
||||||
$table->string('sha');
|
$table->string('sha')->unique()->nullable();
|
||||||
$table->string('icon')->nullable();
|
$table->string('icon')->nullable();
|
||||||
$table->string('website')->nullable();
|
$table->string('website')->nullable();
|
||||||
$table->string('license')->nullable();
|
$table->string('license')->nullable();
|
||||||
$table->mediumText('description')->nullable();
|
$table->mediumText('description')->nullable();
|
||||||
$table->boolean('enhanced')->default(false);
|
$table->boolean('enhanced')->default(false);
|
||||||
|
$table->string('tile_background')->default('dark');
|
||||||
|
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<script src="/js/select2.min.js"></script>
|
<script src="{{ asset('js/select2.min.js') }}"></script>
|
||||||
<script>
|
<script>
|
||||||
$( function() {
|
$( function() {
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
// options
|
// options
|
||||||
});
|
});
|
||||||
|
|
||||||
var availableTags = @json(App\Item::supportedOptions());
|
var availableTags = @json(App\Application::all()->pluck('name'));
|
||||||
|
|
||||||
$( "#appname" ).autocomplete({
|
$( "#appname" ).autocomplete({
|
||||||
source: availableTags,
|
source: availableTags,
|
||||||
|
|
Loading…
Reference in a new issue