Split up settings sections, use new datasource selector
This commit is contained in:
parent
2ce53eb499
commit
4057e18755
13 changed files with 869 additions and 720 deletions
142
src/lib/components/settings/DataSourceSettings.svelte
Normal file
142
src/lib/components/settings/DataSourceSettings.svelte
Normal file
|
@ -0,0 +1,142 @@
|
|||
<script lang="ts">
|
||||
import { SettingsInput, SettingsSwitch } from '$lib/components';
|
||||
import { _ } from 'svelte-i18n';
|
||||
import { Row, Col, FormGroup, Input, InputGroupText } from '@sveltestrap/sveltestrap';
|
||||
import ToggleHeader from '../ToggleHeader.svelte';
|
||||
import { uiSettings } from '$lib/uiSettings';
|
||||
import { isValidHexPubKey, getPubKey, isValidNpub } from '$lib';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { DataSourceType } from '$lib/types/dataSource';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
export let settings;
|
||||
export let isOpen = false;
|
||||
|
||||
const checkValidNostrPubkey = (key: string) => {
|
||||
$settings[key] = $settings[key].trim();
|
||||
if (isValidNpub($settings[key])) {
|
||||
dispatch('showToast', {
|
||||
color: 'info',
|
||||
text: $_('section.settings.convertingValidNpub')
|
||||
});
|
||||
}
|
||||
|
||||
let ret = getPubKey($settings[key]);
|
||||
if (ret) $settings[key] = ret;
|
||||
};
|
||||
</script>
|
||||
|
||||
<Row>
|
||||
<ToggleHeader header={$_('section.settings.section.dataSource')} bind:isOpen defaultOpen={false}>
|
||||
<Row>
|
||||
<Col>
|
||||
<h5>Data Source</h5>
|
||||
<FormGroup>
|
||||
<Row>
|
||||
<Col xs="12" xl="6" class="mb-2">
|
||||
<Input
|
||||
type="radio"
|
||||
id="btclock_source"
|
||||
name="dataSource"
|
||||
bind:group={$settings.dataSource}
|
||||
value={DataSourceType.BTCLOCK_SOURCE}
|
||||
label={$_('section.settings.dataSource.btclock')}
|
||||
/>
|
||||
</Col>
|
||||
<Col xs="12" xl="6" class="mb-2">
|
||||
<Input
|
||||
type="radio"
|
||||
id="third_party_source"
|
||||
name="dataSource"
|
||||
bind:group={$settings.dataSource}
|
||||
value={DataSourceType.THIRD_PARTY_SOURCE}
|
||||
label={$_('section.settings.dataSource.thirdParty')}
|
||||
/>
|
||||
</Col>
|
||||
{#if $settings.nostrRelay}
|
||||
<Col xs="12" xl="6" class="mb-2">
|
||||
<Input
|
||||
type="radio"
|
||||
id="nostr_source"
|
||||
name="dataSource"
|
||||
bind:group={$settings.dataSource}
|
||||
value={DataSourceType.NOSTR_SOURCE}
|
||||
label={$_('section.settings.dataSource.nostr')}
|
||||
/>
|
||||
</Col>
|
||||
{/if}
|
||||
<Col xs="12" xl="6" class="mb-2">
|
||||
<Input
|
||||
type="radio"
|
||||
id="custom_source"
|
||||
name="dataSource"
|
||||
bind:group={$settings.dataSource}
|
||||
value={DataSourceType.CUSTOM_SOURCE}
|
||||
label={$_('section.settings.dataSource.custom')}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
</FormGroup>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{#if $settings.dataSource === DataSourceType.THIRD_PARTY_SOURCE}
|
||||
<SettingsInput
|
||||
id="mempoolInstance"
|
||||
label={$_('section.settings.mempoolnstance')}
|
||||
bind:value={$settings.mempoolInstance}
|
||||
required={true}
|
||||
size={$uiSettings.inputSize}
|
||||
>
|
||||
<InputGroupText>
|
||||
<Input
|
||||
type="checkbox"
|
||||
bind:checked={$settings.mempoolSecure}
|
||||
bsSize={$uiSettings.inputSize}
|
||||
/>
|
||||
HTTPS
|
||||
</InputGroupText>
|
||||
</SettingsInput>
|
||||
{/if}
|
||||
|
||||
{#if $settings.dataSource === DataSourceType.NOSTR_SOURCE}
|
||||
<SettingsInput
|
||||
id="nostrRelay"
|
||||
label={$_('section.settings.nostrRelay')}
|
||||
bind:value={$settings.nostrRelay}
|
||||
required={true}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
<SettingsInput
|
||||
id="nostrPubKey"
|
||||
label={$_('section.settings.nostrPubKey')}
|
||||
bind:value={$settings.nostrPubKey}
|
||||
required={true}
|
||||
minlength="64"
|
||||
invalid={!isValidHexPubKey($settings.nostrPubKey)}
|
||||
helpText={!isValidHexPubKey($settings.nostrPubKey)
|
||||
? $_('section.settings.invalidNostrPubkey')
|
||||
: undefined}
|
||||
size={$uiSettings.inputSize}
|
||||
onChange={() => checkValidNostrPubkey('nostrPubKey')}
|
||||
onInput={() => checkValidNostrPubkey('nostrPubKey')}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if $settings.dataSource === DataSourceType.CUSTOM_SOURCE}
|
||||
<SettingsInput
|
||||
id="ceEndpoint"
|
||||
label={$_('section.settings.ceEndpoint')}
|
||||
bind:value={$settings.ceEndpoint}
|
||||
required={true}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
<SettingsSwitch
|
||||
id="ceDisableSSL"
|
||||
bind:checked={$settings.ceDisableSSL}
|
||||
label={$_('section.settings.ceDisableSSL')}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
{/if}
|
||||
</ToggleHeader>
|
||||
</Row>
|
189
src/lib/components/settings/DisplaySettings.svelte
Normal file
189
src/lib/components/settings/DisplaySettings.svelte
Normal file
|
@ -0,0 +1,189 @@
|
|||
<script lang="ts">
|
||||
import { SettingsInput, SettingsSwitch, SettingsSelect } from '$lib/components';
|
||||
import { _ } from 'svelte-i18n';
|
||||
import { Row } from '@sveltestrap/sveltestrap';
|
||||
import ToggleHeader from '../ToggleHeader.svelte';
|
||||
import { uiSettings } from '$lib/uiSettings';
|
||||
import { PUBLIC_BASE_URL } from '$lib/config';
|
||||
|
||||
export let settings;
|
||||
export let isOpen = false;
|
||||
|
||||
const onFlBrightnessChange = async () => {
|
||||
await fetch(`${PUBLIC_BASE_URL}/api/frontlight/brightness/${$settings.flMaxBrightness}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const setTextColor = () => {
|
||||
$settings.invertedColor = !$settings.invertedColor;
|
||||
$settings.fgColor = $settings.invertedColor ? 65535 : 0;
|
||||
$settings.bgColor = $settings.invertedColor ? 0 : 65535;
|
||||
};
|
||||
|
||||
const textColorOptions: [string, boolean][] = [
|
||||
[$_('colors.black') + ' on ' + $_('colors.white'), false],
|
||||
[$_('colors.white') + ' on ' + $_('colors.black'), true]
|
||||
];
|
||||
</script>
|
||||
|
||||
<Row>
|
||||
<ToggleHeader
|
||||
header={$_('section.settings.section.displaysAndLed')}
|
||||
bind:isOpen
|
||||
defaultOpen={false}
|
||||
>
|
||||
<SettingsSelect
|
||||
id="textColor"
|
||||
label={$_('section.settings.textColor')}
|
||||
bind:value={$settings.invertedColor}
|
||||
options={textColorOptions}
|
||||
size={$uiSettings.inputSize}
|
||||
on:change={setTextColor}
|
||||
/>
|
||||
|
||||
<SettingsInput
|
||||
id="timePerScreen"
|
||||
label={$_('section.settings.timePerScreen')}
|
||||
bind:value={$settings.timePerScreen}
|
||||
type="number"
|
||||
min={1}
|
||||
step={1}
|
||||
required={true}
|
||||
suffix={$_('time.minutes')}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
|
||||
<SettingsInput
|
||||
id="fullRefreshMin"
|
||||
label={$_('section.settings.fullRefreshEvery')}
|
||||
bind:value={$settings.fullRefreshMin}
|
||||
type="number"
|
||||
min={1}
|
||||
step={1}
|
||||
required={true}
|
||||
suffix={$_('time.minutes')}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
|
||||
<SettingsInput
|
||||
id="minSecPriceUpd"
|
||||
label={$_('section.settings.timeBetweenPriceUpdates')}
|
||||
bind:value={$settings.minSecPriceUpd}
|
||||
type="number"
|
||||
min={1}
|
||||
step={1}
|
||||
suffix={$_('time.seconds')}
|
||||
helpText={$_('section.settings.shortAmountsWarning')}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
|
||||
<SettingsInput
|
||||
id="ledBrightness"
|
||||
label={$_('section.settings.ledBrightness')}
|
||||
bind:value={$settings.ledBrightness}
|
||||
type="range"
|
||||
min={0}
|
||||
max={255}
|
||||
step={1}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
|
||||
{#if $settings.hasFrontlight && !$settings.flDisable}
|
||||
<SettingsInput
|
||||
id="flMaxBrightness"
|
||||
label={$_('section.settings.flMaxBrightness')}
|
||||
bind:value={$settings.flMaxBrightness}
|
||||
type="range"
|
||||
min={0}
|
||||
max={4095}
|
||||
step={1}
|
||||
size={$uiSettings.inputSize}
|
||||
on:change={onFlBrightnessChange}
|
||||
/>
|
||||
|
||||
<SettingsInput
|
||||
id="flEffectDelay"
|
||||
label={$_('section.settings.flEffectDelay')}
|
||||
bind:value={$settings.flEffectDelay}
|
||||
type="range"
|
||||
min={5}
|
||||
max={300}
|
||||
step={1}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if !$settings.flDisable && $settings.hasLightLevel}
|
||||
<SettingsInput
|
||||
id="luxLightToggle"
|
||||
label={`${$_('section.settings.luxLightToggle')} (${$settings.luxLightToggle})`}
|
||||
bind:value={$settings.luxLightToggle}
|
||||
type="range"
|
||||
min={0}
|
||||
max={1000}
|
||||
step={1}
|
||||
helpText={$_('section.settings.luxLightToggleText')}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<Row>
|
||||
<SettingsSwitch
|
||||
id="ledTestOnPower"
|
||||
bind:checked={$settings.ledTestOnPower}
|
||||
label={$_('section.settings.ledPowerOnTest')}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
|
||||
<SettingsSwitch
|
||||
id="ledFlashOnUpd"
|
||||
bind:checked={$settings.ledFlashOnUpd}
|
||||
label={$_('section.settings.ledFlashOnBlock')}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
|
||||
<SettingsSwitch
|
||||
id="disableLeds"
|
||||
bind:checked={$settings.disableLeds}
|
||||
label={$_('section.settings.disableLeds')}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
|
||||
{#if $settings.hasFrontlight}
|
||||
<SettingsSwitch
|
||||
id="flDisable"
|
||||
bind:checked={$settings.flDisable}
|
||||
label={$_('section.settings.flDisable')}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if $settings.hasFrontlight && !$settings.flDisable}
|
||||
<SettingsSwitch
|
||||
id="flAlwaysOn"
|
||||
bind:checked={$settings.flAlwaysOn}
|
||||
label={$_('section.settings.flAlwaysOn')}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
|
||||
<SettingsSwitch
|
||||
id="flFlashOnUpd"
|
||||
bind:checked={$settings.flFlashOnUpd}
|
||||
label={$_('section.settings.flFlashOnUpd')}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
|
||||
<SettingsSwitch
|
||||
id="flOffWhenDark"
|
||||
bind:checked={$settings.flOffWhenDark}
|
||||
label={$_('section.settings.flOffWhenDark')}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
{/if}
|
||||
</Row>
|
||||
</ToggleHeader>
|
||||
</Row>
|
190
src/lib/components/settings/ExtraFeaturesSettings.svelte
Normal file
190
src/lib/components/settings/ExtraFeaturesSettings.svelte
Normal file
|
@ -0,0 +1,190 @@
|
|||
<script lang="ts">
|
||||
import { SettingsInput, SettingsSwitch, SettingsSelect } from '$lib/components';
|
||||
import { _ } from 'svelte-i18n';
|
||||
import { Row, Button, Col } from '@sveltestrap/sveltestrap';
|
||||
import ToggleHeader from '../ToggleHeader.svelte';
|
||||
import { uiSettings } from '$lib/uiSettings';
|
||||
import { isValidHexPubKey, getPubKey, isValidNpub } from '$lib';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
export let settings;
|
||||
export let isOpen = false;
|
||||
export let miningPoolMap: Map<string, string>;
|
||||
|
||||
let validBitaxe = false;
|
||||
const testBitaxe = async () => {
|
||||
try {
|
||||
const response = await fetch(`http://${$settings.bitaxeHostname}/api/system/info`);
|
||||
|
||||
if (!response.ok) {
|
||||
dispatch('showToast', {
|
||||
color: 'danger',
|
||||
text: `Failed to connect to BitAxe HTTP error! status: ${response.status}`
|
||||
});
|
||||
validBitaxe = false;
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
const systemInfo = await response.json();
|
||||
dispatch('showToast', {
|
||||
color: 'success',
|
||||
text: `Connected to BitAxe ${systemInfo.ASICModel} (Board version ${systemInfo.boardVersion}) running firmware ${systemInfo.version}.\r\nCurrent hashrate ${Math.round(systemInfo.hashRate)} GH/s`
|
||||
});
|
||||
validBitaxe = true;
|
||||
} catch (error) {
|
||||
if (error instanceof TypeError && error.message.includes('Failed to fetch')) {
|
||||
dispatch('showToast', {
|
||||
color: 'danger',
|
||||
text: `Failed to connect to BitAxe, make sure you are connected to the same network.`
|
||||
});
|
||||
}
|
||||
console.error('Failed to fetch Bitaxe system info:', error);
|
||||
validBitaxe = false;
|
||||
}
|
||||
};
|
||||
|
||||
const checkValidNostrPubkey = (key: string) => {
|
||||
$settings[key] = $settings[key].trim();
|
||||
if (isValidNpub($settings[key])) {
|
||||
dispatch('showToast', {
|
||||
color: 'info',
|
||||
text: $_('section.settings.convertingValidNpub')
|
||||
});
|
||||
}
|
||||
|
||||
let ret = getPubKey($settings[key]);
|
||||
if (ret) $settings[key] = ret;
|
||||
};
|
||||
|
||||
$: poolOptions = ($settings.availablePools || []).map((pool: string): [string, string] => [
|
||||
miningPoolMap.get(pool) || pool,
|
||||
pool
|
||||
]);
|
||||
</script>
|
||||
|
||||
<Row>
|
||||
<ToggleHeader
|
||||
header={$_('section.settings.section.extraFeatures')}
|
||||
bind:isOpen
|
||||
defaultOpen={false}
|
||||
>
|
||||
<!-- BitAxe Settings -->
|
||||
{#if 'bitaxeEnabled' in $settings}
|
||||
<Row class="mb-3">
|
||||
<Col>
|
||||
<h5>BitAxe</h5>
|
||||
<SettingsSwitch
|
||||
id="bitaxeEnabled"
|
||||
bind:checked={$settings.bitaxeEnabled}
|
||||
label="{$_('section.settings.bitaxeEnabled')} ({$_('restartRequired')})"
|
||||
size={$uiSettings.inputSize}
|
||||
col={{ md: '12', xl: '12', xxl: '12' }}
|
||||
/>
|
||||
{#if $settings.bitaxeEnabled}
|
||||
<SettingsInput
|
||||
id="bitaxeHostname"
|
||||
label={$_('section.settings.bitaxeHostname')}
|
||||
bind:value={$settings.bitaxeHostname}
|
||||
required={true}
|
||||
valid={validBitaxe}
|
||||
size={$uiSettings.inputSize}
|
||||
>
|
||||
<Button type="button" color="success" on:click={testBitaxe}>
|
||||
{$_('test', { default: 'Test' })}
|
||||
</Button>
|
||||
</SettingsInput>
|
||||
{/if}
|
||||
</Col>
|
||||
</Row>
|
||||
{/if}
|
||||
|
||||
<!-- Mining Pool Settings -->
|
||||
{#if 'miningPoolStats' in $settings}
|
||||
<Row class="mb-3">
|
||||
<Col>
|
||||
<h5>Mining Pool stats</h5>
|
||||
<SettingsSwitch
|
||||
id="miningPoolStats"
|
||||
bind:checked={$settings.miningPoolStats}
|
||||
label="{$_('section.settings.miningPoolStats')} ({$_('restartRequired')})"
|
||||
size={$uiSettings.inputSize}
|
||||
col={{ md: '12', xl: '12', xxl: '12' }}
|
||||
/>
|
||||
{#if $settings.miningPoolStats}
|
||||
<SettingsSelect
|
||||
id="miningPoolName"
|
||||
label={$_('section.settings.miningPoolName')}
|
||||
bind:value={$settings.miningPoolName}
|
||||
options={poolOptions}
|
||||
size={$uiSettings.inputSize}
|
||||
selectClass={$uiSettings.selectClass}
|
||||
/>
|
||||
<SettingsInput
|
||||
id="miningPoolUser"
|
||||
label={$_('section.settings.miningPoolUser')}
|
||||
bind:value={$settings.miningPoolUser}
|
||||
required={true}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
{/if}
|
||||
</Col>
|
||||
</Row>
|
||||
{/if}
|
||||
|
||||
<!-- Nostr Settings -->
|
||||
{#if 'nostrZapNotify' in $settings}
|
||||
<Row class="mb-3">
|
||||
<Col>
|
||||
<h5>Nostr</h5>
|
||||
<SettingsInput
|
||||
id="nostrRelay"
|
||||
label={$_('section.settings.nostrRelay')}
|
||||
bind:value={$settings.nostrRelay}
|
||||
required={true}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
<SettingsSwitch
|
||||
id="nostrZapNotify"
|
||||
bind:checked={$settings.nostrZapNotify}
|
||||
label="{$_('section.settings.nostrZapNotify')} ({$_('restartRequired')})"
|
||||
size={$uiSettings.inputSize}
|
||||
col={{ md: '12', xl: '12', xxl: '12' }}
|
||||
/>
|
||||
{#if $settings.nostrZapNotify}
|
||||
<Row>
|
||||
<SettingsSwitch
|
||||
id="ledFlashOnZap"
|
||||
bind:checked={$settings.ledFlashOnZap}
|
||||
label={$_('section.settings.ledFlashOnZap')}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
{#if $settings.hasFrontlight && !$settings.flDisable}
|
||||
<SettingsSwitch
|
||||
id="flFlashOnZap"
|
||||
bind:checked={$settings.flFlashOnZap}
|
||||
label={$_('section.settings.flFlashOnZap')}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
{/if}
|
||||
</Row>
|
||||
<SettingsInput
|
||||
id="nostrZapPubkey"
|
||||
label={$_('section.settings.nostrZapPubkey')}
|
||||
bind:value={$settings.nostrZapPubkey}
|
||||
required={true}
|
||||
minlength="64"
|
||||
invalid={!isValidHexPubKey($settings.nostrZapPubkey)}
|
||||
helpText={!isValidHexPubKey($settings.nostrZapPubkey)
|
||||
? $_('section.settings.invalidNostrPubkey')
|
||||
: undefined}
|
||||
size={$uiSettings.inputSize}
|
||||
onChange={() => checkValidNostrPubkey('nostrZapPubkey')}
|
||||
onInput={() => checkValidNostrPubkey('nostrZapPubkey')}
|
||||
/>
|
||||
{/if}
|
||||
</Col>
|
||||
</Row>
|
||||
{/if}
|
||||
</ToggleHeader>
|
||||
</Row>
|
125
src/lib/components/settings/ScreenSpecificSettings.svelte
Normal file
125
src/lib/components/settings/ScreenSpecificSettings.svelte
Normal file
|
@ -0,0 +1,125 @@
|
|||
<script lang="ts">
|
||||
import { SettingsSwitch } from '$lib/components';
|
||||
import { _ } from 'svelte-i18n';
|
||||
import { Row, Col } from '@sveltestrap/sveltestrap';
|
||||
import ToggleHeader from '../ToggleHeader.svelte';
|
||||
import { uiSettings } from '$lib/uiSettings';
|
||||
|
||||
export let settings;
|
||||
export let isOpen = false;
|
||||
</script>
|
||||
|
||||
<Row>
|
||||
<ToggleHeader
|
||||
header={$_('section.settings.section.screenSettings')}
|
||||
bind:isOpen
|
||||
defaultOpen={true}
|
||||
>
|
||||
<Row>
|
||||
<SettingsSwitch
|
||||
id="stealFocus"
|
||||
bind:checked={$settings.stealFocus}
|
||||
label={$_('section.settings.StealFocusOnNewBlock')}
|
||||
size={$uiSettings.inputSize}
|
||||
col={{ md: '6', xl: '12', xxl: '6' }}
|
||||
/>
|
||||
<SettingsSwitch
|
||||
id="mcapBigChar"
|
||||
bind:checked={$settings.mcapBigChar}
|
||||
label={$_('section.settings.useBigCharsMcap')}
|
||||
size={$uiSettings.inputSize}
|
||||
col={{ md: '6', xl: '12', xxl: '6' }}
|
||||
/>
|
||||
<SettingsSwitch
|
||||
id="useBlkCountdown"
|
||||
bind:checked={$settings.useBlkCountdown}
|
||||
label={$_('section.settings.useBlkCountdown')}
|
||||
size={$uiSettings.inputSize}
|
||||
col={{ md: '6', xl: '12', xxl: '6' }}
|
||||
/>
|
||||
<SettingsSwitch
|
||||
id="useSatsSymbol"
|
||||
bind:checked={$settings.useSatsSymbol}
|
||||
label={$_('section.settings.useSatsSymbol')}
|
||||
size={$uiSettings.inputSize}
|
||||
col={{ md: '6', xl: '12', xxl: '6' }}
|
||||
/>
|
||||
<SettingsSwitch
|
||||
id="suffixPrice"
|
||||
bind:checked={$settings.suffixPrice}
|
||||
label={$_('section.settings.suffixPrice')}
|
||||
size={$uiSettings.inputSize}
|
||||
col={{ md: '6', xl: '12', xxl: '6' }}
|
||||
/>
|
||||
<SettingsSwitch
|
||||
id="mowMode"
|
||||
bind:checked={$settings.mowMode}
|
||||
label={$_('section.settings.mowMode')}
|
||||
size={$uiSettings.inputSize}
|
||||
col={{ md: '6', xl: '12', xxl: '6' }}
|
||||
disabled={!$settings.suffixPrice}
|
||||
/>
|
||||
<SettingsSwitch
|
||||
id="suffixShareDot"
|
||||
bind:checked={$settings.suffixShareDot}
|
||||
label={$_('section.settings.suffixShareDot')}
|
||||
size={$uiSettings.inputSize}
|
||||
col={{ md: '6', xl: '12', xxl: '6' }}
|
||||
disabled={!$settings.suffixPrice}
|
||||
/>
|
||||
<SettingsSwitch
|
||||
id="verticalDesc"
|
||||
bind:checked={$settings.verticalDesc}
|
||||
label={$_('section.settings.verticalDesc')}
|
||||
size={$uiSettings.inputSize}
|
||||
col={{ md: '6', xl: '12', xxl: '6' }}
|
||||
/>
|
||||
|
||||
{#if !$settings.actCurrencies}
|
||||
<SettingsSwitch
|
||||
id="fetchEurPrice"
|
||||
bind:checked={$settings.fetchEurPrice}
|
||||
label="{$_('section.settings.fetchEuroPrice')} ({$_('restartRequired')})"
|
||||
size={$uiSettings.inputSize}
|
||||
col={{ md: '6', xl: '12', xxl: '6' }}
|
||||
/>
|
||||
{/if}
|
||||
</Row>
|
||||
<Row>
|
||||
<h5>{$_('section.settings.screens')}</h5>
|
||||
{#if $settings.screens}
|
||||
{#each $settings.screens as s}
|
||||
<SettingsSwitch
|
||||
id="screens_{s.id}"
|
||||
bind:checked={s.enabled}
|
||||
label={s.name}
|
||||
size={$uiSettings.inputSize}
|
||||
col={{ md: '6', xl: '12', xxl: '6' }}
|
||||
/>
|
||||
{/each}
|
||||
{/if}
|
||||
</Row>
|
||||
{#if $settings.actCurrencies && $settings.useNostr !== true}
|
||||
<Row>
|
||||
<h5>{$_('section.settings.currencies')}</h5>
|
||||
<small>{$_('restartRequired')}</small>
|
||||
{#if $settings.availableCurrencies}
|
||||
{#each $settings.availableCurrencies as c}
|
||||
<Col md="6" xl="12" xxl="6">
|
||||
<div class="form-check form-control-{$uiSettings.inputSize}">
|
||||
<input
|
||||
id="currency_{c}"
|
||||
bind:group={$settings.actCurrencies}
|
||||
value={c}
|
||||
type="checkbox"
|
||||
class="form-check-input"
|
||||
/>
|
||||
<label class="form-check-label" for="currency_{c}">{c}</label>
|
||||
</div>
|
||||
</Col>
|
||||
{/each}
|
||||
{/if}
|
||||
</Row>
|
||||
{/if}
|
||||
</ToggleHeader>
|
||||
</Row>
|
113
src/lib/components/settings/SystemSettings.svelte
Normal file
113
src/lib/components/settings/SystemSettings.svelte
Normal file
|
@ -0,0 +1,113 @@
|
|||
<script lang="ts">
|
||||
import { SettingsInput, SettingsSwitch } from '$lib/components';
|
||||
import { _ } from 'svelte-i18n';
|
||||
import { Row, Button } from '@sveltestrap/sveltestrap';
|
||||
import ToggleHeader from '../ToggleHeader.svelte';
|
||||
import { uiSettings } from '$lib/uiSettings';
|
||||
import EyeIcon from 'svelte-bootstrap-icons/lib/Eye.svelte';
|
||||
import EyeSlashIcon from 'svelte-bootstrap-icons/lib/EyeSlash.svelte';
|
||||
|
||||
export let settings;
|
||||
export let isOpen = false;
|
||||
|
||||
let showPassword = false;
|
||||
|
||||
const getTzOffsetFromSystem = () => {
|
||||
const dt = new Date();
|
||||
let diffTZ = dt.getTimezoneOffset();
|
||||
$settings.tzOffset = diffTZ * -1;
|
||||
};
|
||||
</script>
|
||||
|
||||
<Row>
|
||||
<ToggleHeader header={$_('section.settings.section.system')} bind:isOpen defaultOpen={false}>
|
||||
<SettingsInput
|
||||
id="tzOffset"
|
||||
label={$_('section.settings.timezoneOffset')}
|
||||
bind:value={$settings.tzOffset}
|
||||
type="number"
|
||||
step={1}
|
||||
required={true}
|
||||
suffix={$_('time.minutes')}
|
||||
helpText={$_('section.settings.tzOffsetHelpText')}
|
||||
size={$uiSettings.inputSize}
|
||||
>
|
||||
<Button type="button" color="info" on:click={getTzOffsetFromSystem}>
|
||||
{$_('auto-detect')}
|
||||
</Button>
|
||||
</SettingsInput>
|
||||
|
||||
{#if $settings.httpAuthEnabled}
|
||||
<SettingsInput
|
||||
id="httpAuthUser"
|
||||
label={$_('section.settings.httpAuthUser')}
|
||||
bind:value={$settings.httpAuthUser}
|
||||
required={true}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
<SettingsInput
|
||||
id="httpAuthPass"
|
||||
label={$_('section.settings.httpAuthPass')}
|
||||
bind:value={$settings.httpAuthPass}
|
||||
type={showPassword ? 'text' : 'password'}
|
||||
required={true}
|
||||
size={$uiSettings.inputSize}
|
||||
>
|
||||
<Button
|
||||
type="button"
|
||||
on:click={() => (showPassword = !showPassword)}
|
||||
color={showPassword ? 'success' : 'danger'}
|
||||
>
|
||||
{#if !showPassword}<EyeIcon />{:else}<EyeSlashIcon />{/if}
|
||||
</Button>
|
||||
</SettingsInput>
|
||||
{/if}
|
||||
|
||||
<SettingsInput
|
||||
id="hostnamePrefix"
|
||||
label={$_('section.settings.hostnamePrefix')}
|
||||
bind:value={$settings.hostnamePrefix}
|
||||
required={true}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
|
||||
<SettingsInput
|
||||
id="wpTimeout"
|
||||
label={$_('section.settings.wpTimeout')}
|
||||
bind:value={$settings.wpTimeout}
|
||||
type="number"
|
||||
min={1}
|
||||
step={1}
|
||||
required={true}
|
||||
suffix={$_('time.seconds')}
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
|
||||
<Row>
|
||||
<SettingsSwitch
|
||||
id="otaEnabled"
|
||||
bind:checked={$settings.otaEnabled}
|
||||
label="{$_('section.settings.otaUpdates')} ({$_('restartRequired')})"
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
<SettingsSwitch
|
||||
id="mdnsEnabled"
|
||||
bind:checked={$settings.mdnsEnabled}
|
||||
label="{$_('section.settings.enableMdns')} ({$_('restartRequired')})"
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
<SettingsSwitch
|
||||
id="httpAuthEnabled"
|
||||
bind:checked={$settings.httpAuthEnabled}
|
||||
label="{$_('section.settings.httpAuthEnabled')} ({$_('restartRequired')})"
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
<SettingsSwitch
|
||||
id="enableDebugLog"
|
||||
bind:checked={$settings.enableDebugLog}
|
||||
label="{$_('section.settings.enableDebugLog')} ({$_('restartRequired')})"
|
||||
size={$uiSettings.inputSize}
|
||||
/>
|
||||
</Row>
|
||||
</ToggleHeader>
|
||||
</Row>
|
5
src/lib/components/settings/index.ts
Normal file
5
src/lib/components/settings/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
export { default as ScreenSpecificSettings } from './ScreenSpecificSettings.svelte';
|
||||
export { default as DisplaySettings } from './DisplaySettings.svelte';
|
||||
export { default as DataSourceSettings } from './DataSourceSettings.svelte';
|
||||
export { default as ExtraFeaturesSettings } from './ExtraFeaturesSettings.svelte';
|
||||
export { default as SystemSettings } from './SystemSettings.svelte';
|
Loading…
Add table
Add a link
Reference in a new issue