- Update conflicts.templ to accept pre-rendered data - Update queue.templ to accept pre-rendered data - Update /conflicts and /queue routes in main.go for SSR - Update stats rendering to use server-side values - Add server-side conflict list rendering - Add server-side queue list rendering - Update conflicts.js to use location.reload() after operations - Update queue.js to use location.reload() after operations - Remove initial load calls from JavaScript files Preserves all API endpoints and backward compatibility
200 lines
11 KiB
Templ
200 lines
11 KiB
Templ
package templates
|
|
|
|
import "bookmann/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 - Bookmann</title>
|
|
<script src="/static/htmx.min.js"></script>
|
|
<script src="/static/toast.js"></script>
|
|
<link href="/static/style.css" rel="stylesheet">
|
|
<script src="/static/theme.js"></script>
|
|
<style>
|
|
.status-badge {
|
|
display: inline-block;
|
|
padding: 2px 8px;
|
|
border-radius: 4px;
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
}
|
|
.status-pending { background-color: #f59e0b; color: white; }
|
|
.status-processing { background-color: #3b82f6; color: white; }
|
|
.status-completed { background-color: #10b981; color: white; }
|
|
.status-failed { background-color: #ef4444; color: white; }
|
|
|
|
.priority-badge {
|
|
display: inline-block;
|
|
padding: 2px 8px;
|
|
border-radius: 4px;
|
|
font-size: 10px;
|
|
font-weight: 600;
|
|
}
|
|
.priority-1 { background-color: #ef4444; color: white; }
|
|
.priority-2 { background-color: #f97316; color: white; }
|
|
.priority-3 { background-color: #f59e0b; color: white; }
|
|
.priority-5 { background-color: #10b981; color: white; }
|
|
.priority-7 { background-color: #6b7280; color: white; }
|
|
.priority-10 { background-color: #9ca3af; color: white; }
|
|
</style>
|
|
</head>
|
|
<body class="theme-{ user.Theme }">
|
|
@Header(user, "/queue")
|
|
|
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
|
<div class="mb-8">
|
|
<div class="flex justify-between items-center">
|
|
<div>
|
|
<h1 class="text-3xl font-bold" style="color: var(--text-primary)">Sync Queue</h1>
|
|
<p style="color: var(--text-secondary)">Monitor and manage offline sync queue</p>
|
|
</div>
|
|
<div class="flex space-x-3">
|
|
<button onclick="processPendingItems()" class="btn-primary px-4 py-2 rounded-lg">
|
|
Process Queue
|
|
</button>
|
|
<button onclick="clearFailedItems()" class="btn-secondary px-4 py-2 rounded-lg">
|
|
Clear Failed
|
|
</button>
|
|
<button onclick="clearAllItems()" class="btn-danger px-4 py-2 rounded-lg">
|
|
Clear All
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="stats-bar" class="mt-4 grid grid-cols-2 md:grid-cols-4 gap-4">
|
|
<div class="card p-4 rounded-lg border text-center" style="background-color: var(--bg-secondary); border-color: var(--border);">
|
|
<div class="text-3xl font-bold" style="color: #f59e0b;">{ stats.PendingCount }</div>
|
|
<div class="text-sm" style="color: var(--text-secondary);">Pending</div>
|
|
</div>
|
|
<div class="card p-4 rounded-lg border text-center" style="background-color: var(--bg-secondary); border-color: var(--border);">
|
|
<div class="text-3xl font-bold" style="color: #3b82f6;">{ stats.ProcessingCount }</div>
|
|
<div class="text-sm" style="color: var(--text-secondary);">Processing</div>
|
|
</div>
|
|
<div class="card p-4 rounded-lg border text-center" style="background-color: var(--bg-secondary); border-color: var(--border);">
|
|
<div class="text-3xl font-bold" style="color: #10b981;">{ stats.CompletedCount }</div>
|
|
<div class="text-sm" style="color: var(--text-secondary);">Completed</div>
|
|
</div>
|
|
<div class="card p-4 rounded-lg border text-center" style="background-color: var(--bg-secondary); border-color: var(--border);">
|
|
<div class="text-3xl font-bold" style="color: #ef4444;">{ stats.FailedCount }</div>
|
|
<div class="text-sm" style="color: var(--text-secondary);">Failed</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card p-4 rounded-lg border mb-6" style="background-color: var(--bg-secondary); border-color: var(--border);">
|
|
<div class="flex flex-wrap gap-4 items-center">
|
|
<div>
|
|
<label class="block text-sm font-medium mb-2" style="color: var(--text-secondary)">Status Filter</label>
|
|
<select id="status-filter" onchange="filterQueue()"
|
|
class="px-4 py-2 border rounded-lg"
|
|
style="background-color: var(--bg-primary); color: var(--text-primary); border-color: var(--border);">
|
|
<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-sm font-medium mb-2" style="color: var(--text-secondary)">Sync Type</label>
|
|
<select id="type-filter" onchange="filterQueue()"
|
|
class="px-4 py-2 border rounded-lg"
|
|
style="background-color: var(--bg-primary); color: var(--text-primary); border-color: var(--border);">
|
|
<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-sm font-medium mb-2" style="color: var(--text-secondary)">Device</label>
|
|
<select id="device-filter" onchange="filterQueue()"
|
|
class="px-4 py-2 border rounded-lg"
|
|
style="background-color: var(--bg-primary); color: var(--text-primary); border-color: var(--border);">
|
|
<option value="all">All Devices</option>
|
|
</select>
|
|
</div>
|
|
<div class="flex-1"></div>
|
|
<button onclick="refreshQueue()" class="btn-secondary px-4 py-2 rounded-lg">
|
|
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 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)">Queue Empty</h3>
|
|
<p>No items in the sync queue</p>
|
|
</div>
|
|
|
|
<div id="queue-list" class="space-y-3">
|
|
if len(queueItems) == 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)">Queue Empty</h3>
|
|
<p>No items in the sync queue</p>
|
|
</div>
|
|
}
|
|
|
|
for _, item := range queueItems {
|
|
<div class="card p-4 rounded-lg border" style="background-color: var(--bg-secondary); border-color: var(--border);">
|
|
<div class="flex justify-between items-start mb-2">
|
|
<div class="flex items-center space-x-3">
|
|
<span class="status-badge status-{ item.Status }">{ item.Status }</span>
|
|
<span class="text-sm" style="color: var(--text-secondary)">{ item.SyncType }</span>
|
|
</div>
|
|
<span class="priority-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.CreatedAt }</span>
|
|
</div>
|
|
if item.ErrorMessage != nil {
|
|
<div class="mt-2 text-sm" style="color: #ef4444;">
|
|
Error: { *item.ErrorMessage }
|
|
</div>
|
|
}
|
|
</div>
|
|
}
|
|
</div>
|
|
|
|
<div id="queue-item-modal" class="hidden fixed inset-0 z-50 flex items-center justify-center overflow-y-auto" style="background-color: rgba(0, 0, 0, 0.7);">
|
|
<div class="card rounded-lg p-6 w-full max-w-2xl mx-4 my-8" style="background-color: var(--bg-secondary); border-color: var(--border);">
|
|
<div class="flex justify-between items-center mb-6">
|
|
<h2 class="text-2xl font-bold" style="color: var(--text-primary)">Queue Item Details</h2>
|
|
<button onclick="hideQueueItemModal()" class="p-2 hover:opacity-80 rounded-lg" style="color: var(--text-primary); background-color: var(--bg-primary);">
|
|
X
|
|
</button>
|
|
</div>
|
|
|
|
<div id="queue-item-details"></div>
|
|
|
|
<div class="flex justify-end space-x-3 mt-6">
|
|
<button onclick="hideQueueItemModal()" class="btn-secondary px-4 py-2 rounded-lg">Close</button>
|
|
<button onclick="retryQueueItem()" class="btn-primary px-4 py-2 rounded-lg">Retry</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="/static/queue.js"></script>
|
|
</body>
|
|
</html>
|
|
}
|