feat: Add LNBits multi-currency support
This commit is contained in:
parent
a413c2d8e7
commit
e16062569d
3 changed files with 62 additions and 4 deletions
|
@ -138,5 +138,31 @@
|
|||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
{/if}
|
||||
<Row>
|
||||
<SettingsSwitch
|
||||
id="lnbitsEnabled"
|
||||
bind:checked={$settings.lnbitsEnabled}
|
||||
label="{$_('section.settings.lnbitsEnabled')} ({$_('restartRequired')})"
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
</Row>
|
||||
{#if $settings.lnbitsEnabled}
|
||||
<SettingsInput
|
||||
id="lnbitsInstance"
|
||||
label={$_('section.settings.lnbitsInstance')}
|
||||
bind:value={$settings.lnbitsInstance}
|
||||
required={true}
|
||||
size={$uiSettings.inputSize}
|
||||
>
|
||||
<InputGroupText>
|
||||
<Input
|
||||
type="checkbox"
|
||||
bind:checked={$settings.lnbitsHttps}
|
||||
bsSize={$uiSettings.inputSize}
|
||||
/>
|
||||
HTTPS
|
||||
</InputGroupText>
|
||||
</SettingsInput>
|
||||
{/if}
|
||||
</ToggleHeader>
|
||||
</Row>
|
||||
|
|
|
@ -5,9 +5,39 @@
|
|||
import ToggleHeader from '../ToggleHeader.svelte';
|
||||
import { uiSettings } from '$lib/uiSettings';
|
||||
import { DataSourceType } from '$lib/types/dataSource';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
export let settings;
|
||||
export let isOpen = false;
|
||||
|
||||
let availableCurrencies: string[] = [];
|
||||
let prevLnbitsEnabled: boolean;
|
||||
|
||||
function updateCurrencies(enabled: boolean) {
|
||||
if (enabled) {
|
||||
fetch(`https://${$settings.lnbitsInstance}/api/v1/currencies`)
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
availableCurrencies = data;
|
||||
});
|
||||
} else {
|
||||
// Remove any currencies from actCurrencies that aren't in availableCurrencies
|
||||
$settings.actCurrencies = $settings.actCurrencies.filter((curr: string) =>
|
||||
$settings.availableCurrencies.includes(curr)
|
||||
);
|
||||
availableCurrencies = $settings.availableCurrencies;
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
prevLnbitsEnabled = $settings.lnbitsEnabled;
|
||||
updateCurrencies($settings.lnbitsEnabled);
|
||||
});
|
||||
|
||||
$: if (prevLnbitsEnabled !== $settings.lnbitsEnabled) {
|
||||
prevLnbitsEnabled = $settings.lnbitsEnabled;
|
||||
updateCurrencies($settings.lnbitsEnabled);
|
||||
}
|
||||
</script>
|
||||
|
||||
<Row>
|
||||
|
@ -104,9 +134,9 @@
|
|||
<Row>
|
||||
<h5>{$_('section.settings.currencies')}</h5>
|
||||
<small>{$_('restartRequired')}</small>
|
||||
{#if $settings.availableCurrencies}
|
||||
{#each $settings.availableCurrencies as c}
|
||||
<Col md="6" xl="12" xxl="6">
|
||||
{#if availableCurrencies}
|
||||
{#each availableCurrencies as c}
|
||||
<Col md="6" xl="3" xxl="3">
|
||||
<div class="form-check form-control-{$uiSettings.inputSize}">
|
||||
<input
|
||||
id="currency_{c}"
|
||||
|
|
|
@ -90,7 +90,9 @@
|
|||
"dndStartHour": "Start hour",
|
||||
"dndStartMinute": "Start minute",
|
||||
"dndEndHour": "End hour",
|
||||
"dndEndMinute": "End minute"
|
||||
"dndEndMinute": "End minute",
|
||||
"lnbitsEnabled": "LNBits multi-currency integration",
|
||||
"lnbitsInstance": "LNbits instance hostname"
|
||||
},
|
||||
"control": {
|
||||
"systemInfo": "System info",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue