ajout heimdall
This commit is contained in:
67
heimdall/config/www/SupportedApps/PaperlessNgx/PaperlessNgx.php
Executable file
67
heimdall/config/www/SupportedApps/PaperlessNgx/PaperlessNgx.php
Executable file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\SupportedApps\PaperlessNgx;
|
||||
|
||||
class PaperlessNgx extends \App\SupportedApps implements \App\EnhancedApps
|
||||
{
|
||||
public $config;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function getRequestAttrs()
|
||||
{
|
||||
$apikey = $this->getConfigValue("apikey", null);
|
||||
|
||||
$attrs["headers"] = [
|
||||
"Accept" => "application/json",
|
||||
"Authorization" => "Token " . $apikey,
|
||||
];
|
||||
|
||||
return $attrs;
|
||||
}
|
||||
|
||||
|
||||
public function getConfigValue($key, $default = null)
|
||||
{
|
||||
return isset($this->config) && isset($this->config->$key)
|
||||
? $this->config->$key
|
||||
: $default;
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
$attrs = $this->getRequestAttrs();
|
||||
$test = parent::appTest($this->url("documents"), $attrs);
|
||||
echo $test->status;
|
||||
}
|
||||
|
||||
public function livestats()
|
||||
{
|
||||
$status = "inactive";
|
||||
$data = [];
|
||||
$attrs = $this->getRequestAttrs();
|
||||
|
||||
$documents = json_decode(
|
||||
parent::execute($this->url("statistics"), $attrs)->getBody()
|
||||
);
|
||||
|
||||
$data = [
|
||||
"documentCount" => $documents->documents_total ?? 0,
|
||||
"documentsInbox" => $documents->documents_inbox ?? 0
|
||||
];
|
||||
|
||||
return parent::getLiveStats($status, $data);
|
||||
}
|
||||
|
||||
public function url($endpoint)
|
||||
{
|
||||
$api_url =
|
||||
parent::normaliseurl($this->config->url) .
|
||||
"api/" .
|
||||
$endpoint .
|
||||
"/";
|
||||
return $api_url;
|
||||
}
|
||||
}
|
||||
10
heimdall/config/www/SupportedApps/PaperlessNgx/app.json
Executable file
10
heimdall/config/www/SupportedApps/PaperlessNgx/app.json
Executable file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"appid": "23e9c842d2423902706ae92996554f6fbd92c502",
|
||||
"name": "PaperlessNgx",
|
||||
"website": "https://github.com/paperless-ngx/paperless-ngx",
|
||||
"license": "GNU General Public License v3.0 only",
|
||||
"description": "Paperless-ngx is a document management system that transforms your physical documents into a searchable online archive so you can keep, well, less paper.",
|
||||
"enhanced": true,
|
||||
"tile_background": "dark",
|
||||
"icon": "paperlessngx.svg"
|
||||
}
|
||||
14
heimdall/config/www/SupportedApps/PaperlessNgx/config.blade.php
Executable file
14
heimdall/config/www/SupportedApps/PaperlessNgx/config.blade.php
Executable file
@@ -0,0 +1,14 @@
|
||||
<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.apikey') }}</label>
|
||||
{!! Form::text('config[apikey]', isset($item) ? $item->getconfig()->apikey : null, ['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>
|
||||
10
heimdall/config/www/SupportedApps/PaperlessNgx/livestats.blade.php
Executable file
10
heimdall/config/www/SupportedApps/PaperlessNgx/livestats.blade.php
Executable file
@@ -0,0 +1,10 @@
|
||||
<ul class="livestats">
|
||||
<li>
|
||||
<span class="title">Documents</span>
|
||||
<strong>{!! $documentCount !!}</strong>
|
||||
</li>
|
||||
<li>
|
||||
<span class="title">Inbox</span>
|
||||
<strong>{!! $documentsInbox !!}</strong>
|
||||
</li>
|
||||
</ul>
|
||||
Reference in New Issue
Block a user