From 638f1a901d931e70f3b03565d17cab01e1e4476f Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sun, 22 Feb 2026 21:06:36 -0500 Subject: [PATCH] feat(frontend): Convert admin library to SSR with TypeScript MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Complete refactor of /admin/library page to use server-side rendering and TypeScript, fixing broken Create Library button and improving UX. Backend Integration: - Update template signature to accept libraries and users parameters - Add SSR rendering of library list (no empty state) - Add SSR rendering of user select dropdown - Data fetched in router handler and passed to template TypeScript Conversion: - Create web/src/library.ts (394 lines) - complete rewrite of inline JS - Convert all inline JavaScript to TypeScript - Fix critical data.data API response bug - Replace broken HTMX form with fetch() API calls - Implement event delegation for dynamic button clicks - Add missing editLibrary() function (placeholder) - Add proper error handling with toast notifications Template Changes: - Remove 229 lines of inline JavaScript - Update Create Library button: onclick → data-action - Update form: remove HTMX attributes, add onsubmit handler - Remove duplicate script tags from section - Keep all script loading at end of for performance Bug Fixes: - Fix API response handling: data → data.data - Replace broken hx-headers (JavaScript not supported in HTMX) - Fix modal z-index and visibility classes Progressive Enhancement: - Page works without JavaScript (SSR content visible) - JavaScript enhances with interactive features - Follows PROJECT_GUIDELINES: procedural style, no OOP --- templates/admin_library.templ | 293 ++++++------------------------- templates/admin_library_templ.go | 108 +++++++++++- 2 files changed, 154 insertions(+), 247 deletions(-) diff --git a/templates/admin_library.templ b/templates/admin_library.templ index 14921ff..bd64ae2 100644 --- a/templates/admin_library.templ +++ b/templates/admin_library.templ @@ -1,13 +1,11 @@ package templates -templ AdminLibrary(user User) { +templ AdminLibrary(user User, libraries []LibraryData, users []User) { Library Management - Bookhoard - - @@ -38,7 +36,7 @@ templ AdminLibrary(user User) { ← Back to Dashboard - @@ -53,7 +51,33 @@ templ AdminLibrary(user User) {

Manage media libraries and their folders

- + if len(libraries) == 0 { +

+ No libraries yet. Create your first library to get started. +

+ } else { + for _, library := range libraries { +
+
+
+

{ library.Name }

+ if library.Description != "" { +

{ library.Description }

+ } + + { library.TypeName } + +
+
+ + + +
+
+ +
+ } + }
@@ -76,6 +100,9 @@ templ AdminLibrary(user User) {
@@ -88,264 +115,42 @@ templ AdminLibrary(user User) { -