ajout heimdall
This commit is contained in:
65
heimdall/config/www/SupportedApps/Bookstack/Bookstack.php
Executable file
65
heimdall/config/www/SupportedApps/Bookstack/Bookstack.php
Executable file
@@ -0,0 +1,65 @@
|
||||
<?php namespace App\SupportedApps\Bookstack;
|
||||
|
||||
class Bookstack extends \App\SupportedApps implements \App\EnhancedApps {
|
||||
|
||||
public $config;
|
||||
|
||||
//protected $login_first = true; // Uncomment if api requests need to be authed first
|
||||
//protected $method = 'POST'; // Uncomment if requests to the API should be set by POST
|
||||
|
||||
function __construct() {
|
||||
//$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set
|
||||
}
|
||||
|
||||
public function getHeaders()
|
||||
{
|
||||
$api_token = $this->config->api_token.":".$this->config->api_secret;
|
||||
|
||||
$attrs['headers'] = ['Authorization' => 'Token '.$api_token];
|
||||
return $attrs;
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
$test = parent::appTest($this->url('/api/shelves?count=0'), $this->getHeaders());
|
||||
echo $test->status;
|
||||
}
|
||||
|
||||
public function livestats()
|
||||
{
|
||||
$status = 'inactive';
|
||||
|
||||
$attrs = $this->getHeaders();
|
||||
|
||||
$data = ['visiblestats' => []];
|
||||
|
||||
foreach($this->config->availablestats as $stat) {
|
||||
if (!isset(self::getAvailableStats()[$stat])) continue;
|
||||
|
||||
$res = parent::execute($this->url('/api/'.$stat.'?count=0'), $attrs);
|
||||
$details = json_decode($res->getBody());
|
||||
|
||||
$newstat = new \stdClass();
|
||||
$newstat->title = self::getAvailableStats()[$stat];
|
||||
$newstat->value = isset($details->total) ? number_format($details->total) : 'N/A';
|
||||
|
||||
$data['visiblestats'][] = $newstat;
|
||||
}
|
||||
|
||||
return parent::getLiveStats($status, $data);
|
||||
}
|
||||
|
||||
public function url($endpoint)
|
||||
{
|
||||
$api_url = parent::normaliseurl($this->config->url).$endpoint;
|
||||
return $api_url;
|
||||
}
|
||||
|
||||
public static function getAvailableStats() {
|
||||
return [
|
||||
'shelves'=>'Shelves',
|
||||
'books'=>'Books',
|
||||
'chapters'=>'Chapters',
|
||||
];
|
||||
}
|
||||
}
|
||||
10
heimdall/config/www/SupportedApps/Bookstack/app.json
Executable file
10
heimdall/config/www/SupportedApps/Bookstack/app.json
Executable file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"appid": "348c49dd03dddd418929316668d2e67bf2d9ae88",
|
||||
"name": "Bookstack",
|
||||
"website": "https://www.bookstackapp.com/",
|
||||
"license": "MIT License",
|
||||
"description": "BookStack is a simple, self-hosted, easy-to-use platform for organising and storing information.",
|
||||
"enhanced": true,
|
||||
"tile_background": "dark",
|
||||
"icon": "bookstack.png"
|
||||
}
|
||||
BIN
heimdall/config/www/SupportedApps/Bookstack/bookstack.png
Executable file
BIN
heimdall/config/www/SupportedApps/Bookstack/bookstack.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
23
heimdall/config/www/SupportedApps/Bookstack/config.blade.php
Executable file
23
heimdall/config/www/SupportedApps/Bookstack/config.blade.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<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) : null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>Token ID</label>
|
||||
{!! Form::text('config[api_token]', null, array('placeholder' => 'Token ID', 'data-config' => 'api_token', 'class' => 'form-control config-item')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>Token Secret</label>
|
||||
{!! Form::text('config[api_secret]', null, array('placeholder' => 'Token Secret', 'data-config' => 'api_secret', 'class' => 'form-control config-item')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>Stats to show</label>
|
||||
{!! Form::select('config[availablestats][]', App\SupportedApps\Bookstack\Bookstack::getAvailableStats(), isset($item) ? ($item->getConfig()->availablestats ?? null) : null, array('multiple'=>'multiple')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
8
heimdall/config/www/SupportedApps/Bookstack/livestats.blade.php
Executable file
8
heimdall/config/www/SupportedApps/Bookstack/livestats.blade.php
Executable file
@@ -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