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

feat: update localization files and add adventure creation messages; refine adventure filtering logic

This commit is contained in:
Sean Morley 2025-01-16 21:15:22 -05:00
parent 62efa2478e
commit 2b78021155
12 changed files with 117 additions and 30 deletions

View file

@ -1409,13 +1409,10 @@ class OverpassViewSet(viewsets.ViewSet):
# "tags": tags, # Include all raw tags for future use # "tags": tags, # Include all raw tags for future use
} }
# Filter out adventures with no meaningful data # Filter out adventures with no name, latitude, or longitude
if any([ if (adventure["name"] and
adventure["name"], adventure["latitude"] is not None and -90 <= adventure["latitude"] <= 90 and
adventure["latitude"], adventure["longitude"] is not None and -180 <= adventure["longitude"] <= 180) or all:
adventure["longitude"],
]
) or all:
adventures.append(adventure) adventures.append(adventure)
return adventures return adventures

View file

@ -15,7 +15,6 @@ export type User = {
export type Adventure = { export type Adventure = {
id: string; id: string;
user_id: string | null; user_id: string | null;
type: string;
name: string; name: string;
location?: string | null; location?: string | null;
activity_types?: string[] | null; activity_types?: string[] | null;

View file

@ -218,7 +218,9 @@
"transportation_delete_confirm": "Sind Sie sicher, dass Sie diesen Transport löschen möchten? \nDiese Aktion kann nicht rückgängig gemacht werden.", "transportation_delete_confirm": "Sind Sie sicher, dass Sie diesen Transport löschen möchten? \nDiese Aktion kann nicht rückgängig gemacht werden.",
"show_map": "Karte anzeigen", "show_map": "Karte anzeigen",
"will_be_marked": "wird als besucht markiert, sobald das Abenteuer gespeichert ist.", "will_be_marked": "wird als besucht markiert, sobald das Abenteuer gespeichert ist.",
"cities_updated": "Städte aktualisiert" "cities_updated": "Städte aktualisiert",
"create_adventure": "Erstelle Abenteuer",
"no_adventures_to_recommendations": "Keine Abenteuer gefunden. \nFügen Sie mindestens ein Abenteuer hinzu, um Empfehlungen zu erhalten."
}, },
"home": { "home": {
"desc_1": "Entdecken, planen und erkunden Sie mit Leichtigkeit", "desc_1": "Entdecken, planen und erkunden Sie mit Leichtigkeit",

View file

@ -185,12 +185,14 @@
"no_description_found": "No description found", "no_description_found": "No description found",
"adventure_created": "Adventure created", "adventure_created": "Adventure created",
"adventure_create_error": "Failed to create adventure", "adventure_create_error": "Failed to create adventure",
"create_adventure": "Create Adventure",
"adventure_updated": "Adventure updated", "adventure_updated": "Adventure updated",
"adventure_update_error": "Failed to update adventure", "adventure_update_error": "Failed to update adventure",
"set_to_pin": "Set to Pin", "set_to_pin": "Set to Pin",
"category_fetch_error": "Error fetching categories", "category_fetch_error": "Error fetching categories",
"new_adventure": "New Adventure", "new_adventure": "New Adventure",
"basic_information": "Basic Information", "basic_information": "Basic Information",
"no_adventures_to_recommendations": "No adventures found. Add at leat one adventure to get recommendations.",
"adventure_not_found": "There are no adventures to display. Add some using the plus button at the bottom right or try changing filters!", "adventure_not_found": "There are no adventures to display. Add some using the plus button at the bottom right or try changing filters!",
"no_adventures_found": "No adventures found", "no_adventures_found": "No adventures found",
"mark_region_as_visited": "Mark region {region}, {country} as visited?", "mark_region_as_visited": "Mark region {region}, {country} as visited?",

View file

@ -265,7 +265,9 @@
"transportation_delete_confirm": "¿Está seguro de que desea eliminar este transporte? \nEsta acción no se puede deshacer.", "transportation_delete_confirm": "¿Está seguro de que desea eliminar este transporte? \nEsta acción no se puede deshacer.",
"show_map": "Mostrar mapa", "show_map": "Mostrar mapa",
"will_be_marked": "se marcará como visitado una vez guardada la aventura.", "will_be_marked": "se marcará como visitado una vez guardada la aventura.",
"cities_updated": "ciudades actualizadas" "cities_updated": "ciudades actualizadas",
"create_adventure": "Crear aventura",
"no_adventures_to_recommendations": "No se encontraron aventuras. \nAñade al menos una aventura para obtener recomendaciones."
}, },
"worldtravel": { "worldtravel": {
"all": "Todo", "all": "Todo",

View file

@ -218,7 +218,9 @@
"transportation_delete_confirm": "Etes-vous sûr de vouloir supprimer ce transport ? \nCette action ne peut pas être annulée.", "transportation_delete_confirm": "Etes-vous sûr de vouloir supprimer ce transport ? \nCette action ne peut pas être annulée.",
"show_map": "Afficher la carte", "show_map": "Afficher la carte",
"will_be_marked": "sera marqué comme visité une fois laventure sauvegardée.", "will_be_marked": "sera marqué comme visité une fois laventure sauvegardée.",
"cities_updated": "villes mises à jour" "cities_updated": "villes mises à jour",
"create_adventure": "Créer une aventure",
"no_adventures_to_recommendations": "Aucune aventure trouvée. \nAjoutez au moins une aventure pour obtenir des recommandations."
}, },
"home": { "home": {
"desc_1": "Découvrez, planifiez et explorez en toute simplicité", "desc_1": "Découvrez, planifiez et explorez en toute simplicité",

View file

@ -218,7 +218,9 @@
"transportation_delete_confirm": "Sei sicuro di voler eliminare questo trasporto? \nQuesta azione non può essere annullata.", "transportation_delete_confirm": "Sei sicuro di voler eliminare questo trasporto? \nQuesta azione non può essere annullata.",
"show_map": "Mostra mappa", "show_map": "Mostra mappa",
"will_be_marked": "verrà contrassegnato come visitato una volta salvata l'avventura.", "will_be_marked": "verrà contrassegnato come visitato una volta salvata l'avventura.",
"cities_updated": "città aggiornate" "cities_updated": "città aggiornate",
"create_adventure": "Crea Avventura",
"no_adventures_to_recommendations": "Nessuna avventura trovata. \nAggiungi almeno un'avventura per ricevere consigli."
}, },
"home": { "home": {
"desc_1": "Scopri, pianifica ed esplora con facilità", "desc_1": "Scopri, pianifica ed esplora con facilità",

View file

@ -218,7 +218,9 @@
"ending_airport": "Einde luchthaven", "ending_airport": "Einde luchthaven",
"show_map": "Toon kaart", "show_map": "Toon kaart",
"will_be_marked": "wordt gemarkeerd als bezocht zodra het avontuur is opgeslagen.", "will_be_marked": "wordt gemarkeerd als bezocht zodra het avontuur is opgeslagen.",
"cities_updated": "steden bijgewerkt" "cities_updated": "steden bijgewerkt",
"create_adventure": "Creëer avontuur",
"no_adventures_to_recommendations": "Geen avonturen gevonden. \nVoeg ten minste één avontuur toe om aanbevelingen te krijgen."
}, },
"home": { "home": {
"desc_1": "Ontdek, plan en verken met gemak", "desc_1": "Ontdek, plan en verken met gemak",

View file

@ -265,7 +265,9 @@
"transportation_delete_confirm": "Czy na pewno chcesz usunąć ten transport? \nTej akcji nie można cofnąć.", "transportation_delete_confirm": "Czy na pewno chcesz usunąć ten transport? \nTej akcji nie można cofnąć.",
"show_map": "Pokaż mapę", "show_map": "Pokaż mapę",
"will_be_marked": "zostanie oznaczona jako odwiedzona po zapisaniu przygody.", "will_be_marked": "zostanie oznaczona jako odwiedzona po zapisaniu przygody.",
"cities_updated": "miasta zaktualizowane" "cities_updated": "miasta zaktualizowane",
"create_adventure": "Stwórz przygodę",
"no_adventures_to_recommendations": "Nie znaleziono żadnych przygód. \nDodaj co najmniej jedną przygodę, aby uzyskać rekomendacje."
}, },
"worldtravel": { "worldtravel": {
"country_list": "Lista krajów", "country_list": "Lista krajów",

View file

@ -218,7 +218,9 @@
"transportation_delete_confirm": "Är du säker på att du vill ta bort denna transport? \nDenna åtgärd kan inte ångras.", "transportation_delete_confirm": "Är du säker på att du vill ta bort denna transport? \nDenna åtgärd kan inte ångras.",
"show_map": "Visa karta", "show_map": "Visa karta",
"will_be_marked": "kommer att markeras som besökt när äventyret har sparats.", "will_be_marked": "kommer att markeras som besökt när äventyret har sparats.",
"cities_updated": "städer uppdaterade" "cities_updated": "städer uppdaterade",
"create_adventure": "Skapa äventyr",
"no_adventures_to_recommendations": "Inga äventyr hittades. \nLägg till minst ett äventyr för att få rekommendationer."
}, },
"home": { "home": {
"desc_1": "Upptäck, planera och utforska med lätthet", "desc_1": "Upptäck, planera och utforska med lätthet",

View file

@ -208,6 +208,30 @@
} }
} }
function recomendationToAdventure(recomendation: any) {
adventureToEdit = {
id: '',
user_id: null,
name: recomendation.name,
latitude: recomendation.latitude,
longitude: recomendation.longitude,
images: [],
is_visited: false,
is_public: false,
visits: [],
category: {
display_name: recomendation.tag
.replace(/_/g, ' ')
.replace(/\b\w/g, (char: string) => char.toUpperCase()),
icon: osmTagToEmoji(recomendation.tag),
id: '',
name: recomendation.tag,
user_id: ''
}
};
isAdventureModalOpen = true;
}
let adventureToEdit: Adventure | null = null; let adventureToEdit: Adventure | null = null;
let transportationToEdit: Transportation | null = null; let transportationToEdit: Transportation | null = null;
let isAdventureModalOpen: boolean = false; let isAdventureModalOpen: boolean = false;
@ -251,11 +275,24 @@
let loadingRecomendations: boolean = false; let loadingRecomendations: boolean = false;
let recomendationsRange: number = 1600; let recomendationsRange: number = 1600;
let recomendationType: string = 'tourism'; let recomendationType: string = 'tourism';
let recomendationTags: string[] = []; let recomendationTags: { name: string; display_name: string }[] = [];
let selectedRecomendationTag: string = ''; let selectedRecomendationTag: string = '';
let filteredRecomendations: any[] = [];
$: {
if (recomendationsData && selectedRecomendationTag) {
filteredRecomendations = recomendationsData.filter(
(r: any) => r.tag === selectedRecomendationTag
);
} else {
filteredRecomendations = recomendationsData;
}
console.log(filteredRecomendations);
console.log(selectedRecomendationTag);
}
async function getRecomendations(adventure: Adventure) { async function getRecomendations(adventure: Adventure) {
recomendationsData = null; recomendationsData = null;
selectedRecomendationTag = '';
loadingRecomendations = true; loadingRecomendations = true;
let res = await fetch( let res = await fetch(
`/api/overpass/query/?lat=${adventure.latitude}&lon=${adventure.longitude}&radius=${recomendationsRange}&category=${recomendationType}` `/api/overpass/query/?lat=${adventure.latitude}&lon=${adventure.longitude}&radius=${recomendationsRange}&category=${recomendationType}`
@ -267,11 +304,28 @@
let data = await res.json(); let data = await res.json();
recomendationsData = data; recomendationsData = data;
console.log(data); if (recomendationsData && recomendationsData.some((r: any) => r.longitude && r.latitude)) {
if (recomendationsData) { const tagMap = new Map();
recomendationTags = [ recomendationsData.forEach((r: any) => {
...new Set(recomendationsData.map((r: any) => r.tag).filter(Boolean)) const tag = formatTag(r.tag);
] as string[]; if (tag) {
tagMap.set(r.tag, { name: r.tag, display_name: tag });
}
});
recomendationTags = Array.from(tagMap.values());
function formatTag(tag: string): string {
if (tag) {
return (
tag
.split('_')
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(' ') + osmTagToEmoji(tag)
);
} else {
return '';
}
}
} }
loadingRecomendations = false; loadingRecomendations = false;
console.log(recomendationTags); console.log(recomendationTags);
@ -850,10 +904,17 @@
<div class="card-body"> <div class="card-body">
<h2 class="card-title text-3xl justify-center mb-4">Adventure Recommendations</h2> <h2 class="card-title text-3xl justify-center mb-4">Adventure Recommendations</h2>
{#each adventures as adventure} {#each adventures as adventure}
{#if adventure.longitude && adventure.latitude}
<button on:click={() => getRecomendations(adventure)} class="btn btn-neutral" <button on:click={() => getRecomendations(adventure)} class="btn btn-neutral"
>{adventure.name}</button >{adventure.name}</button
> >
{/if}
{/each} {/each}
{#if adventures.length == 0}
<div class="alert alert-info">
<p class="text-center text-lg">{$t('adventures.no_adventures_to_recommendations')}</p>
</div>
{/if}
<div class="mt-4"> <div class="mt-4">
<input <input
type="range" type="range"
@ -898,10 +959,13 @@
/> />
</div> </div>
{#if recomendationTags.length > 0} {#if recomendationTags.length > 0}
<select class="select select-bordered w-full max-w-xs"> <select
<option disabled selected>Select a tag</option> class="select select-bordered w-full max-w-xs"
bind:value={selectedRecomendationTag}
>
<option value="">All</option>
{#each recomendationTags as tag} {#each recomendationTags as tag}
<option on:click={() => (selectedRecomendationTag = tag)}>{tag}</option> <option value={tag.name}>{tag.display_name}</option>
{/each} {/each}
</select> </select>
{/if} {/if}
@ -916,7 +980,7 @@
center={{ lng: recomendationsData[0].longitude, lat: recomendationsData[0].latitude }} center={{ lng: recomendationsData[0].longitude, lat: recomendationsData[0].latitude }}
zoom={12} zoom={12}
> >
{#each recomendationsData as recomendation} {#each filteredRecomendations as recomendation}
{#if recomendation.longitude && recomendation.latitude && recomendation.name} {#if recomendation.longitude && recomendation.latitude && recomendation.name}
<Marker <Marker
lngLat={[recomendation.longitude, recomendation.latitude]} lngLat={[recomendation.longitude, recomendation.latitude]}
@ -942,13 +1006,18 @@
'_blank' '_blank'
)}>{$t('map.view_details')}</button )}>{$t('map.view_details')}</button
> >
<button
class="btn btn-neutral btn-wide btn-sm mt-4"
on:click={() => recomendationToAdventure(recomendation)}
>{$t('adventures.create_adventure')}</button
>
</Popup> </Popup>
{/if} {/if}
</Marker> </Marker>
{/if} {/if}
{/each} {/each}
</MapLibre> </MapLibre>
{#each recomendationsData as recomendation} {#each filteredRecomendations as recomendation}
{#if recomendation.name && recomendation.longitude && recomendation.latitude} {#if recomendation.name && recomendation.longitude && recomendation.latitude}
<div class="card bg-base-100 shadow-xl my-4 w-full"> <div class="card bg-base-100 shadow-xl my-4 w-full">
<div class="card-body"> <div class="card-body">
@ -984,6 +1053,12 @@
{/if} {/if}
</p> </p>
{/if} {/if}
<button
class="btn btn-primary"
on:click={() => recomendationToAdventure(recomendation)}
>
{$t('adventures.create_adventure')}
</button>
</div> </div>
</div> </div>
{/if} {/if}