From de2eb07f64c90703b78daffe501daa1908207bc9 Mon Sep 17 00:00:00 2001 From: Pedro Buffon Date: Tue, 11 Nov 2025 13:41:37 +0000 Subject: [PATCH] N8n enhanced version --- N8n/N8n.php | 53 ++++++++++++++++++++++++++++++++++++++++- N8n/app.json | 2 +- N8n/config.blade.php | 25 +++++++++++++++++++ N8n/livestats.blade.php | 10 ++++++++ 4 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 N8n/config.blade.php create mode 100644 N8n/livestats.blade.php diff --git a/N8n/N8n.php b/N8n/N8n.php index 545d4555e..4bcbd081c 100644 --- a/N8n/N8n.php +++ b/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 + ], + ]; + } } diff --git a/N8n/app.json b/N8n/app.json index 12b4a0558..076126c91 100644 --- a/N8n/app.json +++ b/N8n/app.json @@ -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" } diff --git a/N8n/config.blade.php b/N8n/config.blade.php new file mode 100644 index 000000000..ee12aab95 --- /dev/null +++ b/N8n/config.blade.php @@ -0,0 +1,25 @@ +

{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')

+
+
+ + {!! Form::text('config[override_url]', + isset($item) ? $item->getconfig()->override_url : null, + ['placeholder' => __('app.apps.override'), + 'id' => 'override_url', + 'class' => 'form-control' + ]) !!} +
+ +
+ + {!! Form::input('password', 'config[password]', '', + ['placeholder' => __('app.apps.apikey'), + 'data-config' => 'password', + 'class' => 'form-control config-item' + ]) !!} +
+ +
+ +
+
diff --git a/N8n/livestats.blade.php b/N8n/livestats.blade.php new file mode 100644 index 000000000..33cda621b --- /dev/null +++ b/N8n/livestats.blade.php @@ -0,0 +1,10 @@ +