diff --git a/modules/fx-rates/assets/fx-rates.js b/modules/fx-rates/assets/fx-rates.js
index 2ed0def..6d478d7 100644
--- a/modules/fx-rates/assets/fx-rates.js
+++ b/modules/fx-rates/assets/fx-rates.js
@@ -115,19 +115,6 @@
}
});
- root.querySelector('[data-action="refresh-catalog"]')?.addEventListener('click', async () => {
- try {
- setLoading(true);
- setMessage('Ich synchronisiere jetzt den Waehrungskatalog.');
- const data = await request('/currencies-refresh', { method: 'POST', body: JSON.stringify({}) });
- setMessage(`Waehrungskatalog synchronisiert. ${data?.synced_count || 0} Waehrungen verarbeitet.`, 'success');
- } catch (error) {
- setMessage(error.message || 'Waehrungskatalog konnte nicht synchronisiert werden.', 'error');
- } finally {
- setLoading(false);
- }
- });
-
root.querySelector('[data-action="save-settings"]')?.addEventListener('click', async () => {
try {
setLoading(true);
diff --git a/modules/fx-rates/bootstrap.php b/modules/fx-rates/bootstrap.php
index 32ba41a..5ec077f 100644
--- a/modules/fx-rates/bootstrap.php
+++ b/modules/fx-rates/bootstrap.php
@@ -129,6 +129,23 @@ $mm->registerFunction($moduleName, 'service', static function (): FxRatesService
);
});
+$mm->registerFunction($moduleName, 'setup_actions', static function (): array {
+ return [
+ [
+ 'name' => 'sync_currency_catalog',
+ 'label' => 'Waehrungskatalog synchronisieren',
+ 'help' => 'Laedt die verfuegbaren Waehrungen einmalig aus dem konfigurierten FX-Provider.',
+ ],
+ ];
+});
+
+$mm->registerFunction($moduleName, 'run_setup_action', static function (string $action): array {
+ return match ($action) {
+ 'sync_currency_catalog' => module_fn('fx-rates', 'service')->refreshCurrencyCatalog(),
+ default => throw new \RuntimeException('Unbekannte Setup-Aktion.'),
+ };
+});
+
$mm->registerFunction($moduleName, 'refresh_latest', static function (?array $currencies = null, ?string $baseCurrency = null): array {
return module_fn('fx-rates', 'service')->refreshLatestRates($currencies, $baseCurrency);
});
diff --git a/modules/fx-rates/pages/index.php b/modules/fx-rates/pages/index.php
index 053b4c4..729fb1a 100644
--- a/modules/fx-rates/pages/index.php
+++ b/modules/fx-rates/pages/index.php
@@ -30,7 +30,6 @@ $pageData = json_encode([
-
@@ -79,7 +78,6 @@ $pageData = json_encode([
- API: /api/fx-rates/v1/latest, /api/fx-rates/v1/rate, /api/fx-rates/v1/history, /api/fx-rates/v1/refresh
diff --git a/modules/fx-rates/src/Api/Router.php b/modules/fx-rates/src/Api/Router.php
index d11e486..4bcf98f 100644
--- a/modules/fx-rates/src/Api/Router.php
+++ b/modules/fx-rates/src/Api/Router.php
@@ -88,14 +88,6 @@ final class Router
$this->respond(['data' => $this->service->probeLatestRates($base)]);
}
- if ($path === 'v1/currencies-probe' && $method === 'GET') {
- $this->respond(['data' => $this->service->probeCurrencyCatalog()]);
- }
-
- if ($path === 'v1/currencies-refresh' && $method === 'POST') {
- $this->respond(['data' => $this->service->refreshCurrencyCatalog()], 201);
- }
-
if ($path === 'v1/settings' && $method === 'GET') {
$this->respond(['data' => module_fn('fx-rates', 'settings')]);
}
diff --git a/partials/landingpages/modules/setup.php b/partials/landingpages/modules/setup.php
index 8937e8e..4988fae 100644
--- a/partials/landingpages/modules/setup.php
+++ b/partials/landingpages/modules/setup.php
@@ -42,6 +42,9 @@ foreach ($fields as $field) {
}
$current = modules()->settings($moduleName);
$intervalTaskStatuses = modules()->intervalTaskStatuses($moduleName);
+$setupActions = modules()->hasFunction($moduleName, 'setup_actions')
+ ? (array) module_fn($moduleName, 'setup_actions')
+ : [];
$defaults = $module['db_defaults'] ?? [];
if (empty($current['db']) && is_array($defaults)) {
$current['db'] = $defaults;
@@ -364,7 +367,26 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$postedTestGroup = (string)($_POST['test_db'] ?? '');
$postedResetGroup = (string)($_POST['reset_db'] ?? '');
- if ($postedResetGroup !== '') {
+ $postedSetupAction = trim((string)($_POST['module_setup_action'] ?? ''));
+ if ($postedSetupAction !== '') {
+ if (!modules()->hasFunction($moduleName, 'run_setup_action')) {
+ $error = 'Diese Setup-Aktion wird vom Modul nicht unterstuetzt.';
+ } else {
+ try {
+ $actionResult = module_fn($moduleName, 'run_setup_action', $postedSetupAction);
+ $notice = 'Setup-Aktion ausgefuehrt.';
+ if (is_array($actionResult)) {
+ if (isset($actionResult['message']) && is_string($actionResult['message']) && trim($actionResult['message']) !== '') {
+ $notice = trim((string) $actionResult['message']);
+ } elseif (isset($actionResult['synced_count'])) {
+ $notice = 'Waehrungskatalog synchronisiert. ' . (int) $actionResult['synced_count'] . ' Waehrungen verarbeitet.';
+ }
+ }
+ } catch (\Throwable $e) {
+ $error = $e->getMessage();
+ }
+ }
+ } elseif ($postedResetGroup !== '') {
$testGroup = $postedResetGroup;
if (!array_key_exists($postedResetGroup, $dbGroups)) {
$error = 'Unbekannte Datenbank-Konfiguration.';
@@ -497,6 +519,41 @@ $activeDbGroup = $testGroup !== null && array_key_exists($testGroup, $dbGroups)
+
+
+
+
+
Aktionen
+
Modulaktionen
+
Seltene Wartungsaktionen koennen direkt hier aus dem Setup ausgefuehrt werden.
+
+
+
+
+
+
+
= e($actionLabel) ?>
+
+
= e($actionHelp) ?>
+
+
+
+
+
+
+
+
+
+