feat(progress): implement progress visualization page with sync source tracking (Phase 9-3)

Add progress list page showing reading progress across all devices:
- GetAllProgress API endpoint: Returns all user progress with media details
- GetAllProgressData helper: Fetches progress data for SSR rendering
- ProgressWithMedia struct: Combines progress with book metadata
- Progress page template: Displays progress bars, device icons, sync sources

Features:
- Visual progress bars with percentage
- Device-specific icons (Kobo, KOReader, Web, Mobile)
- Last sync timestamp and device attribution
- EPUB CFI location display
- Cover image support with fallback
- Responsive grid layout

This gives users a unified view of their reading progress across all synced devices.
This commit is contained in:
2026-02-01 00:25:15 -05:00
parent 4a19699e8f
commit 7828371c9c
3 changed files with 480 additions and 0 deletions
+111
View File
@@ -0,0 +1,111 @@
package templates
templ Progress(user User, progressData []ProgressItemData) {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reading Progress - Bookmann</title>
<script src="/static/htmx.min.js"></script>
<script src="/static/toast.js"></script>
<script src="/static/header.js"></script>
<link href="/static/style.css" rel="stylesheet">
</head>
<body class="theme-{ user.Theme }">
@Header(user, "/progress")
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<div class="mb-8">
<h1 class="text-3xl font-bold" style="color: var(--text-primary)">Reading Progress</h1>
<p style="color: var(--text-secondary)">Track your reading progress across all devices</p>
</div>
<div id="progress-container" class="space-y-6">
if len(progressData) == 0 {
<div class="text-center py-16" style="color: var(--text-secondary)">
<div class="text-6xl mb-4">📖</div>
<h3 class="text-xl font-semibold mb-2" style="color: var(--text-primary)">No Progress Yet</h3>
<p>Start reading a book to track your progress</p>
</div>
}
for _, item := range progressData {
<div class="card p-6 rounded-lg border" style="background-color: var(--bg-secondary); border-color: var(--border);">
<div class="flex gap-6">
<div class="flex-shrink-0">
<img src="{ item.CoverImagePath }" alt="Cover"
class="w-24 h-32 object-cover rounded"
onerror="this.src='/static/placeholder-book.svg'">
</div>
<div class="flex-1">
<div class="flex justify-between items-start mb-2">
<div>
<h3 class="font-semibold text-lg" style="color: var(--text-primary)">{ item.Title }</h3>
if item.Author != "" {
<p class="text-sm" style="color: var(--text-secondary)">by { item.Author }</p>
}
</div>
<div class="text-right">
<span class="text-2xl font-bold" style="color: var(--accent)">{ item.ProgressPercentage }%</span>
</div>
</div>
<div class="mb-4">
<div class="w-full bg-gray-700 rounded-full h-3">
<div class="h-3 rounded-full transition-all" style="width: { item.ProgressPercentage }%; background-color: var(--accent);"></div>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 text-sm">
<div>
<p style="color: var(--text-secondary)">Current Position</p>
<p style="color: var(--text-primary)">
{ item.CurrentPage } / { item.TotalPages }
</p>
</div>
<div>
<p style="color: var(--text-secondary)">Last Updated</p>
<p style="color: var(--text-primary)">{ item.LastUpdated }</p>
</div>
<div>
<p style="color: var(--text-secondary)">Synced From</p>
<div class="flex items-center gap-2">
<span class="text-xl">{ item.DeviceIcon }</span>
<span style="color: var(--text-primary)">{ item.DeviceName }</span>
</div>
</div>
</div>
if item.DeviceIcon != "" {
<div class="mt-3 pt-3 border-t" style="border-color: var(--border);">
<div class="flex items-center gap-2 text-xs" style="color: var(--text-secondary);">
<span>🔄</span>
<span>Last sync from <strong>{ item.DeviceName }</strong></span>
<span>({ item.DeviceType })</span>
</div>
</div>
}
if item.EpubCFI != "" {
<div class="mt-2 text-xs" style="color: var(--text-secondary);">
<span>📍</span>
<span>CFI: { item.EpubCFI }</span>
</div>
}
</div>
</div>
</div>
}
</div>
</div>
<script>
function logout() {
localStorage.removeItem('token');
window.location.href = '/login';
}
</script>
</body>
</html>
}