ora/src/dashboard/views/Settings.svelte

48 lines
1.3 KiB
Svelte
Raw Normal View History

2021-11-22 20:07:06 +01:00
<script>
import { onMount } from 'svelte'
import { DB } from '../../shared/db'
2021-11-23 01:45:19 +01:00
import { getSettingsWithDefaults } from '../../shared/lib'
import { notify } from '../toasts'
2021-11-22 20:07:06 +01:00
let settings = null
async function load() {
2021-11-23 01:45:19 +01:00
settings = await getSettingsWithDefaults()
2021-11-22 20:07:06 +01:00
}
async function save() {
for (const [key, value] of Object.entries(settings)) {
await DB.settings.put({ key, value })
}
2021-11-23 01:45:19 +01:00
notify('Saved')
2021-11-22 20:07:06 +01:00
}
onMount(load)
</script>
<h2 class="mt-8 text-2xl">Settings</h2>
{#if settings}
<form class="mt-2" on:submit|preventDefault={save}>
<div class="form-group">
<label class="form-label">
Retention
<small>(Days)</small>
<input class="form-input" type="number" min="3" max="365" step="1" bind:value={settings.retention} />
</label>
<label class="form-label">
Idle Timeout
<small>(Minutes)</small>
<input class="form-input" type="number" min="0" step="1" bind:value={settings.idleTimeout} />
<p>Stop tracking after a certain period of idle behavior. <span class="font-mono">0</span> to disable.</p>
</label>
<div class="mt-2">
<button type="submit" class="btn btn-primary">Save</button>
</div>
</div>
</form>
{:else}
<div class="loading loading-lg" />
{/if}