mirror of
https://github.com/linuxserver/Heimdall-Apps.git
synced 2026-02-20 04:16:08 +08:00
N8n enhanced version
This commit is contained in:
parent
24bd2b1f88
commit
de2eb07f64
53
N8n/N8n.php
53
N8n/N8n.php
@ -2,6 +2,57 @@
|
||||
|
||||
namespace App\SupportedApps\N8n;
|
||||
|
||||
class N8n extends \App\SupportedApps
|
||||
// use Barryvdh\Debugbar\Facades\Debugbar;
|
||||
// Debugbar::info($data);
|
||||
|
||||
class N8n extends \App\SupportedApps implements \App\EnhancedApps
|
||||
{
|
||||
public $config;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
$attrs = $this->getAttrs();
|
||||
$test = parent::appTest($this->url("workflows"), $attrs);
|
||||
echo $test->status;
|
||||
}
|
||||
|
||||
public function livestats()
|
||||
{
|
||||
$status = "active";
|
||||
$data = [];
|
||||
$attrs = $this->getAttrs();
|
||||
|
||||
// Fetch workflows
|
||||
$workflowsResponse = parent::execute($this->url("workflows"), $attrs);
|
||||
$workflows = json_decode($workflowsResponse->getBody());
|
||||
|
||||
$data["workflows"] = count($workflows->data);
|
||||
|
||||
// Fetch active workflows
|
||||
$activeResponse = parent::execute($this->url("workflows?active=true"), $attrs);
|
||||
$active = json_decode($activeResponse->getBody());
|
||||
|
||||
$data["active"] = count($active->data);
|
||||
|
||||
return parent::getLiveStats($status, $data);
|
||||
}
|
||||
|
||||
public function url($endpoint)
|
||||
{
|
||||
$api_url = parent::normaliseurl($this->config->url) . "api/v1/" . $endpoint;
|
||||
return $api_url;
|
||||
}
|
||||
private function getAttrs()
|
||||
{
|
||||
return [
|
||||
"headers" => [
|
||||
"Accept" => "application/json",
|
||||
"X-N8N-API-KEY" => $this->config->password
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
"website": "https://n8n.io",
|
||||
"license": "Apache License 2.0",
|
||||
"description": "n8n is an extendable workflow automation tool. With a fair-code distribution model, n8n will always have visible source code, be available to self-host, and allow you to add your own custom functions, logic and apps. n8n's node-based approach makes it highly versatile, enabling you to connect anything to everything.",
|
||||
"enhanced": false,
|
||||
"enhanced": true,
|
||||
"tile_background": "light",
|
||||
"icon": "n8n.svg"
|
||||
}
|
||||
|
||||
25
N8n/config.blade.php
Normal file
25
N8n/config.blade.php
Normal file
@ -0,0 +1,25 @@
|
||||
<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') }}(<a href="https://docs.n8n.io/api/authentication/#create-an-api-key" target="_blank">help?</a>)</label>
|
||||
{!! Form::input('password', 'config[password]', '',
|
||||
['placeholder' => __('app.apps.apikey'),
|
||||
'data-config' => 'password',
|
||||
'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
N8n/livestats.blade.php
Normal file
10
N8n/livestats.blade.php
Normal file
@ -0,0 +1,10 @@
|
||||
<ul class="livestats">
|
||||
<li>
|
||||
<span class="title">Workflows</span>
|
||||
<strong>{!! $workflows !!}</strong>
|
||||
</li>
|
||||
<li>
|
||||
<span class="title">Active</span>
|
||||
<strong>{!! $active !!}</strong>
|
||||
</li>
|
||||
</ul>
|
||||
Loading…
x
Reference in New Issue
Block a user