1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-26 00:09:38 +02:00

created_at and updated_at fields

This commit is contained in:
Sean Morley 2024-07-19 09:05:47 -04:00
parent 4abaaa5fb3
commit c6633a17cb
11 changed files with 81 additions and 39 deletions

View file

@ -124,11 +124,16 @@
latitude={adventureToEdit.latitude}
on:close={() => (isPointModalOpen = false)}
on:submit={setLongLat}
query={adventureToEdit.name}
/>
{/if}
{#if isImageFetcherOpen}
<ImageFetcher on:image={handleImageFetch} on:close={() => (isImageFetcherOpen = false)} />
<ImageFetcher
on:image={handleImageFetch}
name={adventureToEdit.name}
on:close={() => (isImageFetcherOpen = false)}
/>
{/if}
<dialog id="my_modal_1" class="modal">

View file

@ -6,7 +6,8 @@
let modal: HTMLDialogElement;
let url: string = '';
let query: string = '';
export let name: string | null = null;
let error = '';
@ -30,13 +31,13 @@
}
async function fetchWikiImage() {
let res = await fetch(`/api/generate/img/?name=${query}`);
let res = await fetch(`/api/generate/img/?name=${name}`);
let data = await res.json();
if (data.source) {
let imageUrl = data.source;
let res = await fetch(imageUrl);
let blob = await res.blob();
let file = new File([blob], `${query}.jpg`, { type: 'image/jpeg' });
let file = new File([blob], `${name}.jpg`, { type: 'image/jpeg' });
close();
dispatch('image', { file });
} else {
@ -75,7 +76,7 @@
<input
type="text"
class="input input-bordered w-full max-w-xs"
bind:value={query}
bind:value={name}
placeholder="Enter a Wikipedia Article Name"
/>
<button class="btn btn-primary" on:click={fetchWikiImage}>Submit</button>

View file

@ -132,11 +132,19 @@
</script>
{#if isPointModalOpen}
<PointSelectionModal on:close={() => (isPointModalOpen = false)} on:submit={setLongLat} />
<PointSelectionModal
query={newAdventure.name}
on:close={() => (isPointModalOpen = false)}
on:submit={setLongLat}
/>
{/if}
{#if isImageFetcherOpen}
<ImageFetcher on:image={handleImageFetch} on:close={() => (isImageFetcherOpen = false)} />
<ImageFetcher
on:image={handleImageFetch}
name={newAdventure.name}
on:close={() => (isImageFetcherOpen = false)}
/>
{/if}
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->

View file

@ -10,7 +10,11 @@
let markers: Point[] = [];
let query: string = '';
export let query: string | null = null;
if (query) {
geocode();
}
export let longitude: number | null = null;
export let latitude: number | null = null;
@ -43,8 +47,10 @@
let places: OpenStreetMapPlace[] = [];
async function geocode(e: Event) {
e.preventDefault();
async function geocode(e: Event | null) {
if (e) {
e.preventDefault();
}
if (!query) {
alert('Please enter a location');
return;