Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions Budibase/Budibase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace App\SupportedApps\Budibase;

class Budibase 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

public function __construct()
{
//$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set
}

public function test()
{
$attrs = [
"headers" => [
"x-budibase-api-key" => $this->config->apikey
],
];
$test = parent::appTest($this->url('metrics'), $attrs);
echo $test->status;
}

public function decodeResponse($response)
{
$response = explode(PHP_EOL, $response);
$data = [];
foreach ($response as $x) {
$y = explode(' ', $x);
if (is_array($y) && count($y) == 2) {
$data[$y[0]] = $y[1];
}
}
return $data;
}

public function livestats()
{
$attrs = [
"headers" => [
"x-budibase-api-key" => $this->config->apikey
],
];
$status = 'inactive';
$res = parent::execute($this->url('metrics'), $attrs);
$info = $this->decodeResponse($res->getBody());

$data = [
"total" => $info['budibase_tenant_app_count'],
"active" => $info['budibase_tenant_production_app_count']
];
if ($info['budibase_quota_limit_automations'] > 0) {
$status = "active";
}

return parent::getLiveStats($status, $data);
}

public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url, true) . "api/public/v1/" . $endpoint;
return $api_url;
}
}
29 changes: 29 additions & 0 deletions Budibase/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"appid": "6c51d4f37f544b0327d327d1bade045a7809a4d9",
"name": "Budibase",
"website": "https://budibase.com/",
"license": "GNU General Public License v3.0 or later",
"description": "Budibase is an open-source low-code platform that saves engineers 100s of hours building forms, portals, and approval apps, securely.",
"enhanced": true,
"tile_background": "dark",
"icon": "budibase.png",
"config": {
"type": "apikey",
"stat1": {
"name": "Total Apps",
"url": ":url:api/public/v1/metrics",
"key": "budibase_tenant_app_count",
"filter": "none",
"updateOnChange": "no",
"suffix": ""
},
"stat2": {
"name": "Active Apps",
"url": ":url:api/public/v1/metrics",
"key": "budibase_tenant_production_app_count",
"filter": "none",
"updateOnChange": "no",
"suffix": ""
}
}
}
Binary file added Budibase/budibase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions Budibase/config.blade.php
Original file line number Diff line number Diff line change
@@ -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 changes: 10 additions & 0 deletions Budibase/livestats.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<ul class="livestats">
<li>
<span class="title">Total Apps</span>
<strong>{!! $total !!}</strong>
</li>
<li>
<span class="title">Active Apps</span>
<strong>{!! $active !!}</strong>
</li>
</ul>