1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-23 14:59:36 +02:00

Remove AUTHORS and MANIFEST.in files; add ReverseGeocodeViewSet and localization updates

This commit is contained in:
Sean Morley 2024-10-30 15:11:00 -04:00
parent 05076a6732
commit 83d06fc0a4
13 changed files with 109 additions and 42 deletions

View file

@ -3,7 +3,7 @@
import type { Adventure, User } from '$lib/types';
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
import type { ActionResult } from '@sveltejs/kit';
import { t } from 'svelte-i18n';
import { onMount } from 'svelte';
import AdventureCard from './AdventureCard.svelte';
let modal: HTMLDialogElement;
@ -51,7 +51,7 @@
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
<div class="modal-box w-11/12 max-w-5xl" role="dialog" on:keydown={handleKeydown} tabindex="0">
<h1 class="text-center font-bold text-4xl mb-6">My Adventures</h1>
<h1 class="text-center font-bold text-4xl mb-6">{$t('adventures.my_adventures')}</h1>
{#if isLoading}
<div class="flex justify-center items-center w-full mt-16">
<span class="loading loading-spinner w-24 h-24"></span>
@ -63,10 +63,10 @@
{/each}
{#if adventures.length === 0 && !isLoading}
<p class="text-center text-lg">
No adventures found that can be linked to this collection.
{$t('adventures.no_linkable_adventures')}
</p>
{/if}
</div>
<button class="btn btn-primary" on:click={close}>Close</button>
<button class="btn btn-primary" on:click={close}>{$t('about.close')}</button>
</div>
</dialog>

View file

@ -1,6 +1,12 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import type { Adventure, Collection, OpenStreetMapPlace, Point } from '$lib/types';
import type {
Adventure,
Collection,
OpenStreetMapPlace,
Point,
ReverseGeocode
} from '$lib/types';
import { onMount } from 'svelte';
import { enhance } from '$app/forms';
import { addToast } from '$lib/toasts';
@ -27,6 +33,8 @@
let noPlaces: boolean = false;
let reverseGeocodePlace: ReverseGeocode | null = null;
let adventure: Adventure = {
id: '',
name: '',
@ -136,6 +144,12 @@
}
}
$: {
if (adventure.longitude && adventure.latitude) {
reverseGeocode();
}
}
async function fetchImage() {
let res = await fetch(url);
let data = await res.blob();
@ -249,29 +263,15 @@
async function reverseGeocode() {
let res = await fetch(
`https://nominatim.openstreetmap.org/search?q=${adventure.latitude},${adventure.longitude}&format=jsonv2`,
{
headers: {
'User-Agent': `AdventureLog / ${appVersion} `
}
}
`/api/reverse-geocode/reverse_geocode/?lat=${adventure.latitude}&lon=${adventure.longitude}`
);
let data = (await res.json()) as OpenStreetMapPlace[];
if (data.length > 0) {
adventure.name = data[0]?.name || '';
adventure.activity_types?.push(data[0]?.type || '');
adventure.location = data[0]?.display_name || '';
if (longitude && latitude) {
markers = [
{
lngLat: { lng: longitude, lat: latitude },
location: data[0]?.display_name || '',
name: data[0]?.name || '',
activity_type: data[0]?.type || ''
}
];
}
let data = await res.json();
if (data.error) {
console.log(data.error);
reverseGeocodePlace = null;
return;
}
reverseGeocodePlace = data;
console.log(data);
}
@ -610,6 +610,13 @@ it would also work to just use on:click on the MapLibre component itself. -->
<DefaultMarker lngLat={marker.lngLat} />
{/each}
</MapLibre>
{#if reverseGeocodePlace}
<div class="mt-2">
<p>{reverseGeocodePlace.id}</p>
<p>{reverseGeocodePlace.region}, {reverseGeocodePlace.country}</p>
<p>{reverseGeocodePlace.is_visited ? 'Visited' : 'Not Visited'}</p>
</div>
{/if}
</div>
</div>
</div>

View file

@ -5,6 +5,7 @@
import { onMount } from 'svelte';
import CollectionCard from './CollectionCard.svelte';
let modal: HTMLDialogElement;
import { t } from 'svelte-i18n';
let collections: Collection[] = [];
@ -44,15 +45,15 @@
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
<div class="modal-box w-11/12 max-w-5xl" role="dialog" on:keydown={handleKeydown} tabindex="0">
<h1 class="text-center font-bold text-4xl mb-6">My Collections</h1>
<h1 class="text-center font-bold text-4xl mb-6">{$t('adventures.my_collections')}</h1>
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
{#each collections as collection}
<CollectionCard {collection} type="link" on:link={link} />
{/each}
{#if collections.length === 0}
<p class="text-center text-lg">No collections found to add this adventure to.</p>
<p class="text-center text-lg">{$t('adventures.no_collections_found')}</p>
{/if}
</div>
<button class="btn btn-primary" on:click={close}>Close</button>
<button class="btn btn-primary" on:click={close}>{$t('about.close')}</button>
</div>
</dialog>

View file

@ -1,6 +1,7 @@
<script lang="ts">
import Lost from '$lib/assets/undraw_lost.svg';
export let error: string | undefined;
import { t } from 'svelte-i18n';
</script>
<div
@ -11,12 +12,11 @@
<img src={Lost} alt="Lost" class="w-1/2" />
</div>
<h1 class="mt-4 text-3xl font-bold tracking-tight text-foreground sm:text-4xl">
No adventures found
{$t('adventures.no_adventures_found')}
</h1>
{#if !error}
<p class="mt-4 text-muted-foreground">
There are no adventures to display. Add some using the plus button at the bottom right or
try changing filters!
{$t('adventures.adventure_not_found')}
</p>
{:else}
<p class="text-error mt-2">{error}</p>