Release / build-and-push (push) Successful in 3m31s
templ does not interpolate { expr } inside quoted attribute values — the
braces ship as literal text (AGENTS.md gotcha #1). Swept every templ
source for the pattern and fixed all of it:
Body theme classes: 22 page bodies rendered class="theme-{ user.Theme }"
literally, so every page first-painted the :root default (Tokyo Night)
and flashed when main.js applied the real theme. All now render
class={ "theme-" + user.Theme } server-side.
Attribute interpolations (26 across 8 files):
- api_explorer: initAPIExplorerDoc path/body/response and the Copy
Request/Response buttons (invalid JS, silently dead)
- collections: book-selection :checked/@change/@click ids and four
hx-get search URLs (collection_id={ collection.ID })
- conflicts: Resolve button id
- devices: Kobo sync-url/auth-token element ids (copy lookups only
worked because the id and the lookup were the same literal)
- unlinked_books: search-matches/manual-link clicks and container ids
- queue: status/priority badge classes never matched their CSS
- dashboard: Restore-section tooltip text
- collection_rules/collections: collection icon color
Free text goes through the new templates.JSONArg (json.Marshal) —
templ.JSONString in this templ version returns (string, error) and
cannot compose in attribute expressions; uuids via device.ID.String().
Includes regen-only drift from running templ generate (error-path
normalization) on files with no source change.
138 lines
6.2 KiB
Templ
138 lines
6.2 KiB
Templ
package templates
|
|
|
|
templ Admin(user User, stats AdminStats) {
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
<title>Admin Dashboard - Bookhoard</title>
|
|
<link href="/static/style.css" rel="stylesheet"/>
|
|
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg"/>
|
|
</head>
|
|
<body x-data="admin" x-init="loadWatchStatus(); checkActiveScans()" class={ "theme-" + user.Theme }>
|
|
@Header(user, "/admin")
|
|
<main class="p-8">
|
|
<div class="max-w-4xl">
|
|
<div class="mb-8">
|
|
<div class="flex items-center gap-3 mb-1">
|
|
<span class="grid place-items-center h-10 w-10 rounded-xl" style="background-color: var(--accent-muted); color: var(--accent);">
|
|
@Icon("grid", "h-5 w-5")
|
|
</span>
|
|
<h1 class="text-2xl font-bold tracking-tight" style="color: var(--text-primary)">Dashboard</h1>
|
|
</div>
|
|
<p class="text-sm" style="color: var(--text-secondary)">Overview of your Bookhoard instance</p>
|
|
</div>
|
|
<!-- Stats Grid -->
|
|
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-6">
|
|
<div class="stat-card">
|
|
<div class="flex items-center gap-2 mb-2" style="color: var(--text-secondary);">
|
|
@Icon("library", "h-4 w-4")
|
|
<span class="text-xs font-semibold uppercase tracking-wide">Libraries</span>
|
|
</div>
|
|
<p class="text-2xl font-bold" style="color: var(--text-primary)">{ stats.LibraryCount }</p>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="flex items-center gap-2 mb-2" style="color: var(--text-secondary);">
|
|
@Icon("book", "h-4 w-4")
|
|
<span class="text-xs font-semibold uppercase tracking-wide">Books</span>
|
|
</div>
|
|
<p class="text-2xl font-bold" style="color: var(--text-primary)">{ stats.MediaCount }</p>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="flex items-center gap-2 mb-2" style="color: var(--text-secondary);">
|
|
@Icon("users", "h-4 w-4")
|
|
<span class="text-xs font-semibold uppercase tracking-wide">Users</span>
|
|
</div>
|
|
<p class="text-2xl font-bold" style="color: var(--text-primary)">{ stats.UserCount }</p>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="flex items-center gap-2 mb-2" style="color: var(--text-secondary);">
|
|
@Icon("device", "h-4 w-4")
|
|
<span class="text-xs font-semibold uppercase tracking-wide">Devices</span>
|
|
</div>
|
|
<p class="text-2xl font-bold" style="color: var(--text-primary)">{ stats.DeviceCount }</p>
|
|
</div>
|
|
</div>
|
|
<!-- Watch Status -->
|
|
<div class="stat-card mb-6">
|
|
<div class="flex items-center gap-3">
|
|
<span class="grid place-items-center h-11 w-11 rounded-xl shrink-0" style="background-color: var(--accent-muted); color: var(--accent);">
|
|
@Icon("sync", "h-5 w-5")
|
|
</span>
|
|
<div class="flex-1">
|
|
<h3 class="font-semibold" style="color: var(--text-primary)">File Watcher</h3>
|
|
<p class="text-sm" style="color: var(--text-secondary)">Auto-detects new files in library folders</p>
|
|
</div>
|
|
<div class="text-right text-sm" style="color: var(--text-secondary)">
|
|
<span class="inline-block w-2 h-2 rounded-full mr-2" style="background-color: var(--status-success);"></span>
|
|
Watching <span id="watch-count">0</span> libraries
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Quick Actions -->
|
|
<div class="card p-6">
|
|
<h3 class="text-lg font-semibold mb-4" style="color: var(--text-primary)">Quick Actions</h3>
|
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
|
<button @click="scanAllLibraries()" class="btn btn-primary py-4 flex-col items-start gap-1">
|
|
<span class="flex items-center gap-2 font-medium">
|
|
@Icon("refresh", "h-5 w-5")
|
|
Scan All Libraries
|
|
</span>
|
|
<span class="text-xs font-normal opacity-80">Re-scan existing files and detect new items</span>
|
|
</button>
|
|
<a href="/admin/library" class="btn btn-secondary py-4 flex-col items-start gap-1">
|
|
<span class="flex items-center gap-2 font-medium">
|
|
@Icon("library", "h-5 w-5")
|
|
Manage Libraries
|
|
</span>
|
|
<span class="text-xs font-normal opacity-80">Add or remove libraries and folders</span>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<!-- Scan Progress Section -->
|
|
<div id="scan-progress-container" class="card hidden mt-6 p-6 opacity-0 -translate-y-2.5 transition-all duration-300 ease-out">
|
|
<div class="flex justify-between items-center mb-4">
|
|
<h3 class="text-lg font-semibold flex items-center gap-2" style="color: var(--text-primary)">
|
|
@Icon("refresh", "h-5 w-5")
|
|
Scanning Libraries
|
|
</h3>
|
|
<button @click="hideScanProgress()" class="icon-btn" aria-label="Close">
|
|
@Icon("close", "h-5 w-5")
|
|
</button>
|
|
</div>
|
|
<div class="mb-4">
|
|
<div class="flex justify-between text-sm mb-2">
|
|
<span style="color: var(--text-secondary)">Overall Progress</span>
|
|
<span id="scan-progress-text" style="color: var(--text-primary)">0%</span>
|
|
</div>
|
|
<div class="w-full rounded-full h-3" style="background-color: var(--surface-hover);">
|
|
<div
|
|
id="scan-progress-bar"
|
|
class="h-3 rounded-full transition-all duration-500"
|
|
style="width: 0%; background-color: var(--accent);"
|
|
></div>
|
|
</div>
|
|
<div id="scan-status" class="text-sm mt-2" style="color: var(--text-secondary)">
|
|
Starting scan...
|
|
</div>
|
|
</div>
|
|
<div id="library-progress-list" class="space-y-3"></div>
|
|
<div id="scan-results" class="hidden mt-6 p-4 rounded-xl border" style="background-color: var(--bg-primary); border-color: var(--border);">
|
|
<h4 class="font-semibold mb-2 flex items-center gap-2" style="color: var(--status-success);">
|
|
@Icon("check-circle", "h-5 w-5")
|
|
Scan Complete!
|
|
</h4>
|
|
<div id="scan-results-content" style="color: var(--text-secondary)"></div>
|
|
<div class="mt-4 flex gap-2">
|
|
<button @click="window.location.reload()" class="btn btn-primary">Refresh to View Books</button>
|
|
<button @click="hideScanProgress()" class="btn btn-secondary">Dismiss</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
</body>
|
|
</html>
|
|
}
|