1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-19 13:27:58 +00:00
rolens/frontend/src/app.svelte

101 lines
2.6 KiB
Svelte
Raw Normal View History

2023-01-10 16:28:27 +00:00
<script>
import BlankState from '$components/blankstate.svelte';
2023-02-15 18:27:51 +00:00
import ContextMenu from '$components/contextmenu.svelte';
import { connections } from '$lib/stores/connections';
import contextMenu from '$lib/stores/contextmenu';
import environment from '$lib/stores/environment';
import applicationInited from '$lib/stores/inited';
2023-05-29 20:09:09 +00:00
import About from '$organisms/about.svelte';
2023-02-15 18:27:51 +00:00
import Connection from '$organisms/connection/index.svelte';
import Settings from '$organisms/settings/index.svelte';
import { EventsEmit, EventsOn } from '$wails/runtime';
import { tick } from 'svelte';
2023-01-10 16:28:27 +00:00
2023-01-22 20:12:56 +00:00
const hosts = {};
const activeHostKey = '';
2023-01-10 16:28:27 +00:00
let activeDbKey = '';
let activeCollKey = '';
2023-01-20 14:35:16 +00:00
let settingsModalOpen = false;
2023-01-20 15:27:51 +00:00
let aboutModalOpen = false;
let connectionManager;
let showWelcomeScreen = false;
2023-01-10 16:28:27 +00:00
$: host = hosts[activeHostKey];
2023-01-16 19:03:56 +00:00
$: connection = $connections[activeHostKey];
$: showWelcomeScreen = !Object.keys(hosts).length;
async function createFirstHost() {
showWelcomeScreen = false;
await tick();
connectionManager.createHost();
}
2023-01-10 16:28:27 +00:00
EventsOn('OpenPreferences', () => settingsModalOpen = true);
2023-01-20 15:27:51 +00:00
EventsOn('OpenAboutModal', () => aboutModalOpen = true);
2023-01-10 16:28:27 +00:00
</script>
2023-01-20 15:27:51 +00:00
<svelte:window on:contextmenu|preventDefault />
2023-01-18 10:22:02 +00:00
2023-01-20 14:35:16 +00:00
<div id="root" class="platform-{$environment?.platform}">
2023-01-17 08:07:53 +00:00
<div class="titlebar"></div>
2023-01-16 15:56:16 +00:00
2023-02-14 15:18:35 +00:00
{#if $applicationInited}
<main class:empty={showWelcomeScreen}>
{#if showWelcomeScreen}
<BlankState label="Welcome to Rolens!" image="/logo.png" pale={false} big={true}>
<button class="btn" on:click={createFirstHost}>Add your first host</button>
</BlankState>
{:else}
<Connection {hosts} {activeHostKey} bind:activeCollKey bind:activeDbKey bind:this={connectionManager} />
{/if}
2023-01-16 15:56:16 +00:00
</main>
{#key $contextMenu}
<ContextMenu {...$contextMenu} on:close={contextMenu.hide} />
{/key}
2023-05-29 20:09:09 +00:00
2023-01-20 14:35:16 +00:00
<Settings bind:show={settingsModalOpen} />
2023-01-20 15:27:51 +00:00
<About bind:show={aboutModalOpen} />
2023-01-11 19:41:15 +00:00
{/if}
2023-01-16 15:56:16 +00:00
</div>
2023-01-14 19:38:39 +00:00
2023-01-10 16:28:27 +00:00
<style>
2023-01-16 19:03:56 +00:00
.titlebar {
height: 0;
background-color: #00002a;
2023-01-16 15:56:16 +00:00
--wails-draggable: drag;
2023-01-16 19:03:56 +00:00
}
2023-01-18 10:26:28 +00:00
#root.platform-darwin .titlebar {
2023-01-17 08:07:53 +00:00
height: var(--darwin-titlebar-height);
2023-01-16 15:56:16 +00:00
}
2023-01-10 16:28:27 +00:00
main {
height: 100vh;
2023-01-11 19:41:15 +00:00
display: grid;
grid-template: 1fr / minmax(300px, 0.3fr) 1fr;
2023-01-10 16:28:27 +00:00
}
main.empty {
grid-template: 1fr / 1fr;
}
2023-01-18 10:26:28 +00:00
#root.platform-darwin main {
2023-01-17 08:07:53 +00:00
height: calc(100vh - var(--darwin-titlebar-height));
2023-01-16 15:56:16 +00:00
}
2023-01-15 16:10:30 +00:00
2023-01-17 15:22:49 +00:00
main > :global(*) {
overflow: auto;
min-height: 0;
min-width: 0;
}
2023-01-11 19:41:15 +00:00
main > :global(.addressbar) {
grid-column: 1 / 3;
2023-01-10 16:28:27 +00:00
}
2023-01-14 19:38:39 +00:00
.databaselist {
2023-01-10 19:10:39 +00:00
overflow: scroll;
2023-01-10 16:28:27 +00:00
}
2023-01-15 15:49:08 +00:00
.btn.create {
margin-top: 0.5rem;
}
2023-01-10 16:28:27 +00:00
</style>