- Implemented PageService with full CRUD operations - Added GetPages, CreatePage, UpdatePage, DeletePage, ReorderPages methods - Cascade deletion of widgets when page is deleted - Prevention of last page deletion - Created page HTTP endpoints (GET, POST, PUT, DELETE, reorder) - HTMX-friendly HTML fragment responses - Comprehensive unit tests for service and handlers - Updated dashboard to use PageService and create default pages
88 lines
4.5 KiB
HTML
88 lines
4.5 KiB
HTML
{{template "layouts/base.html" .}}
|
|
|
|
{{define "title"}}Dashboard - Custom Start Page{{end}}
|
|
|
|
{{define "content"}}
|
|
<div class="min-h-screen flex flex-col">
|
|
<!-- Top Toolbar -->
|
|
<header class="bg-white shadow-sm border-b border-gray-200">
|
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
<div class="flex items-center justify-between h-16">
|
|
<!-- Logo -->
|
|
<div class="flex-shrink-0">
|
|
<h1 class="text-xl font-bold text-gray-800">Start Page</h1>
|
|
</div>
|
|
|
|
<!-- Search Bar -->
|
|
<div class="flex-1 max-w-2xl mx-8">
|
|
<form action="/search" method="get" class="relative">
|
|
<input type="text"
|
|
name="q"
|
|
placeholder="Search the web..."
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent">
|
|
<button type="submit" class="absolute right-3 top-2.5 text-gray-400 hover:text-gray-600">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
|
|
</svg>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- User Menu -->
|
|
<div class="flex items-center space-x-4">
|
|
<button class="text-gray-600 hover:text-gray-800">
|
|
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/>
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
|
|
</svg>
|
|
</button>
|
|
<form action="/logout" method="post">
|
|
<button type="submit" class="text-gray-600 hover:text-gray-800">
|
|
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"/>
|
|
</svg>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Page Tabs -->
|
|
<div id="page-tabs" class="flex space-x-1 -mb-px">
|
|
{{template "page-tabs.html" .}}
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- Widget Grid -->
|
|
<main class="flex-1 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 w-full">
|
|
<div id="widget-grid" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
|
<!-- Widgets will be loaded here via HTMX -->
|
|
<div class="col-span-full text-center text-gray-500 py-12">
|
|
<p>No widgets yet. Click the + button to add your first widget.</p>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
{{end}}
|
|
|
|
{{define "scripts"}}
|
|
<script>
|
|
// Initialize Sortable.js for drag-and-drop when widgets are loaded
|
|
document.body.addEventListener('htmx:afterSwap', function(evt) {
|
|
if (evt.detail.target.id === 'widget-grid') {
|
|
new Sortable(document.getElementById('widget-grid'), {
|
|
animation: 150,
|
|
handle: '.widget-handle',
|
|
onEnd: function(evt) {
|
|
// Send reorder request
|
|
const widgetIds = Array.from(evt.to.children).map(el => el.dataset.widgetId);
|
|
htmx.ajax('POST', '/widgets/reorder', {
|
|
values: { order: widgetIds.join(',') }
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
{{end}}
|