From 1f33bf7738718d36820026e0ee804c56b945b983 Mon Sep 17 00:00:00 2001 From: Karsten Lehmann Date: Tue, 1 Dec 2026 23:39:46 +0100 Subject: [PATCH] feat: Made wavelog an enhanced app --- Wavelog/Wavelog.php | 60 ++++++++++++++++++++++++++++++++++++- Wavelog/app.json | 2 +- Wavelog/config.blade.php | 18 +++++++++++ Wavelog/livestats.blade.php | 10 +++++++ 4 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 Wavelog/config.blade.php create mode 100644 Wavelog/livestats.blade.php diff --git a/Wavelog/Wavelog.php b/Wavelog/Wavelog.php index 84e961379a..439a9cf6c7 100644 --- a/Wavelog/Wavelog.php +++ b/Wavelog/Wavelog.php @@ -2,6 +2,64 @@ namespace App\SupportedApps\Wavelog; -class Wavelog extends \App\SupportedApps +class Wavelog extends \App\SupportedApps implements \App\EnhancedApps { + public $config; + + public function test(): void + { + $attrs = $this->getRequestAttrs(); + $test = parent::appTest($this->url("token"), $attrs); + echo $test->status; + } + + public function livestats() + { + $status = "inactive"; + $data = []; + $attrs = $this->getRequestAttrs(); + + $stats = json_decode( + parent::execute($this->url("statistic?profile=qso"), $attrs)->getBody() + ); + + $data = [ + "qsosToday" => $stats?->data?->qso?->activity?->today ?? 0, + "totalQSOs" => $stats?->data?->qso?->total ?? 0, + ]; + + return parent::getLiveStats($status, $data); + } + + public function url($endpoint): string + { + $api_url = parent::normaliseurl($this->config->url) . + 'index.php/api/v2/' . + $endpoint; + + return $api_url; + } + + private function getConfigValue(string $key, $default = null) + { + return isset($this->config) && isset($this->config->{$key}) + ? $this->config->{$key} + : $default; + } + + private function getRequestAttrs(): array + { + $attrs = [ + 'headers' => [ + 'Accept' => 'application/json', + ], + ]; + + $apikey = $this->getConfigValue('apikey'); + if ($apikey !== null) { + $attrs['headers']['Authorization'] = 'Bearer ' . $apikey; + } + + return $attrs; + } } diff --git a/Wavelog/app.json b/Wavelog/app.json index 626fdfa3b4..31d62afec7 100644 --- a/Wavelog/app.json +++ b/Wavelog/app.json @@ -4,7 +4,7 @@ "website": "https://www.wavelog.org/", "license": "MIT License", "description": "Wavelog is an open source and self-hosted logging software for amateur radio operators. It serves as a log book for QSOs (connections in the amateur radio world) and tracks their confirmation via external websites.", - "enhanced": false, + "enhanced": true, "tile_background": "dark", "icon": "wavelog.png" } diff --git a/Wavelog/config.blade.php b/Wavelog/config.blade.php new file mode 100644 index 0000000000..7c1d63ca52 --- /dev/null +++ b/Wavelog/config.blade.php @@ -0,0 +1,18 @@ +

{{ __('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::text('config[apikey]', isset($item) ? $item->getconfig()->apikey : null, ['placeholder' => __('app.apps.apikey'), 'data-config' => 'apikey', 'class' => 'form-control config-item']) !!} + + Requires a key for the Wavelog API v2 with scope statistic:read. + See the Wavelog docs. + +
+
+ +
+
diff --git a/Wavelog/livestats.blade.php b/Wavelog/livestats.blade.php new file mode 100644 index 0000000000..8aee8ad9d7 --- /dev/null +++ b/Wavelog/livestats.blade.php @@ -0,0 +1,10 @@ +