1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2024-12-01 13:20:54 +00:00

Create new host button

This commit is contained in:
Romein van Buren 2023-01-19 08:36:05 +01:00
parent dbceac7edf
commit 9cecad0c3a
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49

View File

@ -14,6 +14,7 @@
let error = '';
let createHostModalOpen = false;
$: host = hosts?.[activeHostKey];
$: hostCount = Object.keys(hosts).length;
$: if (!modalOpen) {
error = '';
@ -47,13 +48,20 @@
onMount(getHosts);
</script>
<Modal bind:show={modalOpen} title={Object.keys(hosts).length && 'Hosts'} width="60vw">
<Modal bind:show={modalOpen} title={hostCount && 'Hosts'} width="60vw">
<div class="status">
<p class:error>
{#if error}
<p class="error">
<strong>Oops!</strong> {error}
</p>
{:else}
{hostCount} host{hostCount === 1 ? '' : 's'}
{/if}
{#if Object.keys(hosts).length}
</p>
<button class="btn" on:click={() => createHostModalOpen = true}>
Create new host
</button>
</div>
{#if hostCount}
<ul class="hosts">
{#each Object.entries(hosts) as [hostKey, host]}
<li>
@ -85,6 +93,11 @@
gap: 0.5rem;
}
.status {
display: flex;
justify-content: space-between;
align-items: center;
}
.error {
color: #c00;
}