including some more dashboard components
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\SupportedApps\Jellyfin;
|
||||
|
||||
class Jellyfin extends \App\SupportedApps implements \App\EnhancedApps
|
||||
{
|
||||
public $config;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
$test = parent::appTest(
|
||||
$this->url("System/Info"),
|
||||
$this->getAttrs()
|
||||
);
|
||||
echo $test->status;
|
||||
}
|
||||
|
||||
public function livestats()
|
||||
{
|
||||
$status = "inactive";
|
||||
$res = parent::execute($this->url("Items/Counts"), $this->getAttrs());
|
||||
$result = json_decode($res->getBody());
|
||||
$details = ["visiblestats" => []];
|
||||
foreach ($this->config->availablestats as $stat) {
|
||||
$newstat = new \stdClass();
|
||||
$newstat->title = self::getAvailableStats()[$stat];
|
||||
$newstat->value = $result->{$stat};
|
||||
$details["visiblestats"][] = $newstat;
|
||||
}
|
||||
return parent::getLiveStats($status, $details);
|
||||
}
|
||||
public function url($endpoint)
|
||||
{
|
||||
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
|
||||
return $api_url;
|
||||
}
|
||||
|
||||
private function getAttrs()
|
||||
{
|
||||
$authorizationHeader = "MediaBrowser " .
|
||||
"Token=\"" . urlencode($this->config->password) . "\", " .
|
||||
"Client=\"Heimdall\"";
|
||||
return [
|
||||
"headers" => [
|
||||
"Authorization" => $authorizationHeader,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public static function getAvailableStats()
|
||||
{
|
||||
return [
|
||||
"MovieCount" => "Movies",
|
||||
"SeriesCount" => "Series",
|
||||
"EpisodeCount" => "Episodes",
|
||||
"ArtistCount" => "Artists",
|
||||
"ProgramCount" => "Programs",
|
||||
"TrailerCount" => "Trailers",
|
||||
"SongCount" => "Songs",
|
||||
"AlbumCount" => "Albums",
|
||||
"MusicVideoCount" => "MusicVideos",
|
||||
"BoxSetCount" => "BoxSets",
|
||||
"BookCount" => "Books",
|
||||
"ItemCount" => "Items",
|
||||
];
|
||||
}
|
||||
}
|
||||
10
stacks/dashboard/config/www/SupportedApps/Jellyfin/app.json
Normal file
10
stacks/dashboard/config/www/SupportedApps/Jellyfin/app.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"appid": "3e0a7f109bd760b9474c78cb652e8c3e82669226",
|
||||
"name": "Jellyfin",
|
||||
"website": "https://jellyfin.github.io",
|
||||
"license": "GNU General Public License v2.0 only",
|
||||
"description": "Jellyfin is the Free Software Media System that puts you in control of managing and streaming your media. There are no strings attached, no premium licenses or features, and no hidden agendas.",
|
||||
"enhanced": true,
|
||||
"tile_background": "dark",
|
||||
"icon": "jellyfin.svg"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
|
||||
<div class="items">
|
||||
<div class="input">
|
||||
<label>{{ strtoupper(__('app.url')) }}</label>
|
||||
{!! Form::text('config[override_url]', isset($item) ? $item->getconfig()->override_url : null, ['placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control']) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>{{ __('app.apps.password') }} (secret token)</label>
|
||||
{!! Form::input('password', 'config[password]', '', ['placeholder' => __('app.apps.password'), 'data-config' => 'password', 'class' => 'form-control config-item']) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>Stats to show</label>
|
||||
{!! Form::select('config[availablestats][]', App\SupportedApps\Jellyfin\Jellyfin::getAvailableStats(), isset($item) ? $item->getConfig()->availablestats ?? null : null, ['multiple' => 'multiple']) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
<ul class="livestats">
|
||||
@foreach ($visiblestats as $stat)
|
||||
<li>
|
||||
<span class="title">{!! $stat->title !!}</span>
|
||||
<strong>{!! $stat->value !!}</strong>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
Reference in New Issue
Block a user