Browse Source

Merge branch 'master' into patch-1

pull/146/head
KodeStar 7 years ago
committed by GitHub
parent
commit
95be8d4698
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      app/Item.php
  2. 122
      app/SupportedApps/CouchPotato.php
  3. 12
      app/SupportedApps/OpenMediaVault.php
  4. 12
      app/SupportedApps/WebTools.php
  5. 3
      readme.md
  6. 13
      resources/views/supportedapps/couchpotato.blade.php
  7. BIN
      storage/app/public/supportedapps/couchpotato.png
  8. BIN
      storage/app/public/supportedapps/openmediavault.png
  9. BIN
      storage/app/public/supportedapps/transmission.png
  10. BIN
      storage/app/public/supportedapps/webtools.png

7
app/Item.php

@ -27,6 +27,7 @@ class Item extends Model
{ {
return [ return [
'AirSonic' => \App\SupportedApps\AirSonic::class, 'AirSonic' => \App\SupportedApps\AirSonic::class,
'CouchPotato' => \App\SupportedApps\CouchPotato::class,
'Deluge' => \App\SupportedApps\Deluge::class, 'Deluge' => \App\SupportedApps\Deluge::class,
'Dokuwiki' => \App\SupportedApps\Dokuwiki::class, 'Dokuwiki' => \App\SupportedApps\Dokuwiki::class,
'Duplicati' => \App\SupportedApps\Duplicati::class, 'Duplicati' => \App\SupportedApps\Duplicati::class,
@ -48,6 +49,7 @@ class Item extends Model
'OPNSense' => \App\SupportedApps\Opnsense::class, 'OPNSense' => \App\SupportedApps\Opnsense::class,
'Ombi' => \App\SupportedApps\Ombi::class, 'Ombi' => \App\SupportedApps\Ombi::class,
'Openhab' => \App\SupportedApps\Openhab::class, 'Openhab' => \App\SupportedApps\Openhab::class,
'OpenMediaVault' => \App\SupportedApps\OpenMediaVault::class,
'Pihole' => \App\SupportedApps\Pihole::class, 'Pihole' => \App\SupportedApps\Pihole::class,
'Plex' => \App\SupportedApps\Plex::class, 'Plex' => \App\SupportedApps\Plex::class,
'Plexpy' => \App\SupportedApps\Plexpy::class, 'Plexpy' => \App\SupportedApps\Plexpy::class,
@ -62,10 +64,11 @@ class Item extends Model
'Tautulli' => \App\SupportedApps\Tautulli::class, 'Tautulli' => \App\SupportedApps\Tautulli::class,
'Transmission' => \App\SupportedApps\Transmission::class, 'Transmission' => \App\SupportedApps\Transmission::class,
'Traefik' => \App\SupportedApps\Traefik::class, 'Traefik' => \App\SupportedApps\Traefik::class,
'Ttrss' => \App\SupportedApps\Ttrss::class, 'tt-rss' => \App\SupportedApps\Ttrss::class,
'UniFi' => \App\SupportedApps\Unifi::class, 'UniFi' => \App\SupportedApps\Unifi::class,
'pFsense' => \App\SupportedApps\Pfsense::class, 'pfSense' => \App\SupportedApps\Pfsense::class,
'ruTorrent' => \App\SupportedApps\ruTorrent::class, 'ruTorrent' => \App\SupportedApps\ruTorrent::class,
'WebTools' => \App\SupportedApps\WebTools::class,
]; ];
} }
public static function supportedOptions() public static function supportedOptions()

122
app/SupportedApps/CouchPotato.php

