1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-31 10:19:27 +00:00
rolens/frontend/src/app.svelte
Romein van Buren a1456b3987
Implement OOP hosttree (#32)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-18 21:31:55 +02:00

109 lines
2.7 KiB
Svelte

<script>
import BlankState from '$components/blankstate.svelte';
import ContextMenu from '$components/contextmenu.svelte';
import dialogs from '$lib/dialogs';
import contextMenu from '$lib/stores/contextmenu';
import environment from '$lib/stores/environment';
import hostTree from '$lib/stores/hosttree';
import applicationInited from '$lib/stores/inited';
import windowTitle from '$lib/stores/windowtitle';
import Connection from '$organisms/connection/index.svelte';
import { EventsOn } from '$wails/runtime';
import { tick } from 'svelte';
import AboutDialog from './dialogs/about.svelte';
import SettingsDialog from './dialogs/settings/index.svelte';
let showWelcomeScreen = undefined;
applicationInited.defer(() => {
hostTree.subscribe(hosts => {
if (hostTree.hasBeenInited() && (showWelcomeScreen === undefined)) {
showWelcomeScreen = !Object.keys(hosts || {}).length;
}
});
});
async function createFirstHost() {
showWelcomeScreen = false;
await tick();
hostTree.newHost();
}
function showAboutDialog() {
dialogs.new(AboutDialog);
}
function showSettings() {
dialogs.new(SettingsDialog);
}
EventsOn('OpenPreferences', showSettings);
EventsOn('OpenAboutModal', showAboutDialog);
</script>
<svelte:window on:contextmenu|preventDefault />
<div id="root" class="platform-{$environment?.platform}">
<div class="titlebar">{$windowTitle}</div>
{#if $applicationInited && (showWelcomeScreen !== undefined)}
<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 />
{/if}
</main>
{#key $contextMenu}
<ContextMenu {...$contextMenu} on:close={contextMenu.hide} />
{/key}
{/if}
</div>
<style>
.titlebar {
height: 0;
background-color: #00002a;
--wails-draggable: drag;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
}
#root.platform-darwin .titlebar {
height: var(--darwin-titlebar-height);
}
main {
height: 100vh;
display: grid;
grid-template: 1fr / minmax(300px, 0.3fr) 1fr;
}
main.empty {
grid-template: 1fr / 1fr;
}
#root.platform-darwin main {
height: calc(100vh - var(--darwin-titlebar-height));
}
main > :global(*) {
overflow: auto;
min-height: 0;
min-width: 0;
}
main > :global(.addressbar) {
grid-column: 1 / 3;
}
.databaselist {
overflow: scroll;
}
.btn.create {
margin-top: 0.5rem;
}
</style>