sdadas
This commit is contained in:
@@ -32,7 +32,6 @@ $mm->registerFunction($moduleName, 'settings', static function (): array {
|
|||||||
$apiUrl = rtrim((string) ($saved['api_url'] ?? (getenv('FX_RATES_API_URL') ?: getenv('MINING_CHECKER_FX_URL') ?: 'https://currencyapi.net')), '/');
|
$apiUrl = rtrim((string) ($saved['api_url'] ?? (getenv('FX_RATES_API_URL') ?: getenv('MINING_CHECKER_FX_URL') ?: 'https://currencyapi.net')), '/');
|
||||||
$apiKey = trim((string) ($saved['api_key'] ?? (getenv('FX_RATES_API_KEY') ?: getenv('MINING_CHECKER_FX_API_KEY') ?: '')));
|
$apiKey = trim((string) ($saved['api_key'] ?? (getenv('FX_RATES_API_KEY') ?: getenv('MINING_CHECKER_FX_API_KEY') ?: '')));
|
||||||
$timeout = max(2, (int) ($saved['timeout_sec'] ?? (getenv('FX_RATES_TIMEOUT') ?: getenv('MINING_CHECKER_FX_TIMEOUT') ?: 10)));
|
$timeout = max(2, (int) ($saved['timeout_sec'] ?? (getenv('FX_RATES_TIMEOUT') ?: getenv('MINING_CHECKER_FX_TIMEOUT') ?: 10)));
|
||||||
$cacheTtl = max(60, (int) ($saved['cache_ttl_sec'] ?? (getenv('FX_RATES_CACHE_TTL') ?: getenv('MINING_CHECKER_FX_CACHE_TTL') ?: 21600)));
|
|
||||||
|
|
||||||
$preferredCurrencies = $saved['preferred_currencies'] ?? ['EUR', 'USD', 'DOGE'];
|
$preferredCurrencies = $saved['preferred_currencies'] ?? ['EUR', 'USD', 'DOGE'];
|
||||||
if (is_string($preferredCurrencies)) {
|
if (is_string($preferredCurrencies)) {
|
||||||
@@ -61,7 +60,6 @@ $mm->registerFunction($moduleName, 'settings', static function (): array {
|
|||||||
'api_url' => $apiUrl,
|
'api_url' => $apiUrl,
|
||||||
'api_key' => $apiKey,
|
'api_key' => $apiKey,
|
||||||
'timeout_sec' => $timeout,
|
'timeout_sec' => $timeout,
|
||||||
'cache_ttl_sec' => $cacheTtl,
|
|
||||||
'default_base_currency' => strtoupper(trim((string) ($saved['default_base_currency'] ?? 'EUR'))) ?: 'EUR',
|
'default_base_currency' => strtoupper(trim((string) ($saved['default_base_currency'] ?? 'EUR'))) ?: 'EUR',
|
||||||
'display_base_currency' => strtoupper(trim((string) ($saved['display_base_currency'] ?? ($saved['default_base_currency'] ?? 'EUR')))) ?: 'EUR',
|
'display_base_currency' => strtoupper(trim((string) ($saved['display_base_currency'] ?? ($saved['default_base_currency'] ?? 'EUR')))) ?: 'EUR',
|
||||||
'preferred_currencies' => $preferredCurrencies,
|
'preferred_currencies' => $preferredCurrencies,
|
||||||
@@ -176,10 +174,56 @@ $mm->registerFunction($moduleName, 'run_setup_action', static function (string $
|
|||||||
'sync_currency_catalog' => (static function (): array {
|
'sync_currency_catalog' => (static function (): array {
|
||||||
$result = module_fn('fx-rates', 'service')->refreshCurrencyCatalog();
|
$result = module_fn('fx-rates', 'service')->refreshCurrencyCatalog();
|
||||||
$current = modules()->settings('fx-rates');
|
$current = modules()->settings('fx-rates');
|
||||||
$current['currency_catalog'] = array_values(is_array($result['currencies'] ?? null) ? $result['currencies'] : []);
|
|
||||||
|
$catalog = [];
|
||||||
|
foreach (is_array($result['currencies'] ?? null) ? $result['currencies'] : [] as $item) {
|
||||||
|
if (!is_array($item)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$code = strtoupper(trim((string) ($item['code'] ?? '')));
|
||||||
|
$name = trim((string) ($item['name'] ?? ''));
|
||||||
|
if ($code === '' || $name === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$catalog[$code] = ['code' => $code, 'name' => $name];
|
||||||
|
}
|
||||||
|
|
||||||
|
$latest = module_fn('fx-rates', 'service')->latestStatus();
|
||||||
|
if (is_array($latest) && !empty($latest['id'])) {
|
||||||
|
$snapshot = module_fn('fx-rates', 'snapshot', null, null, null, null);
|
||||||
|
$rates = is_array($snapshot['rates'] ?? null) ? $snapshot['rates'] : [];
|
||||||
|
foreach (array_keys($rates) as $code) {
|
||||||
|
$code = strtoupper(trim((string) $code));
|
||||||
|
if ($code !== '' && !isset($catalog[$code])) {
|
||||||
|
$catalog[$code] = ['code' => $code, 'name' => $code];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$baseCode = strtoupper(trim((string) ($snapshot['base_currency'] ?? '')));
|
||||||
|
if ($baseCode !== '' && !isset($catalog[$baseCode])) {
|
||||||
|
$catalog[$baseCode] = ['code' => $baseCode, 'name' => $baseCode];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ([
|
||||||
|
(string) ($current['default_base_currency'] ?? ''),
|
||||||
|
(string) ($current['display_base_currency'] ?? ''),
|
||||||
|
...((is_array($current['preferred_currencies'] ?? null) ? $current['preferred_currencies'] : [])),
|
||||||
|
] as $code) {
|
||||||
|
$code = strtoupper(trim((string) $code));
|
||||||
|
if ($code !== '' && !isset($catalog[$code])) {
|
||||||
|
$catalog[$code] = ['code' => $code, 'name' => $code];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ksort($catalog);
|
||||||
|
$current['currency_catalog'] = array_values($catalog);
|
||||||
$current['currency_catalog_synced_at'] = gmdate('Y-m-d H:i:s');
|
$current['currency_catalog_synced_at'] = gmdate('Y-m-d H:i:s');
|
||||||
modules()->saveSettings('fx-rates', $current);
|
modules()->saveSettings('fx-rates', $current);
|
||||||
return $result + ['message' => 'Waehrungskatalog synchronisiert. ' . (int) ($result['synced_count'] ?? 0) . ' Waehrungen verarbeitet.'];
|
return $result + [
|
||||||
|
'currencies' => array_values($catalog),
|
||||||
|
'synced_count' => count($catalog),
|
||||||
|
'message' => 'Waehrungskatalog synchronisiert. ' . count($catalog) . ' Waehrungen verarbeitet.',
|
||||||
|
];
|
||||||
})(),
|
})(),
|
||||||
default => throw new \RuntimeException('Unbekannte Setup-Aktion.'),
|
default => throw new \RuntimeException('Unbekannte Setup-Aktion.'),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"title": "Waehrungskurse",
|
"title": "Waehrungskurse",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"description": "Zentrales Modul fuer Waehrungskurse, Historie und API-Abrufe.",
|
"description": "Zentrales Modul fuer Waehrungskurse, Historie und API-Abrufe.",
|
||||||
"enabled_by_default": true,
|
"enabled_by_default": true,
|
||||||
"setup": {
|
"setup": {
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
{ "name": "api_url", "label": "FX API URL", "type": "text", "required": false, "help": "Nur die Basis-URL eintragen, z.B. https://api.currencyapi.com oder https://currencyapi.net." },
|
{ "name": "api_url", "label": "FX API URL", "type": "text", "required": false, "help": "Nur die Basis-URL eintragen, z.B. https://api.currencyapi.com oder https://currencyapi.net." },
|
||||||
{ "name": "api_key", "label": "FX API Key", "type": "password", "required": false },
|
{ "name": "api_key", "label": "FX API Key", "type": "password", "required": false },
|
||||||
{ "name": "timeout_sec", "label": "Timeout (Sek.)", "type": "number", "required": false },
|
{ "name": "timeout_sec", "label": "Timeout (Sek.)", "type": "number", "required": false },
|
||||||
{ "name": "cache_ttl_sec", "label": "Datei-Cache TTL (Sek.)", "type": "number", "required": false },
|
|
||||||
{ "name": "default_base_currency", "label": "Standard-Basiswaehrung", "type": "text", "required": false, "help": "Wird fuer taegliche Abrufe und Snapshot-Abfragen verwendet." },
|
{ "name": "default_base_currency", "label": "Standard-Basiswaehrung", "type": "text", "required": false, "help": "Wird fuer taegliche Abrufe und Snapshot-Abfragen verwendet." },
|
||||||
{ "name": "display_base_currency", "label": "Anzeige-Basiswaehrung", "type": "select", "required": false, "help": "Basis fuer die Anzeige der zuletzt gespeicherten Kurse im Modul." },
|
{ "name": "display_base_currency", "label": "Anzeige-Basiswaehrung", "type": "select", "required": false, "help": "Basis fuer die Anzeige der zuletzt gespeicherten Kurse im Modul." },
|
||||||
{ "name": "preferred_currencies", "label": "Bevorzugte Waehrungen", "type": "multiselect", "required": false, "help": "Auswahl aus dem synchronisierten Waehrungskatalog." },
|
{ "name": "preferred_currencies", "label": "Bevorzugte Waehrungen", "type": "multiselect", "required": false, "help": "Auswahl aus dem synchronisierten Waehrungskatalog." },
|
||||||
|
|||||||
@@ -579,7 +579,9 @@ $activeDbGroup = $testGroup !== null && array_key_exists($testGroup, $dbGroups)
|
|||||||
<label class="setup-field muted">
|
<label class="setup-field muted">
|
||||||
<span>Bevorzugte Waehrungen</span>
|
<span>Bevorzugte Waehrungen</span>
|
||||||
<div class="fx-setup-picker" data-fx-multi-picker data-currencies='<?= e(is_string($fxCatalogJson) ? $fxCatalogJson : '[]') ?>'>
|
<div class="fx-setup-picker" data-fx-multi-picker data-currencies='<?= e(is_string($fxCatalogJson) ? $fxCatalogJson : '[]') ?>'>
|
||||||
<div class="fx-setup-tags" data-fx-tags>
|
<input type="text" value="" placeholder="Waehrung suchen und hinzufuegen" autocomplete="off" data-fx-multi-input>
|
||||||
|
<div class="fx-setup-suggestions" data-fx-multi-suggestions hidden></div>
|
||||||
|
<div class="fx-setup-tags fx-setup-tags--stacked" data-fx-tags>
|
||||||
<?php foreach ($fxPreferred as $code): ?>
|
<?php foreach ($fxPreferred as $code): ?>
|
||||||
<?php if (!isset($fxCatalogOptions[$code])) { continue; } ?>
|
<?php if (!isset($fxCatalogOptions[$code])) { continue; } ?>
|
||||||
<span class="fx-setup-tag" data-code="<?= e($code) ?>">
|
<span class="fx-setup-tag" data-code="<?= e($code) ?>">
|
||||||
@@ -589,8 +591,6 @@ $activeDbGroup = $testGroup !== null && array_key_exists($testGroup, $dbGroups)
|
|||||||
<input type="hidden" name="preferred_currencies[]" value="<?= e($code) ?>" data-code-hidden="<?= e($code) ?>">
|
<input type="hidden" name="preferred_currencies[]" value="<?= e($code) ?>" data-code-hidden="<?= e($code) ?>">
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" value="" placeholder="Waehrung suchen und hinzufuegen" autocomplete="off" data-fx-multi-input>
|
|
||||||
<div class="fx-setup-suggestions" data-fx-multi-suggestions hidden></div>
|
|
||||||
</div>
|
</div>
|
||||||
<small class="muted">Tippen, Treffer anklicken und zur Liste hinzufuegen.</small>
|
<small class="muted">Tippen, Treffer anklicken und zur Liste hinzufuegen.</small>
|
||||||
</label>
|
</label>
|
||||||
@@ -911,15 +911,24 @@ $activeDbGroup = $testGroup !== null && array_key_exists($testGroup, $dbGroups)
|
|||||||
gap: 8px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fx-setup-tags--stacked {
|
||||||
|
min-height: 44px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 12px;
|
||||||
|
background: var(--surface-strong);
|
||||||
|
}
|
||||||
|
|
||||||
.fx-setup-tag {
|
.fx-setup-tag {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
min-height: 30px;
|
||||||
padding: 6px 10px;
|
padding: 6px 10px;
|
||||||
border: 1px solid var(--line);
|
border: 1px solid var(--line);
|
||||||
border-radius: 999px;
|
border-radius: 10px;
|
||||||
background: color-mix(in srgb, var(--brand-accent) 10%, var(--surface-strong));
|
background: #fff;
|
||||||
font-size: 0.88rem;
|
font-size: 0.86rem;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -944,7 +953,7 @@ $activeDbGroup = $testGroup !== null && array_key_exists($testGroup, $dbGroups)
|
|||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
border: 1px solid var(--line);
|
border: 1px solid var(--line);
|
||||||
border-radius: 14px;
|
border-radius: 12px;
|
||||||
background: var(--surface-strong);
|
background: var(--surface-strong);
|
||||||
box-shadow: 0 16px 35px rgba(1, 22, 32, 0.14);
|
box-shadow: 0 16px 35px rgba(1, 22, 32, 0.14);
|
||||||
max-height: 280px;
|
max-height: 280px;
|
||||||
|
|||||||
Reference in New Issue
Block a user