diff --git a/db/main.go b/db/main.go index 65a1635e..5323ed4f 100644 --- a/db/main.go +++ b/db/main.go @@ -157,7 +157,7 @@ func main() { for _, trail := range trails { log.Println(trail) - if err := util.IndexTrail(trail, client); err != nil { + if err := util.UpdateTrail(trail, client); err != nil { return err } } diff --git a/db/migrations/1717613522_updated_user_tokens.go b/db/migrations/1717613522_updated_user_tokens.go index 3941ac44..8388b4fd 100644 --- a/db/migrations/1717613522_updated_user_tokens.go +++ b/db/migrations/1717613522_updated_user_tokens.go @@ -19,10 +19,18 @@ func init() { }) m.Register(func(db dbx.Builder) error { + _, err := client.Index("trails").UpdateFilterableAttributes(&[]string{ + "_geo", "author", "category", "completed", "date", "difficulty", "distance", "elevation_gain", "public", "shares", + }) + + if err != nil { + return err + } + dao := daos.New(db) var usernames []string - err := db.NewQuery("SELECT username FROM users").Column(&usernames) + err = db.NewQuery("SELECT username FROM users").Column(&usernames) if err != nil { return err diff --git a/docker-compose.yml b/docker-compose.yml index 8704ad8d..f5680eb5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -54,8 +54,8 @@ services: PUBLIC_POCKETBASE_URL: http://db:8090 PUBLIC_DISABLE_SIGNUP: false UPLOAD_FOLDER: /app/uploads - UPLOAD_USER: Flomp - UPLOAD_PASSWORD: 12345678 + UPLOAD_USER: + UPLOAD_PASSWORD: PUBLIC_VALHALLA_URL: https://valhalla1.openstreetmap.de volumes: - ./data/uploads:/app/uploads diff --git a/search/migrations/migration.dump b/search/migrations/migration.dump index d4831219..684fdb11 100644 Binary files a/search/migrations/migration.dump and b/search/migrations/migration.dump differ diff --git a/web/cron.sh b/web/cron.sh index 20210beb..ad2706e9 100644 --- a/web/cron.sh +++ b/web/cron.sh @@ -18,9 +18,9 @@ login() { # Check if login was successful (look for "200 OK" in response headers) if [ $? -eq 0 ] && [ "$(echo "$response" | grep -c "token")" -eq 1 ]; then - echo "$(date +"%T"): Login successful. Cookie obtained." > /proc/1/fd/1 + echo "[INFO] [$(date +"%T")]: Login successful. Cookie obtained." > /proc/1/fd/1 else - echo "$(date +"%T"): Login failed. Unable to obtain cookie." > /proc/1/fd/1 + echo "[ERROR] [$(date +"%T")]: Login failed. Unable to obtain cookie." > /proc/1/fd/1 exit 1 fi } @@ -36,16 +36,16 @@ upload_and_delete() { # Check if API call was successful (status code 200) if [ $? -eq 0 ] && [ "$(echo "$response" | grep -c "author")" -eq 1 ]; then - echo "$(date +"%T"): File $file uploaded successfully." > /proc/1/fd/1 + echo "[INFO] [$(date +"%T")]: File $file uploaded successfully." > /proc/1/fd/1 # Delete the file rm "$file" - echo "File $file deleted." + echo "[INFO] [$(date +"%T")]: File $file deleted." else echo $response - echo "$(date +"%T"): Failed to upload file $file." > /proc/1/fd/1 + echo "[ERROR] [$(date +"%T")]: Failed to upload file $file." > /proc/1/fd/1 fi } - echo "$(date +"%T"): Starting auto-upload" > /proc/1/fd/1 +echo "[INFO] [$(date +"%T")]: Starting auto-upload" > /proc/1/fd/1 # Login to obtain cookie login "$USERNAME" "$PASSWORD" @@ -57,4 +57,4 @@ for file in "$UPLOAD_FOLDER"/*; do fi done -echo "$(date +"%T"): Auto-upload completed" > /proc/1/fd/1 +echo "[INFO] [$(date +"%T")]: Auto-upload completed" > /proc/1/fd/1 diff --git a/web/src/lib/components/trail/trail_info_panel.svelte b/web/src/lib/components/trail/trail_info_panel.svelte index 6ef0bd1a..012c1059 100644 --- a/web/src/lib/components/trail/trail_info_panel.svelte +++ b/web/src/lib/components/trail/trail_info_panel.svelte @@ -8,8 +8,10 @@ import type { Trail } from "$lib/models/trail"; import { + comments, comments_create, comments_delete, + comments_index, comments_update, } from "$lib/stores/comment_store"; import { currentUser } from "$lib/stores/user_store"; @@ -59,6 +61,10 @@ let commentCreateLoading: boolean = false; let commentDeleteLoading: boolean = false; + $: if (activeTab == 4) { + fetchComments(); + } + onMount(async () => { if (mode == "overview") { const L = (await import("leaflet")).default; @@ -115,6 +121,10 @@ goto(`/map/trail/${trail.id!}`); } + async function fetchComments() { + await comments_index(trail); + } + async function createComment() { if (!$currentUser || !trail.id) { return; @@ -129,10 +139,8 @@ author: $currentUser!, }; - trail.expand.comments_via_trail = [ - c, - ...(trail.expand.comments_via_trail ?? []), - ]; + const newCommentList = [c, ...$comments]; + comments.set(newCommentList); }); commentCreateLoading = false; @@ -146,8 +154,8 @@ async function deleteComment(comment: Comment) { commentDeleteLoading = true; await comments_delete(comment); - trail.expand.comments_via_trail = - trail.expand.comments_via_trail.filter((c) => c.id !== comment.id); + const newCommentList = $comments.filter((c) => c.id !== comment.id); + comments.set(newCommentList); commentDeleteLoading = false; } @@ -155,28 +163,28 @@
-
+
- +
{#if trail.public || trail.expand?.trail_share_via_trail?.length} -
- {#if trail.public} - - - - {/if} - {#if trail.expand?.trail_share_via_trail?.length} - - {/if} -
+
+ {#if trail.public} + + + + {/if} + {#if trail.expand?.trail_share_via_trail?.length} + + {/if} +
{/if}

{/if} -
- -
-
+
+ +
+
{/if}
    - {#each trail.expand.comments_via_trail ?? [] as comment} + {#each $comments ?? [] as comment}
  • {#if showInfo}