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 @@ +