From 44d506bc69d2af894da25b4c443e05fb31b4fe43 Mon Sep 17 00:00:00 2001 From: John Costa Date: Fri, 21 Mar 2025 14:36:03 +0000 Subject: [PATCH] wip(frontend): adding more information --- .../.gen/haystack/haystack/model/events.go | 2 +- .../.gen/haystack/haystack/table/events.go | 10 +++--- backend/models/events.go | 6 ++++ backend/models/user.go | 2 +- backend/schema.sql | 2 +- frontend/src-tauri/src/lib.rs | 3 +- frontend/src/App.tsx | 26 +++++++------- frontend/src/ImagePage.tsx | 35 +++++++++++++++++-- frontend/src/network/index.ts | 3 +- 9 files changed, 63 insertions(+), 26 deletions(-) diff --git a/backend/.gen/haystack/haystack/model/events.go b/backend/.gen/haystack/haystack/model/events.go index a9494cb..1c21e6a 100644 --- a/backend/.gen/haystack/haystack/model/events.go +++ b/backend/.gen/haystack/haystack/model/events.go @@ -15,5 +15,5 @@ type Events struct { ID uuid.UUID `sql:"primary_key"` Name string Description *string - Location *uuid.UUID + LocationID *uuid.UUID } diff --git a/backend/.gen/haystack/haystack/table/events.go b/backend/.gen/haystack/haystack/table/events.go index 7d1eab5..965e789 100644 --- a/backend/.gen/haystack/haystack/table/events.go +++ b/backend/.gen/haystack/haystack/table/events.go @@ -20,7 +20,7 @@ type eventsTable struct { ID postgres.ColumnString Name postgres.ColumnString Description postgres.ColumnString - Location postgres.ColumnString + LocationID postgres.ColumnString AllColumns postgres.ColumnList MutableColumns postgres.ColumnList @@ -64,9 +64,9 @@ func newEventsTableImpl(schemaName, tableName, alias string) eventsTable { IDColumn = postgres.StringColumn("id") NameColumn = postgres.StringColumn("name") DescriptionColumn = postgres.StringColumn("description") - LocationColumn = postgres.StringColumn("location") - allColumns = postgres.ColumnList{IDColumn, NameColumn, DescriptionColumn, LocationColumn} - mutableColumns = postgres.ColumnList{NameColumn, DescriptionColumn, LocationColumn} + LocationIDColumn = postgres.StringColumn("location_id") + allColumns = postgres.ColumnList{IDColumn, NameColumn, DescriptionColumn, LocationIDColumn} + mutableColumns = postgres.ColumnList{NameColumn, DescriptionColumn, LocationIDColumn} ) return eventsTable{ @@ -76,7 +76,7 @@ func newEventsTableImpl(schemaName, tableName, alias string) eventsTable { ID: IDColumn, Name: NameColumn, Description: DescriptionColumn, - Location: LocationColumn, + LocationID: LocationIDColumn, AllColumns: allColumns, MutableColumns: mutableColumns, diff --git a/backend/models/events.go b/backend/models/events.go index c4fb572..1287194 100644 --- a/backend/models/events.go +++ b/backend/models/events.go @@ -24,6 +24,12 @@ func getEventValues(event model.Events) []any { arr = append(arr, nil) } + if event.LocationID != nil { + arr = append(arr, *event.LocationID) + } else { + arr = append(arr, nil) + } + return arr } diff --git a/backend/models/user.go b/backend/models/user.go index fc148d8..6581053 100644 --- a/backend/models/user.go +++ b/backend/models/user.go @@ -79,7 +79,7 @@ func (m UserModel) ListWithProperties(ctx context.Context, userId uuid.UUID) ([] LEFT_JOIN(ImageLocations, ImageLocations.ImageID.EQ(UserImages.ImageID)). LEFT_JOIN(Locations, Locations.ID.EQ(ImageLocations.LocationID)). LEFT_JOIN(ImageEvents, ImageEvents.ImageID.EQ(UserImages.ImageID)). - LEFT_JOIN(Events, Events.ID.EQ(ImageEvents.ID))). + LEFT_JOIN(Events, Events.ID.EQ(ImageEvents.EventID))). WHERE(UserImages.UserID.EQ(UUID(userId))) fmt.Println(listWithPropertiesStmt.DebugSql()) diff --git a/backend/schema.sql b/backend/schema.sql index 1bd7ef3..822f68b 100644 --- a/backend/schema.sql +++ b/backend/schema.sql @@ -74,7 +74,7 @@ CREATE TABLE haystack.events ( name TEXT NOT NULL, description TEXT, - location UUID REFERENCES haystack.locations (id) + location_id UUID REFERENCES haystack.locations (id) ); CREATE TABLE haystack.image_events ( diff --git a/frontend/src-tauri/src/lib.rs b/frontend/src-tauri/src/lib.rs index c1fcc24..daa3d04 100644 --- a/frontend/src-tauri/src/lib.rs +++ b/frontend/src-tauri/src/lib.rs @@ -7,7 +7,7 @@ use std::sync::Arc; use std::sync::Mutex; use tauri::AppHandle; use tauri::Emitter; -use tauri::{TitleBarStyle, WebviewUrl, WebviewWindowBuilder}; +use tauri::{WebviewUrl, WebviewWindowBuilder}; struct WatcherState { watcher: Option, @@ -114,7 +114,6 @@ pub fn run() { .invoke_handler(tauri::generate_handler![handle_selected_folder]) .setup(|app| { let win_builder = WebviewWindowBuilder::new(app, "main", WebviewUrl::default()) - .hidden_title(true) .inner_size(480.0, 360.0) .resizable(true); // set transparent title bar only when building for macOS diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 3a739db..078f7d9 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -5,6 +5,7 @@ import clsx from "clsx"; import Fuse from "fuse.js"; import { createEffect, createResource, createSignal, For } from "solid-js"; import { getUserImages } from "./network"; +import { ImageViewer } from "./components/ImageViewer"; type UserImages = Awaited>; @@ -18,7 +19,6 @@ function App() { const nav = useNavigate(); let fuze = new Fuse[number]>([], { - keys: ["Text.ImageText"], keys: ["ImageText"], }); @@ -26,7 +26,6 @@ function App() { createEffect(() => { const userImages = images(); - console.log(userImages); if (userImages == null) { return; } @@ -98,23 +97,24 @@ function App() { + + e.preventDefault()} + > + + + No results found + + + {/*
Emoji selected: {emoji()?.emoji} {emoji()?.name}
*/} - {/* */} +
- e.preventDefault()} - > - - - No results found - - -
diff --git a/frontend/src/ImagePage.tsx b/frontend/src/ImagePage.tsx index 0df3f4b..5d3bc5c 100644 --- a/frontend/src/ImagePage.tsx +++ b/frontend/src/ImagePage.tsx @@ -25,10 +25,41 @@ export function ImagePage() { Loading...}> Back

{image()?.Image.ImageName}

- + link
+

Tags

- {(tag) =>
{tag.Tag}
} + {(tag) =>
{tag.Tag.Tag}
} +
+ +

Locations

+ + {(location) => ( +
    +
  • {location.Name}
  • + {location.Address &&
  • {location.Address}
  • } + {location.Coordinates && ( +
  • {location.Coordinates}
  • + )} + {location.Description && ( +
  • {location.Description}
  • + )} +
+ )} +
+ +

Events

+ + {(event) => ( +
    +
  • {event.Name}
  • + {event.Location &&
  • {event.Location.Name}
  • } + {event.Description &&
  • {event.Description}
  • } +
+ )}
diff --git a/frontend/src/network/index.ts b/frontend/src/network/index.ts index 87fcad9..68df1b5 100644 --- a/frontend/src/network/index.ts +++ b/frontend/src/network/index.ts @@ -7,6 +7,7 @@ import { parse, pipe, string, + undefinedable, uuid, } from "valibot"; @@ -82,7 +83,7 @@ const getUserImagesResponseValidator = array( array( object({ ID: pipe(string(), uuid()), - Links: string(), + Link: string(), ImageID: pipe(string(), uuid()), }), ),