The audit showed only 5 of ~11 time-display surfaces converted to the user's timezone; everything else rendered pgx-decoded UTC. The server owns conversion — clients (web/app/KOReader) receive display-ready strings or machine-readable instants and never convert. - Progress page: LastUpdated formatted in the requesting user's tz (was raw UTC). - Analytics: date-range defaults, day buckets, most-active-day, device last-sync, and popular-book last-read all computed in the user's tz — evening sessions no longer land on the next UTC day. Also fixed the end-date boundary: the query bounds with <= and the end bound was midnight, so the end date's own sessions (including 'today') never appeared. - Queue page: new created_at_display field (admin tz) rendered by the template; created_at stays RFC3339 for API consumers. - Admin hash-conflicts SSR bridge: detected date rendered in the admin's tz. - OPDS: .UTC() before the Z-suffixed feed timestamps (honesty fix — correct today only because the session zone happens to be UTC). - KOReader annotation datetimes deliberately untouched (device owns its display).
176 lines
7.6 KiB
Templ
176 lines
7.6 KiB
Templ
package templates
|
|
|
|
import "bookhoard/internal/handlers"
|
|
|
|
templ Queue(user User, queueItems []handlers.QueueItemResponse, stats handlers.QueueStatsResponse) {
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
<title>Sync Queue - Bookhoard</title>
|
|
<script src="/static/htmx.min.js"></script>
|
|
<link href="/static/style.css" rel="stylesheet"/>
|
|
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg"/>
|
|
</head>
|
|
<body x-data="queue" class="theme-{ user.Theme }">
|
|
@Header(user, "/queue")
|
|
<div class="mx-auto container px-4 sm:px-6 lg:px-8 py-8">
|
|
<div class="mb-8">
|
|
<div class="flex justify-between items-center gap-4 flex-wrap">
|
|
<div>
|
|
<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("clock", "h-5 w-5")
|
|
</span>
|
|
<h1 class="text-2xl font-bold tracking-tight" style="color: var(--text-primary)">Sync Queue</h1>
|
|
</div>
|
|
<p class="text-sm" style="color: var(--text-secondary)">Monitor and manage offline sync queue</p>
|
|
</div>
|
|
<div class="flex space-x-3">
|
|
<button @click="processPendingItems()" class="btn btn-primary">
|
|
@Icon("play", "h-4 w-4")
|
|
Process Queue
|
|
</button>
|
|
<button @click="clearFailedItems()" class="btn btn-secondary">Clear Failed</button>
|
|
<button @click="clearAllItems()" class="btn btn-danger">Clear All</button>
|
|
</div>
|
|
</div>
|
|
<div id="stats-bar" class="mt-4 grid grid-cols-2 md:grid-cols-4 gap-4">
|
|
<div class="stat-card text-center">
|
|
<div class="text-3xl font-bold" style="color: var(--status-warning);">{ stats.PendingCount }</div>
|
|
<div class="text-xs uppercase tracking-wide" style="color: var(--text-secondary);">Pending</div>
|
|
</div>
|
|
<div class="stat-card text-center">
|
|
<div class="text-3xl font-bold" style="color: var(--status-info);">{ stats.ProcessingCount }</div>
|
|
<div class="text-xs uppercase tracking-wide" style="color: var(--text-secondary);">Processing</div>
|
|
</div>
|
|
<div class="stat-card text-center">
|
|
<div class="text-3xl font-bold" style="color: var(--status-success);">{ stats.CompletedCount }</div>
|
|
<div class="text-xs uppercase tracking-wide" style="color: var(--text-secondary);">Completed</div>
|
|
</div>
|
|
<div class="stat-card text-center">
|
|
<div class="text-3xl font-bold" style="color: var(--status-danger);">{ stats.FailedCount }</div>
|
|
<div class="text-xs uppercase tracking-wide" style="color: var(--text-secondary);">Failed</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card p-4 mb-6">
|
|
<div class="flex flex-wrap gap-4 items-end">
|
|
<div>
|
|
<label class="block text-xs font-semibold uppercase tracking-wide mb-2" style="color: var(--text-secondary)">Status Filter</label>
|
|
<select
|
|
id="status-filter"
|
|
onchange="filterQueue()"
|
|
class="input"
|
|
>
|
|
<option value="all">All Items</option>
|
|
<option value="pending" selected>Pending</option>
|
|
<option value="processing">Processing</option>
|
|
<option value="completed">Completed</option>
|
|
<option value="failed">Failed</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-semibold uppercase tracking-wide mb-2" style="color: var(--text-secondary)">Sync Type</label>
|
|
<select
|
|
id="type-filter"
|
|
onchange="filterQueue()"
|
|
class="input"
|
|
>
|
|
<option value="all">All Types</option>
|
|
<option value="progress">Progress</option>
|
|
<option value="note">Notes</option>
|
|
<option value="highlight">Highlights</option>
|
|
<option value="bookmark">Bookmarks</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-semibold uppercase tracking-wide mb-2" style="color: var(--text-secondary)">Device</label>
|
|
<select
|
|
id="device-filter"
|
|
onchange="filterQueue()"
|
|
class="input"
|
|
>
|
|
<option value="all">All Devices</option>
|
|
</select>
|
|
</div>
|
|
<div class="flex-1"></div>
|
|
<button @click="refreshQueue()" class="btn btn-secondary">
|
|
@Icon("refresh", "h-4 w-4")
|
|
Refresh
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div id="loading" class="hidden text-center py-16" style="color: var(--text-secondary)">
|
|
<div class="loading-spinner mx-auto mb-4"></div>
|
|
<p>Loading queue...</p>
|
|
</div>
|
|
<div id="empty-state" class="hidden card text-center py-16">
|
|
<span class="grid place-items-center h-14 w-14 mx-auto mb-4 rounded-2xl" style="background-color: var(--accent-muted); color: var(--accent);">
|
|
@Icon("check-circle", "h-7 w-7")
|
|
</span>
|
|
<h3 class="text-xl font-semibold mb-2" style="color: var(--text-primary)">Queue Empty</h3>
|
|
<p style="color: var(--text-secondary)">No items in the sync queue</p>
|
|
</div>
|
|
<div id="queue-list" class="space-y-3">
|
|
if len(queueItems) == 0 {
|
|
<div class="card text-center py-16">
|
|
<span class="grid place-items-center h-14 w-14 mx-auto mb-4 rounded-2xl" style="background-color: var(--accent-muted); color: var(--accent);">
|
|
@Icon("check-circle", "h-7 w-7")
|
|
</span>
|
|
<h3 class="text-xl font-semibold mb-2" style="color: var(--text-primary)">Queue Empty</h3>
|
|
<p style="color: var(--text-secondary)">No items in the sync queue</p>
|
|
</div>
|
|
}
|
|
for _, item := range queueItems {
|
|
<div class="card p-4 transition-colors" style="cursor: default;">
|
|
<div class="flex justify-between items-start mb-2 gap-2">
|
|
<div class="flex items-center gap-2 flex-wrap">
|
|
<span class="badge status-{ item.Status }">{ item.Status }</span>
|
|
<span class="text-sm" style="color: var(--text-secondary)">{ item.SyncType }</span>
|
|
</div>
|
|
<span class="badge priority-{ item.Priority }">P{ item.Priority }</span>
|
|
</div>
|
|
<div class="text-sm mb-2" style="color: var(--text-secondary)">
|
|
Device ID: { item.DeviceID }
|
|
if item.MediaTitle != nil {
|
|
| Book: { *item.MediaTitle }
|
|
}
|
|
</div>
|
|
<div class="flex justify-between items-center text-sm" style="color: var(--text-secondary)">
|
|
<span>Attempts: { item.Attempts }/{ item.MaxAttempts }</span>
|
|
<span>{ item.CreatedAtDisplay }</span>
|
|
</div>
|
|
if item.ErrorMessage != nil {
|
|
<div class="mt-2 text-sm flex items-start gap-2" style="color: var(--status-danger);">
|
|
@Icon("alert", "h-4 w-4 shrink-0 mt-0.5")
|
|
<span>Error: { *item.ErrorMessage }</span>
|
|
</div>
|
|
}
|
|
</div>
|
|
}
|
|
</div>
|
|
<div id="queue-item-modal" class="hidden fixed inset-0 z-50 flex items-center justify-center overflow-y-auto p-4" style="background-color: var(--surface-overlay);">
|
|
<div class="card p-6 w-full max-w-2xl my-8" style="box-shadow: var(--shadow-pop);">
|
|
<div class="flex justify-between items-center mb-6">
|
|
<h2 class="text-xl font-bold" style="color: var(--text-primary)">Queue Item Details</h2>
|
|
<button @click="hideQueueItemModal()" class="icon-btn" aria-label="Close">
|
|
@Icon("close", "h-5 w-5")
|
|
</button>
|
|
</div>
|
|
<div id="queue-item-details"></div>
|
|
<div class="flex justify-end space-x-3 mt-6">
|
|
<button @click="hideQueueItemModal()" class="btn btn-secondary">Close</button>
|
|
<button @click="retryQueueItem()" class="btn btn-primary">
|
|
@Icon("refresh", "h-4 w-4")
|
|
Retry
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
}
|