work on applications
This commit is contained in:
parent
40d6808067
commit
4fb59385b7
8 changed files with 52 additions and 100 deletions
app
config
database/migrations
resources/views/items
|
@ -7,4 +7,25 @@ use Illuminate\Database\Eloquent\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'));
|
||||
}
|
||||
|
||||
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
|
||||
*
|
||||
|
@ -291,19 +281,20 @@ class ItemController extends Controller
|
|||
public function appload(Request $request)
|
||||
{
|
||||
$output = [];
|
||||
$app = $request->input('app');
|
||||
$appname = $request->input('app');
|
||||
|
||||
if(($app_details = $this->isSupportedAppByKey($app)) !== false) {
|
||||
// basic details
|
||||
$output['icon'] = $app_details->icon();
|
||||
$output['colour'] = $app_details->defaultColour();
|
||||
$app_details = Application::where('name', $appname)->firstOrFail();
|
||||
$app = new $appname->class();
|
||||
|
||||
// live details
|
||||
if($app_details instanceof \App\SupportedApps\Contracts\Livestats) {
|
||||
$output['config'] = $app_details->configDetails();
|
||||
} else {
|
||||
$output['config'] = null;
|
||||
}
|
||||
// basic details
|
||||
$output['icon'] = $app_details->icon();
|
||||
$output['colour'] = $app_details->defaultColour();
|
||||
|
||||
// live details
|
||||
if($app_details instanceof \App\SupportedApps\EnhancedApps) {
|
||||
$output['config'] = $app->configDetails();
|
||||
} else {
|
||||
$output['config'] = null;
|
||||
}
|
||||
|
||||
return json_encode($output);
|
||||
|
|
76
app/Item.php
76
app/Item.php
|
@ -34,82 +34,6 @@ class Item extends Model
|
|||
*/
|
||||
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.
|
||||
*
|
||||
|
|
|
@ -229,6 +229,9 @@ return [
|
|||
'Validator' => Illuminate\Support\Facades\Validator::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()
|
||||
{
|
||||
Schema::create('applications', function (Blueprint $table) {
|
||||
|
||||
$table->increments('id');
|
||||
$table->string('name')->unique();
|
||||
$table->string('sha');
|
||||
$table->string('sha')->unique()->nullable();
|
||||
$table->string('icon')->nullable();
|
||||
$table->string('website')->nullable();
|
||||
$table->string('license')->nullable();
|
||||
$table->mediumText('description')->nullable();
|
||||
$table->boolean('enhanced')->default(false);
|
||||
$table->string('tile_background')->default('dark');
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<script src="/js/select2.min.js"></script>
|
||||
<script src="{{ asset('js/select2.min.js') }}"></script>
|
||||
<script>
|
||||
$( function() {
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
|||
// options
|
||||
});
|
||||
|
||||
var availableTags = @json(App\Item::supportedOptions());
|
||||
var availableTags = @json(App\Application::all()->pluck('name'));
|
||||
|
||||
$( "#appname" ).autocomplete({
|
||||
source: availableTags,
|
||||
|
|
Loading…
Add table
Reference in a new issue