settings page

This commit is contained in:
2023-04-25 22:10:14 -07:00
parent 6f9cd6b471
commit 35271049dd
16 changed files with 210 additions and 90 deletions

View File

@ -1,44 +1,46 @@
<script>
import { invoke } from '@tauri-apps/api/tauri';
import { appState } from '../lib/state.js';
import Nav from '../ui/Nav.svelte';
import Link from '../ui/Link.svelte';
import ErrorAlert from '../ui/ErrorAlert.svelte';
// import Setting from '../ui/settings/Setting.svelte';
import { Setting, ToggleSetting, NumericSetting } from '../ui/settings';
async function save() {
await invoke('save_config', {config: $appState.config});
}
</script>
<Nav />
<div class="mx-auto mt-3 max-w-md">
<h2 class="text-2xl font-bold text-center">Settings</h2>
{#await invoke('get_config') then config}
<div class="mx-auto mt-3 max-w-md">
<h2 class="text-2xl font-bold text-center">Settings</h2>
<div class="divider"></div>
<div class="grid grid-cols-2 items-center">
<h3 class="text-lg font-bold">Start minimized</h3>
<input type="checkbox" class="justify-self-end toggle toggle-success" />
</div>
<p class="mt-3">Minimize to the system tray at startup.</p>
<ToggleSetting title="Start minimized" bind:value={$appState.config.start_minimized} on:update={save}>
<svelte:fragment slot="description">
Minimize to the system tray at startup.
</svelte:fragment>
</ToggleSetting>
<div class="divider"></div>
<div class="grid grid-cols-2 items-center">
<h3 class="text-lg font-bold">Re-hide delay</h3>
<div class="justify-self-end">
<span class="mr-2">(Seconds)</span>
<input type="text" class="input input-sm input-bordered text-right max-w-[4rem]" />
</div>
</div>
<p class="mt-3">
How long to wait after a request is approved/denied before minimizing
the window to tray. Only applicable if the window was minimized
to tray before the request was received.
</p>
<NumericSetting title="Re-hide delay" bind:value={$appState.config.rehide_ms} min={0} unit="Milliseconds" on:update={save}>
<svelte:fragment slot="description">
How long to wait after a request is approved/denied before minimizing
the window to tray. Only applicable if the window was minimized
to tray before the request was received.
</svelte:fragment>
</NumericSetting>
<div class="divider"></div>
<div class="grid grid-cols-2 items-center">
<h3 class="text-lg font-bold">Update credentials</h3>
<div class="justify-self-end">
<Link target="EnterCredentials">
<Setting title="Update credentials">
<Link slot="input" target="EnterCredentials">
<button class="btn btn-sm btn-primary">Update</button>
</Link>
</div>
<svelte:fragment slot="description">
Update or re-enter your encrypted credentials.
</svelte:fragment>
</Setting>
</div>
<p class="mt-3">Update or re-enter your encrypted credentials.</p>
</div>
{/await}