From 05058bf363371c2337ade323b7768895d99729e4 Mon Sep 17 00:00:00 2001 From: Romein van Buren Date: Fri, 20 Jan 2023 19:08:56 +0100 Subject: [PATCH] Edit hosts --- ...eatehostmodal.svelte => hostdetail.svelte} | 32 +++++++++++++----- .../src/organisms/addressbar/hostmodal.svelte | 33 +++++++++++++++---- internal/app/hosts.go | 2 +- 3 files changed, 50 insertions(+), 17 deletions(-) rename frontend/src/organisms/addressbar/{createhostmodal.svelte => hostdetail.svelte} (60%) diff --git a/frontend/src/organisms/addressbar/createhostmodal.svelte b/frontend/src/organisms/addressbar/hostdetail.svelte similarity index 60% rename from frontend/src/organisms/addressbar/createhostmodal.svelte rename to frontend/src/organisms/addressbar/hostdetail.svelte index 1bfa6c2..33683f5 100644 --- a/frontend/src/organisms/addressbar/createhostmodal.svelte +++ b/frontend/src/organisms/addressbar/hostdetail.svelte @@ -1,17 +1,24 @@ - +
@@ -52,7 +64,9 @@
{error}
{/if}
- +
diff --git a/frontend/src/organisms/addressbar/hostmodal.svelte b/frontend/src/organisms/addressbar/hostmodal.svelte index d7e4ad6..06178f7 100644 --- a/frontend/src/organisms/addressbar/hostmodal.svelte +++ b/frontend/src/organisms/addressbar/hostmodal.svelte @@ -4,7 +4,7 @@ import Icon from '../../components/icon.svelte'; import { Hosts, RemoveHost } from '../../../wailsjs/go/app/App'; import Welcome from './welcome.svelte'; - import CreateHostModal from './createhostmodal.svelte'; + import HostDetail from './hostdetail.svelte'; export let hosts = {}; export let activeHostKey = ''; @@ -12,7 +12,9 @@ const dispatch = createEventDispatcher(); let error = ''; - let createHostModalOpen = false; + let hostDetailModalOpen = false; + let hostDetailModalHost; + let hostDetailModalKey = ''; $: host = hosts?.[activeHostKey]; $: hostCount = Object.keys(hosts).length; @@ -35,6 +37,18 @@ } } + function createHost() { + hostDetailModalHost = undefined; + hostDetailModalKey = ''; + hostDetailModalOpen = true; + } + + function editHost(hostKey) { + hostDetailModalHost = hosts[hostKey]; + hostDetailModalKey = hostKey; + hostDetailModalOpen = true; + } + async function removeHost(hostKey) { try { await RemoveHost(hostKey); @@ -57,7 +71,7 @@ {hostCount} host{hostCount === 1 ? '' : 's'} {/if}

- @@ -66,10 +80,10 @@ {#each Object.entries(hosts) as [hostKey, host]}
  • - -