adasd
This commit is contained in:
@@ -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 () => {
|
root.querySelector('[data-action="save-settings"]')?.addEventListener('click', async () => {
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|||||||
@@ -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 {
|
$mm->registerFunction($moduleName, 'refresh_latest', static function (?array $currencies = null, ?string $baseCurrency = null): array {
|
||||||
return module_fn('fx-rates', 'service')->refreshLatestRates($currencies, $baseCurrency);
|
return module_fn('fx-rates', 'service')->refreshLatestRates($currencies, $baseCurrency);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ $pageData = json_encode([
|
|||||||
</div>
|
</div>
|
||||||
<div class="fx-actions">
|
<div class="fx-actions">
|
||||||
<button type="button" class="fx-button fx-button--primary" data-action="refresh-rates">Aktuelle Kurse abrufen</button>
|
<button type="button" class="fx-button fx-button--primary" data-action="refresh-rates">Aktuelle Kurse abrufen</button>
|
||||||
<button type="button" class="fx-button" data-action="refresh-catalog">Waehrungskatalog sync</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fx-meta-grid">
|
<div class="fx-meta-grid">
|
||||||
@@ -79,7 +78,6 @@ $pageData = json_encode([
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<p class="fx-api-note">API: <code>/api/fx-rates/v1/latest</code>, <code>/api/fx-rates/v1/rate</code>, <code>/api/fx-rates/v1/history</code>, <code>/api/fx-rates/v1/refresh</code></p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -88,14 +88,6 @@ final class Router
|
|||||||
$this->respond(['data' => $this->service->probeLatestRates($base)]);
|
$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') {
|
if ($path === 'v1/settings' && $method === 'GET') {
|
||||||
$this->respond(['data' => module_fn('fx-rates', 'settings')]);
|
$this->respond(['data' => module_fn('fx-rates', 'settings')]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ foreach ($fields as $field) {
|
|||||||
}
|
}
|
||||||
$current = modules()->settings($moduleName);
|
$current = modules()->settings($moduleName);
|
||||||
$intervalTaskStatuses = modules()->intervalTaskStatuses($moduleName);
|
$intervalTaskStatuses = modules()->intervalTaskStatuses($moduleName);
|
||||||
|
$setupActions = modules()->hasFunction($moduleName, 'setup_actions')
|
||||||
|
? (array) module_fn($moduleName, 'setup_actions')
|
||||||
|
: [];
|
||||||
$defaults = $module['db_defaults'] ?? [];
|
$defaults = $module['db_defaults'] ?? [];
|
||||||
if (empty($current['db']) && is_array($defaults)) {
|
if (empty($current['db']) && is_array($defaults)) {
|
||||||
$current['db'] = $defaults;
|
$current['db'] = $defaults;
|
||||||
@@ -364,7 +367,26 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
|
|
||||||
$postedTestGroup = (string)($_POST['test_db'] ?? '');
|
$postedTestGroup = (string)($_POST['test_db'] ?? '');
|
||||||
$postedResetGroup = (string)($_POST['reset_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;
|
$testGroup = $postedResetGroup;
|
||||||
if (!array_key_exists($postedResetGroup, $dbGroups)) {
|
if (!array_key_exists($postedResetGroup, $dbGroups)) {
|
||||||
$error = 'Unbekannte Datenbank-Konfiguration.';
|
$error = 'Unbekannte Datenbank-Konfiguration.';
|
||||||
@@ -497,6 +519,41 @@ $activeDbGroup = $testGroup !== null && array_key_exists($testGroup, $dbGroups)
|
|||||||
</section>
|
</section>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($setupActions !== []): ?>
|
||||||
|
<section class="setup-panel">
|
||||||
|
<div class="setup-panel__head">
|
||||||
|
<div>
|
||||||
|
<span class="pill">Aktionen</span>
|
||||||
|
<h2>Modulaktionen</h2>
|
||||||
|
<p class="muted">Seltene Wartungsaktionen koennen direkt hier aus dem Setup ausgefuehrt werden.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="setup-grid">
|
||||||
|
<?php foreach ($setupActions as $action): ?>
|
||||||
|
<?php
|
||||||
|
$actionName = trim((string)($action['name'] ?? ''));
|
||||||
|
$actionLabel = trim((string)($action['label'] ?? $actionName));
|
||||||
|
$actionHelp = trim((string)($action['help'] ?? ''));
|
||||||
|
if ($actionName === '' || $actionLabel === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<div class="setup-field muted">
|
||||||
|
<span><?= e($actionLabel) ?></span>
|
||||||
|
<?php if ($actionHelp !== ''): ?>
|
||||||
|
<small class="muted"><?= e($actionHelp) ?></small>
|
||||||
|
<?php endif; ?>
|
||||||
|
<div class="setup-actions" style="justify-content:flex-start; margin-top:12px;">
|
||||||
|
<button class="nav-link" type="submit" name="module_setup_action" value="<?= e($actionName) ?>" formnovalidate>
|
||||||
|
<?= e($actionLabel) ?>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if (is_array($moduleStatusPanel)): ?>
|
<?php if (is_array($moduleStatusPanel)): ?>
|
||||||
<section class="setup-panel setup-panel--flat">
|
<section class="setup-panel setup-panel--flat">
|
||||||
<div class="setup-panel__head">
|
<div class="setup-panel__head">
|
||||||
|
|||||||
Reference in New Issue
Block a user