diff --git a/frontend/src/lib/components/AdventureCard.svelte b/frontend/src/lib/components/AdventureCard.svelte index 34d0a506..fe7d41de 100644 --- a/frontend/src/lib/components/AdventureCard.svelte +++ b/frontend/src/lib/components/AdventureCard.svelte @@ -17,12 +17,14 @@ import Plus from '~icons/mdi/plus'; import CollectionLink from './CollectionLink.svelte'; import DotsHorizontal from '~icons/mdi/dots-horizontal'; + import DeleteWarning from './DeleteWarning.svelte'; export let type: string; export let user: User | null; let isCollectionModalOpen: boolean = false; + let isWarningModalOpen: boolean = false; let keyword: string = ''; @@ -136,6 +138,17 @@ (isCollectionModalOpen = false)} /> {/if} +{#if isWarningModalOpen} + (isWarningModalOpen = false)} + on:confirm={deleteAdventure} + /> +{/if} +
@@ -249,7 +262,8 @@ id="delete_adventure" data-umami-event="Delete Adventure" class="btn btn-warning" - on:click={deleteAdventure}>Delete (isWarningModalOpen = true)} + >Delete
diff --git a/frontend/src/lib/components/CollectionCard.svelte b/frontend/src/lib/components/CollectionCard.svelte index 5439fc7f..df07f461 100644 --- a/frontend/src/lib/components/CollectionCard.svelte +++ b/frontend/src/lib/components/CollectionCard.svelte @@ -13,7 +13,8 @@ import { addToast } from '$lib/toasts'; import Plus from '~icons/mdi/plus'; - import { json } from '@sveltejs/kit'; + import DotsHorizontal from '~icons/mdi/dots-horizontal'; + import TrashCan from '~icons/mdi/trashcan'; import DeleteWarning from './DeleteWarning.svelte'; const dispatch = createEventDispatcher(); @@ -69,7 +70,7 @@ (isWarningModalOpen = false)} on:confirm={deleteCollection} @@ -77,7 +78,7 @@ {/if}
@@ -111,33 +112,50 @@

