creddy/src/views/Home.svelte

67 lines
2.4 KiB
Svelte
Raw Normal View History

2022-11-23 17:11:44 -08:00
<script>
2023-04-25 08:49:00 -07:00
import { onMount } from 'svelte';
2022-12-22 21:50:09 -08:00
import { invoke } from '@tauri-apps/api/tauri';
2023-04-23 22:29:12 -07:00
2023-04-25 08:49:00 -07:00
import { appState } from '../lib/state.js';
2023-04-24 12:05:11 -07:00
import { navigate } from '../lib/routing.js';
2023-04-24 22:16:25 -07:00
import Nav from '../ui/Nav.svelte';
2023-04-23 22:29:12 -07:00
import Icon from '../ui/Icon.svelte';
2023-04-25 08:49:00 -07:00
import Link from '../ui/Link.svelte';
2022-11-23 17:11:44 -08:00
import vaultDoorSvg from '../assets/vault_door.svg?raw';
2023-08-03 22:08:24 -07:00
let launchBase = false;
function launchTerminal() {
invoke('launch_terminal', {base: launchBase});
launchBase = false;
}
2022-11-23 17:11:44 -08:00
</script>
2022-12-22 21:50:09 -08:00
<Nav position="fixed">
<h2 slot="title" class="text-3xl font-bold">Creddy</h2>
</Nav>
2022-12-22 21:50:09 -08:00
<div class="flex flex-col h-screen items-center justify-center p-4 space-y-4">
2023-08-03 22:08:24 -07:00
<div class="flex flex-col items-center space-y-4">
2023-09-05 06:12:26 -07:00
{@html vaultDoorSvg}
{#await invoke('get_session_status') then status}
{#if status === 'locked'}
<h2 class="text-2xl font-bold">Creddy is locked</h2>
<Link target="Unlock" hotkey="Enter" class="w-64">
<button class="btn btn-primary w-full">Unlock</button>
</Link>
{:else if status === 'unlocked'}
<h2 class="text-2xl font-bold">Waiting for requests</h2>
<button class="btn btn-primary w-full" on:click={launchTerminal}>
Launch Terminal
</button>
<label class="label cursor-pointer flex items-center space-x-2">
<span class="label-text">Launch with long-lived credentials</span>
2023-09-05 06:12:26 -07:00
<input type="checkbox" class="checkbox checkbox-sm" bind:checked={launchBase}>
</label>
{:else if status === 'empty'}
<h2 class="text-2xl font-bold">No credentials found</h2>
<Link target="EnterCredentials" hotkey="Enter" class="w-64">
<button class="btn btn-primary w-full">Enter Credentials</button>
</Link>
{/if}
{/await}
2023-08-03 22:08:24 -07:00
</div>
</div>
{#if $appState.setupErrors.some(e => e.show)}
<div class="toast">
{#each $appState.setupErrors as error}
{#if error.show}
<div class="alert alert-error shadow-lg">
{error.msg}
<button class="btn btn-sm btn-alert-error" on:click={() => error.show = false}>Ok</button>
</div>
{/if}
{/each}
</div>
{/if}