@ -0,0 +1,122 @@
<?php namespace App\SupportedApps;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Log;
class CouchPotato implements Contracts\Applications, Contracts\Livestats
{
private $_client;
public function __construct()
{
$this->_client = new Client(
['http_errors' => false,
'timeout' => 10]
);
}
public function defaultColour()
{
return '#363840';
}
public function icon()
{
return 'supportedapps/couchPotato.png';
}
public function configDetails()
{
return 'couchpotato';
}
public function testConfig()
{
$res = $this->sendRequest();
if ($res == null) {
echo 'CouchPotato connection failed';
return;
}
switch($res->getStatusCode()) {
case 200:
echo "Successfully connected to CouchPotato";
break;
case 401:
echo 'Failed: Invalid credentials';
break;
case 404:
echo 'Failed: Please make sure your URL is correct and includes the port';
break;
case 409:
echo 'Failed: Incorrect session id';
break;
default:
echo 'Something went wrong... Code: '.$res->getStatusCode();
break;
}
}
public function executeConfig()
{
$html = '';
$res = $this->sendRequest();
if ($res == null) {
Log::debug('CouchPotato connection failed');
return '';
}
$data = json_decode($res->getBody());
if (! isset($data->movies)) {
Log::debug('Failed to fetch data from CouchPotato');
return '';
}
$movies = $data->movies;
$wantedMovies = $availableMovies = 0;
foreach ($movies as $v) {
switch ($v->status) {
case 'active':
$wantedMovies++;
break;
case 'done':
$availableMovies++;
break;
default:
Log::warning('Unexpected CouchPotato status received: '.$v['status']);
break;
}
}
$html = '
<ul class="livestats">
<li><span class="title">Wanted</span><sub>'.$wantedMovies.'</sub></li>
<li><span class="title">Available</span><sub>'.$availableMovies.'</sub></li>
</ul>
';
return json_encode(['status' => 'inactive', 'html' => $html]);
}
private function sendRequest()
{
$res = null;
try{
$res = $this->_client->request(
'GET',
$this->getApiUrl()
);
}catch(\GuzzleHttp\Exception\BadResponseException $e){
Log::error("Connection to {$e->getRequest()->getUrl()} failed");
Log::debug($e->getMessage());
$res = $e->getRequest();
}catch(\GuzzleHttp\Exception\ConnectException $e) {
Log::error("CouchPotato connection refused");
Log::debug($e->getMessage());
}
return $res;
}
private function getApiUrl()
{
$url = $this->config->url;
$url = rtrim($url, '/');
$apiUrl = $url.'/api/'.$this->config->apikey.'/movie.list';
return $apiUrl;
}
}

12
app/SupportedApps/OpenMediaVault.php

@ -0,0 +1,12 @@
<?php namespace App\SupportedApps;
class OpenMediaVault implements Contracts\Applications {
public function defaultColour()
{
return '#5AF';
}
public function icon()
{
return 'supportedapps/openmediavault.png';
}
}

12
app/SupportedApps/WebTools.php

@ -0,0 +1,12 @@
<?php namespace App\SupportedApps;
class WebTools implements Contracts\Applications {
public function defaultColour()
{
return '#555';
}
public function icon()
{
return 'supportedapps/webtools.png';
}
}

3
readme.md

@ -28,6 +28,7 @@ If you want to see a quick video of it in use, go to https://youtu.be/GXnnMAxPzM
You can use the app to link to any site or application, but Foundation apps will auto fill in the icon for the app and supply a default color for the tile. In addition Enhanced apps allow you provide details to an apps API, allowing you to view live stats directly on the dashboad. For example, the NZBGet and Sabnzbd Enhanced apps will display the queue size and download speed while something is downloading. You can use the app to link to any site or application, but Foundation apps will auto fill in the icon for the app and supply a default color for the tile. In addition Enhanced apps allow you provide details to an apps API, allowing you to view live stats directly on the dashboad. For example, the NZBGet and Sabnzbd Enhanced apps will display the queue size and download speed while something is downloading.
**Enhanced** **Enhanced**
- CouchPotato
- NZBGet - NZBGet
- Pihole - Pihole
- PlexPy - PlexPy
@ -55,6 +56,7 @@ You can use the app to link to any site or application, but Foundation apps will
- Nextcloud - Nextcloud
- Ombi - Ombi
- OpenHAB - OpenHAB
- OpenMediaVault
- Plex - Plex
- Plexrequests - Plexrequests
- Portainer - Portainer
@ -66,6 +68,7 @@ You can use the app to link to any site or application, but Foundation apps will
- UniFI - UniFI
- pfSense - pfSense
- rTorrent/ruTorrent - rTorrent/ruTorrent
- WebTools
## Installing ## Installing
Apart from the Laravel dependencies, namely PHP >= 7.0.0, OpenSSL PHP Extension, PDO PHP Extension, Mbstring PHP Extension, Tokenizer PHP Extension and XML PHP Extension, the only other thing Heimdall needs is sqlite support. Apart from the Laravel dependencies, namely PHP >= 7.0.0, OpenSSL PHP Extension, PDO PHP Extension, Mbstring PHP Extension, Tokenizer PHP Extension and XML PHP Extension, the only other thing Heimdall needs is sqlite support.

13
resources/views/supportedapps/couchpotato.blade.php

@ -0,0 +1,13 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }})</h2>
<div class="items">
<input type="hidden" name="config[enabled]" value="1" />
<input type="hidden" data-config="dataonly" class="config-item" name="config[dataonly]" value="1" />
<input type="hidden" data-config="type" class="config-item" name="config[type]" value="\App\SupportedApps\CouchPotato" />
<div class="input">
<label>{{ __('app.apps.apikey') }}</label>
{!! Form::text('config[apikey]', null, array('placeholder' => __('app.apps.apikey'), 'data-config' => 'apikey', 'class' => 'form-control config-item')) !!}
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
</div>

BIN
storage/app/public/supportedapps/couchpotato.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
storage/app/public/supportedapps/openmediavault.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
storage/app/public/supportedapps/transmission.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 19 KiB

BIN
storage/app/public/supportedapps/webtools.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Loading…
Cancel
Save