{/if}
- {#if type != 'link'} - +
+ +
+ + +
diff --git a/frontend/src/lib/components/Toast.svelte b/frontend/src/lib/components/Toast.svelte index 6b92848b..5bf90c95 100644 --- a/frontend/src/lib/components/Toast.svelte +++ b/frontend/src/lib/components/Toast.svelte @@ -11,8 +11,25 @@
{#each toastList as { type, message, id, duration }} -
- {message} -
+ {#if type == 'success'} +
+ {message} +
+ {/if} + {#if type == 'error'} +
+ {message} +
+ {/if} + {#if type == 'info'} +
+ {message} +
+ {/if} + {#if type == 'warning'} +
+ {message} +
+ {/if} {/each}
diff --git a/frontend/src/lib/config.ts b/frontend/src/lib/config.ts index eb323885..a2968e9a 100644 --- a/frontend/src/lib/config.ts +++ b/frontend/src/lib/config.ts @@ -1,4 +1,4 @@ -export let appVersion = 'Web v0.5.0'; -export let versionChangelog = 'https://github.com/seanmorley15/AdventureLog/releases/tag/v0.5.0'; +export let appVersion = 'Web v0.5.1'; +export let versionChangelog = 'https://github.com/seanmorley15/AdventureLog/releases/tag/v0.5.1'; export let appTitle = 'AdventureLog'; export let copyrightYear = '2024'; diff --git a/frontend/src/routes/adventures/[id]/+page.svelte b/frontend/src/routes/adventures/[id]/+page.svelte index 06403830..1e6b0f50 100644 --- a/frontend/src/routes/adventures/[id]/+page.svelte +++ b/frontend/src/routes/adventures/[id]/+page.svelte @@ -27,6 +27,10 @@ let adventure: Adventure; let notFound: boolean = false; + let isEditModalOpen: boolean = false; + + import ClipboardList from '~icons/mdi/clipboard-list'; + import EditAdventure from '$lib/components/EditAdventure.svelte'; onMount(() => { if (data.props.adventure) { @@ -35,6 +39,11 @@ notFound = true; } }); + + function saveEdit(event: CustomEvent) { + adventure = event.detail; + isEditModalOpen = false; + } {#if notFound} @@ -59,6 +68,14 @@ {/if} +{#if isEditModalOpen} + (isEditModalOpen = false)} + on:saveEdit={saveEdit} + /> +{/if} + {#if !adventure && !notFound}
@@ -66,6 +83,11 @@ {/if} {#if adventure} +
+ +
diff --git a/frontend/src/routes/search/+page.server.ts b/frontend/src/routes/search/+page.server.ts index de98f840..cf8c4f63 100644 --- a/frontend/src/routes/search/+page.server.ts +++ b/frontend/src/routes/search/+page.server.ts @@ -1,11 +1,12 @@ -import type { Adventure } from '$lib/types'; +import type { Adventure, OpenStreetMapPlace } from '$lib/types'; +import { fail } from '@sveltejs/kit'; import type { PageServerLoad } from './$types'; +import { appVersion } from '$lib/config'; const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL']; const serverEndpoint = PUBLIC_SERVER_URL || 'http://localhost:8000'; export const load = (async (event) => { - // get url param query const query = event.url.searchParams.get('query'); const property = event.url.searchParams.get('property') || 'all'; @@ -23,19 +24,33 @@ export const load = (async (event) => { } ); - if (res.ok) { - let data = await res.json(); - console.log('Search data:', data); - - return { - props: { - adventures: data, - query - } - }; - } else { + if (!res.ok) { console.error('Failed to fetch search data'); let error = await res.json(); return { error: error.error }; } + + let adventures: Adventure[] = await res.json(); + + let osmRes = await fetch(`https://nominatim.openstreetmap.org/search?q=${query}&format=jsonv2`, { + headers: { + 'User-Agent': `AdventureLog / ${appVersion} ` + } + }); + + if (!osmRes.ok) { + console.error('Failed to fetch OSM data'); + let error = await res.json(); + return { error: error.error }; + } + + let osmData = (await osmRes.json()) as OpenStreetMapPlace[]; + + return { + props: { + adventures, + query, + osmData + } + }; }) satisfies PageServerLoad; diff --git a/frontend/src/routes/search/+page.svelte b/frontend/src/routes/search/+page.svelte index 49a147b5..bc849a06 100644 --- a/frontend/src/routes/search/+page.svelte +++ b/frontend/src/routes/search/+page.svelte @@ -32,28 +32,6 @@ onMount(() => { const urlParams = new URLSearchParams(window.location.search); query = urlParams.get('query'); - - fetchData(); - }); - - async function fetchData() { - let res = await fetch(`https://nominatim.openstreetmap.org/search?q=${query}&format=jsonv2`, { - headers: { - 'User-Agent': `AdventureLog / ${appVersion} ` - } - }); - const data = await res.json(); - osmResults = data; - } - - onMount(async () => { - let res = await fetch(`https://nominatim.openstreetmap.org/search?q=${query}&format=jsonv2`, { - headers: { - 'User-Agent': `AdventureLog / ${appVersion} ` - } - }); - const data = await res.json(); - osmResults = data; }); console.log(data); @@ -73,12 +51,15 @@ publicAdventures = publicAdventures.filter( (adventure) => adventure.user_id !== data.user?.pk ); + + if (data.props.osmData) { + osmResults = data.props.osmData; + } } } let adventureToEdit: Adventure; let isEditModalOpen: boolean = false; - let isShowingCreateModal: boolean = false; function editAdventure(event: CustomEvent) { adventureToEdit = event.detail; @@ -108,7 +89,7 @@ {/if} -{#if myAdventures.length !== 0 && publicAdventures.length !== 0} +{#if myAdventures.length !== 0}

AdventureLog Results