mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-22 06:19:38 +02:00
chore: Update app version to v0.5.1 and fix toast component styling
This commit is contained in:
parent
25c6d3fce3
commit
a1094f805a
6 changed files with 117 additions and 72 deletions
|
@ -17,12 +17,14 @@
|
||||||
import Plus from '~icons/mdi/plus';
|
import Plus from '~icons/mdi/plus';
|
||||||
import CollectionLink from './CollectionLink.svelte';
|
import CollectionLink from './CollectionLink.svelte';
|
||||||
import DotsHorizontal from '~icons/mdi/dots-horizontal';
|
import DotsHorizontal from '~icons/mdi/dots-horizontal';
|
||||||
|
import DeleteWarning from './DeleteWarning.svelte';
|
||||||
|
|
||||||
export let type: string;
|
export let type: string;
|
||||||
|
|
||||||
export let user: User | null;
|
export let user: User | null;
|
||||||
|
|
||||||
let isCollectionModalOpen: boolean = false;
|
let isCollectionModalOpen: boolean = false;
|
||||||
|
let isWarningModalOpen: boolean = false;
|
||||||
|
|
||||||
let keyword: string = '';
|
let keyword: string = '';
|
||||||
|
|
||||||
|
@ -136,6 +138,17 @@
|
||||||
<CollectionLink on:link={linkCollection} on:close={() => (isCollectionModalOpen = false)} />
|
<CollectionLink on:link={linkCollection} on:close={() => (isCollectionModalOpen = false)} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if isWarningModalOpen}
|
||||||
|
<DeleteWarning
|
||||||
|
title="Delete Adventure"
|
||||||
|
button_text="Delete"
|
||||||
|
description="Are you sure you want to delete this adventure? This action cannot be undone."
|
||||||
|
is_warning={false}
|
||||||
|
on:close={() => (isWarningModalOpen = false)}
|
||||||
|
on:confirm={deleteAdventure}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="card w-full max-w-xs sm:max-w-sm md:max-w-md lg:max-w-md xl:max-w-md bg-primary-content shadow-xl text-base-content"
|
class="card w-full max-w-xs sm:max-w-sm md:max-w-md lg:max-w-md xl:max-w-md bg-primary-content shadow-xl text-base-content"
|
||||||
>
|
>
|
||||||
|
@ -249,7 +262,8 @@
|
||||||
id="delete_adventure"
|
id="delete_adventure"
|
||||||
data-umami-event="Delete Adventure"
|
data-umami-event="Delete Adventure"
|
||||||
class="btn btn-warning"
|
class="btn btn-warning"
|
||||||
on:click={deleteAdventure}><TrashCan class="w-6 h-6" />Delete</button
|
on:click={() => (isWarningModalOpen = true)}
|
||||||
|
><TrashCan class="w-6 h-6" />Delete</button
|
||||||
>
|
>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
import { addToast } from '$lib/toasts';
|
import { addToast } from '$lib/toasts';
|
||||||
|
|
||||||
import Plus from '~icons/mdi/plus';
|
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';
|
import DeleteWarning from './DeleteWarning.svelte';
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
@ -69,7 +70,7 @@
|
||||||
<DeleteWarning
|
<DeleteWarning
|
||||||
title="Delete Collection"
|
title="Delete Collection"
|
||||||
button_text="Delete"
|
button_text="Delete"
|
||||||
description="Are you sure you want to delete this collection? This action cannot be undone."
|
description="Are you sure you want to delete this collection? This will also delete all of the linked adventures. This action cannot be undone."
|
||||||
is_warning={true}
|
is_warning={true}
|
||||||
on:close={() => (isWarningModalOpen = false)}
|
on:close={() => (isWarningModalOpen = false)}
|
||||||
on:confirm={deleteCollection}
|
on:confirm={deleteCollection}
|
||||||
|
@ -77,7 +78,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="card min-w-max lg:w-96 md:w-80 sm:w-60 xs:w-40 bg-primary-content shadow-xl overflow-hidden text-base-content"
|
class="card min-w-max lg:w-96 md:w-80 sm:w-60 xs:w-40 bg-primary-content shadow-xl text-base-content"
|
||||||
>
|
>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
|
@ -111,33 +112,50 @@
|
||||||
</p>{/if}
|
</p>{/if}
|
||||||
|
|
||||||
<div class="card-actions justify-end">
|
<div class="card-actions justify-end">
|
||||||
{#if type != 'link'}
|
<div class="dropdown dropdown-end">
|
||||||
<button on:click={() => (isWarningModalOpen = true)} class="btn btn-secondary"
|
<div tabindex="0" role="button" class="btn btn-neutral">
|
||||||
><TrashCanOutline class="w-5 h-5 mr-1" /></button
|
<DotsHorizontal class="w-6 h-6" />
|
||||||
|
</div>
|
||||||
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||||
|
<ul
|
||||||
|
tabindex="0"
|
||||||
|
class="dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow"
|
||||||
>
|
>
|
||||||
{#if !collection.is_archived}
|
{#if type != 'link'}
|
||||||
<button class="btn btn-primary" on:click={editAdventure}>
|
<button
|
||||||
<FileDocumentEdit class="w-6 h-6" />
|
class="btn btn-neutral mb-2"
|
||||||
</button>
|
on:click={() => goto(`/collections/${collection.id}`)}
|
||||||
{/if}
|
><Launch class="w-5 h-5 mr-1" />Open Details</button
|
||||||
<button class="btn btn-primary" on:click={() => goto(`/collections/${collection.id}`)}
|
>
|
||||||
><Launch class="w-5 h-5 mr-1" /></button
|
{#if !collection.is_archived}
|
||||||
>
|
<button class="btn btn-neutral mb-2" on:click={editAdventure}>
|
||||||
{/if}
|
<FileDocumentEdit class="w-6 h-6" />Edit Collection
|
||||||
{#if type == 'link'}
|
</button>
|
||||||
<button class="btn btn-primary" on:click={() => dispatch('link', collection.id)}>
|
{/if}
|
||||||
<Plus class="w-5 h-5 mr-1" />
|
{#if collection.is_archived}
|
||||||
</button>
|
<button class="btn btn-neutral mb-2" on:click={() => archiveCollection(false)}>
|
||||||
{/if}
|
<ArchiveArrowUp class="w-6 h-6 mr-1" />Unarchive
|
||||||
{#if collection.is_archived}
|
</button>
|
||||||
<button class="btn btn-primary" on:click={() => archiveCollection(false)}>
|
{:else}
|
||||||
<ArchiveArrowUp class="w-5 h-5 mr-1" />
|
<button class="btn btn-neutral mb-2" on:click={() => archiveCollection(true)}>
|
||||||
</button>
|
<ArchiveArrowDown class="w-6 h-6 mr" />Archive
|
||||||
{:else}
|
</button>
|
||||||
<button class="btn btn-primary" on:click={() => archiveCollection(true)}>
|
{/if}
|
||||||
<ArchiveArrowDown class="w-5 h-5 mr" />
|
<button
|
||||||
</button>
|
id="delete_adventure"
|
||||||
{/if}
|
data-umami-event="Delete Adventure"
|
||||||
|
class="btn btn-warning"
|
||||||
|
on:click={() => (isWarningModalOpen = true)}
|
||||||
|
><TrashCan class="w-6 h-6" />Delete</button
|
||||||
|
>
|
||||||
|
{/if}
|
||||||
|
{#if type == 'link'}
|
||||||
|
<button class="btn btn-primary" on:click={() => dispatch('link', collection.id)}>
|
||||||
|
<Plus class="w-5 h-5 mr-1" />
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,8 +11,25 @@
|
||||||
|
|
||||||
<div class="toast toast-top toast-end z-50 min-w-20">
|
<div class="toast toast-top toast-end z-50 min-w-20">
|
||||||
{#each toastList as { type, message, id, duration }}
|
{#each toastList as { type, message, id, duration }}
|
||||||
<div class="alert alert-{type}">
|
{#if type == 'success'}
|
||||||
<span>{message}</span>
|
<div class="alert alert-success">
|
||||||
</div>
|
<span>{message}</span>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{#if type == 'error'}
|
||||||
|
<div class="alert alert-error">
|
||||||
|
<span>{message}</span>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{#if type == 'info'}
|
||||||
|
<div class="alert alert-info">
|
||||||
|
<span>{message}</span>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{#if type == 'warning'}
|
||||||
|
<div class="alert alert-warning">
|
||||||
|
<span>{message}</span>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export let appVersion = 'Web v0.5.0';
|
export let appVersion = 'Web v0.5.1';
|
||||||
export let versionChangelog = 'https://github.com/seanmorley15/AdventureLog/releases/tag/v0.5.0';
|
export let versionChangelog = 'https://github.com/seanmorley15/AdventureLog/releases/tag/v0.5.1';
|
||||||
export let appTitle = 'AdventureLog';
|
export let appTitle = 'AdventureLog';
|
||||||
export let copyrightYear = '2024';
|
export let copyrightYear = '2024';
|
||||||
|
|
|
@ -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 type { PageServerLoad } from './$types';
|
||||||
|
import { appVersion } from '$lib/config';
|
||||||
|
|
||||||
const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL'];
|
const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL'];
|
||||||
const serverEndpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
|
const serverEndpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
|
||||||
|
|
||||||
export const load = (async (event) => {
|
export const load = (async (event) => {
|
||||||
// get url param query
|
|
||||||
const query = event.url.searchParams.get('query');
|
const query = event.url.searchParams.get('query');
|
||||||
const property = event.url.searchParams.get('property') || 'all';
|
const property = event.url.searchParams.get('property') || 'all';
|
||||||
|
|
||||||
|
@ -23,19 +24,33 @@ export const load = (async (event) => {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (res.ok) {
|
if (!res.ok) {
|
||||||
let data = await res.json();
|
|
||||||
console.log('Search data:', data);
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
adventures: data,
|
|
||||||
query
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
console.error('Failed to fetch search data');
|
console.error('Failed to fetch search data');
|
||||||
let error = await res.json();
|
let error = await res.json();
|
||||||
return { error: error.error };
|
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;
|
}) satisfies PageServerLoad;
|
||||||
|
|
|
@ -32,28 +32,6 @@
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
query = urlParams.get('query');
|
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);
|
console.log(data);
|
||||||
|
@ -73,12 +51,15 @@
|
||||||
publicAdventures = publicAdventures.filter(
|
publicAdventures = publicAdventures.filter(
|
||||||
(adventure) => adventure.user_id !== data.user?.pk
|
(adventure) => adventure.user_id !== data.user?.pk
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (data.props.osmData) {
|
||||||
|
osmResults = data.props.osmData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let adventureToEdit: Adventure;
|
let adventureToEdit: Adventure;
|
||||||
let isEditModalOpen: boolean = false;
|
let isEditModalOpen: boolean = false;
|
||||||
let isShowingCreateModal: boolean = false;
|
|
||||||
|
|
||||||
function editAdventure(event: CustomEvent<Adventure>) {
|
function editAdventure(event: CustomEvent<Adventure>) {
|
||||||
adventureToEdit = event.detail;
|
adventureToEdit = event.detail;
|
||||||
|
@ -108,7 +89,7 @@
|
||||||
<NotFound error={data.error} />
|
<NotFound error={data.error} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if myAdventures.length !== 0 && publicAdventures.length !== 0}
|
{#if myAdventures.length !== 0}
|
||||||
<h2 class="text-center font-bold text-2xl mb-4">AdventureLog Results</h2>
|
<h2 class="text-center font-bold text-2xl mb-4">AdventureLog Results</h2>
|
||||||
<div class="flex items-center justify-center mt-2 mb-2">
|
<div class="flex items-center justify-center mt-2 mb-2">
|
||||||
<div class="join">
|
<div class="join">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue