first push

This commit is contained in:
jason
2026-04-22 15:47:27 -05:00
parent 923ef2ec0e
commit 1552a0ea65
86 changed files with 10066 additions and 0 deletions
+84
View File
@@ -0,0 +1,84 @@
<%- include('../partials/head', { title: 'Categories' }) %>
<%- include('../partials/adminNav', { currentPath: '/admin/categories' }) %>
<div class="pl-56 min-h-screen">
<%- include('../partials/adminBanner') %>
<div class="max-w-2xl mx-auto px-8 py-8">
<div class="mb-8">
<h1 class="text-xl font-semibold text-white">Categories</h1>
<p class="text-sm text-gray-500 mt-0.5">Organize your models into groups</p>
</div>
<% if (error) { %>
<div class="mb-6 flex items-start gap-3 bg-red-500/10 border border-red-500/30 rounded-lg px-4 py-3">
<p class="text-sm text-red-400"><%= error %></p>
</div>
<% } %>
<!-- New category form -->
<form method="POST" action="/admin/categories" class="bg-surface-900 border border-gray-800 rounded-2xl p-6 mb-6">
<h2 class="text-sm font-semibold text-white mb-4">New Category</h2>
<div class="flex gap-3">
<input name="name" type="text" required placeholder="Category name"
class="flex-1 bg-surface-800 border border-gray-700 rounded-lg px-3.5 py-2.5 text-sm text-white placeholder-gray-600 focus:outline-none focus:border-accent transition-colors" />
<input name="description" type="text" placeholder="Description (optional)"
class="flex-1 bg-surface-800 border border-gray-700 rounded-lg px-3.5 py-2.5 text-sm text-white placeholder-gray-600 focus:outline-none focus:border-accent transition-colors" />
<button type="submit" class="btn-accent text-white rounded-lg px-5 py-2 text-sm font-medium transition-all shrink-0">
Add
</button>
</div>
</form>
<!-- Category list -->
<% if (categories.length === 0) { %>
<div class="bg-surface-900 border border-gray-800 rounded-2xl px-8 py-12 text-center">
<p class="text-sm text-gray-500">No categories yet. Create one above.</p>
</div>
<% } else { %>
<div class="bg-surface-900 border border-gray-800 rounded-2xl overflow-hidden">
<% categories.forEach((cat, i) => { %>
<div class="<%= i > 0 ? 'border-t border-gray-800' : '' %> px-5 py-4 flex items-center gap-4 hover:bg-surface-800 transition-colors group">
<div class="flex-1 min-w-0">
<p class="text-sm font-medium text-white"><%= cat.name %></p>
<% if (cat.description) { %>
<p class="text-xs text-gray-500 mt-0.5"><%= cat.description %></p>
<% } %>
</div>
<span class="text-xs text-gray-600 shrink-0"><%= cat.model_count %> model<%= cat.model_count !== 1 ? 's' : '' %></span>
<!-- Inline edit form (hidden by default) -->
<form method="POST" action="/admin/categories/<%= cat.id %>/edit" class="hidden edit-form gap-2 items-center">
<input name="name" value="<%= cat.name %>" type="text" required
class="bg-surface-700 border border-gray-600 rounded-lg px-3 py-1.5 text-sm text-white focus:outline-none focus:border-accent w-40 transition-colors" />
<input name="description" value="<%= cat.description || '' %>" type="text" placeholder="Description"
class="bg-surface-700 border border-gray-600 rounded-lg px-3 py-1.5 text-sm text-white placeholder-gray-600 focus:outline-none focus:border-accent w-44 transition-colors" />
<button type="submit" class="text-xs btn-accent text-white rounded-lg px-3 py-1.5">Save</button>
<button type="button" class="text-xs text-gray-500 hover:text-white cancel-edit">Cancel</button>
</form>
<!-- Action buttons -->
<div class="flex items-center gap-1 action-buttons">
<button type="button" class="edit-btn p-1.5 rounded-lg text-gray-500 hover:text-white hover:bg-surface-700 transition-colors" title="Rename">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.75">
<path stroke-linecap="round" stroke-linejoin="round" d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931z" />
</svg>
</button>
<form method="POST" action="/admin/categories/<%= cat.id %>/delete"
onsubmit="return confirm('Delete «<%= cat.name %>»? Models in this category will become uncategorized.')">
<button type="submit" class="p-1.5 rounded-lg text-gray-500 hover:text-red-400 hover:bg-red-500/10 transition-colors" title="Delete">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.75">
<path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" />
</svg>
</button>
</form>
</div>
</div>
<% }) %>
</div>
<% } %>
</div>
</div>
<script src="/admin.js"></script>
</body>
</html>
+156
View File
@@ -0,0 +1,156 @@
<%- include('../partials/head', { title: 'Models' }) %>
<%- include('../partials/adminNav', { currentPath: '/admin' }) %>
<div class="pl-56 min-h-screen">
<%- include('../partials/adminBanner') %>
<div class="max-w-7xl mx-auto px-8 py-8">
<!-- Page header -->
<div class="flex items-center justify-between mb-8">
<div>
<h1 class="text-xl font-semibold text-white">Models</h1>
<p class="text-sm text-gray-500 mt-0.5"><%= totalCount %> total &nbsp;·&nbsp; <%= publicCount %> public</p>
</div>
<a href="/admin/upload" class="inline-flex items-center gap-2 btn-accent text-white rounded-lg px-4 py-2 text-sm font-medium transition-all">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>
Upload Model
</a>
</div>
<!-- Filters -->
<form method="GET" action="/admin" class="flex flex-wrap gap-3 mb-6">
<input
name="search" value="<%= filters.search || '' %>"
placeholder="Search models…"
class="bg-surface-900 border border-gray-800 rounded-lg px-3.5 py-2 text-sm text-white placeholder-gray-600 focus:outline-none focus:border-accent w-64 transition-colors"
/>
<select name="category_id" class="bg-surface-900 border border-gray-800 rounded-lg px-3 py-2 text-sm text-gray-300 focus:outline-none focus:border-accent transition-colors">
<option value="">All categories</option>
<% categories.forEach(c => { %>
<option value="<%= c.id %>" <%= filters.category_id == c.id ? 'selected' : '' %>><%= c.name %></option>
<% }) %>
</select>
<select name="visibility" class="bg-surface-900 border border-gray-800 rounded-lg px-3 py-2 text-sm text-gray-300 focus:outline-none focus:border-accent transition-colors">
<option value="">All visibility</option>
<option value="public" <%= filters.visibility === 'public' ? 'selected' : '' %>>Public</option>
<option value="private" <%= filters.visibility === 'private' ? 'selected' : '' %>>Private</option>
</select>
<button type="submit" class="bg-surface-800 hover:bg-surface-700 border border-gray-700 text-sm text-gray-300 rounded-lg px-4 py-2 transition-colors">
Filter
</button>
<% if (filters.search || filters.category_id || filters.visibility) { %>
<a href="/admin" class="bg-surface-800 hover:bg-surface-700 border border-gray-700 text-sm text-gray-400 rounded-lg px-4 py-2 transition-colors">
Clear
</a>
<% } %>
</form>
<!-- Table -->
<% if (models.length === 0) { %>
<div class="bg-surface-900 border border-gray-800 rounded-2xl px-8 py-16 text-center">
<svg class="w-12 h-12 text-gray-700 mx-auto mb-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1">
<path stroke-linecap="round" stroke-linejoin="round" d="M21 7.5l-9-5.25L3 7.5m18 0l-9 5.25m9-5.25v9l-9 5.25M3 7.5l9 5.25M3 7.5v9l9 5.25m0-9v9" />
</svg>
<p class="text-gray-500 text-sm">No models yet. <a href="/admin/upload" class="text-accent underline">Upload your first model.</a></p>
</div>
<% } else { %>
<div class="bg-surface-900 border border-gray-800 rounded-2xl overflow-hidden">
<table class="w-full text-sm">
<thead>
<tr class="border-b border-gray-800">
<th class="text-left px-5 py-3.5 text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
<th class="text-left px-5 py-3.5 text-xs font-medium text-gray-500 uppercase tracking-wider hidden md:table-cell">Category</th>
<th class="text-left px-5 py-3.5 text-xs font-medium text-gray-500 uppercase tracking-wider hidden lg:table-cell">Type</th>
<th class="text-left px-5 py-3.5 text-xs font-medium text-gray-500 uppercase tracking-wider hidden lg:table-cell">PDFs</th>
<th class="text-left px-5 py-3.5 text-xs font-medium text-gray-500 uppercase tracking-wider">Visibility</th>
<th class="text-right px-5 py-3.5 text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-800">
<% models.forEach(model => { %>
<tr class="hover:bg-surface-800 transition-colors group" data-model-id="<%= model.id %>">
<td class="px-5 py-4">
<div class="font-medium text-white"><%= model.name %></div>
<% if (model.description) { %>
<div class="text-xs text-gray-500 mt-0.5 truncate max-w-xs"><%= model.description %></div>
<% } %>
</td>
<td class="px-5 py-4 hidden md:table-cell">
<span class="text-gray-400"><%= model.category_name || '—' %></span>
</td>
<td class="px-5 py-4 hidden lg:table-cell">
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-mono bg-surface-800 border border-gray-700 text-gray-400"><%= model.file_type.toUpperCase() %></span>
</td>
<td class="px-5 py-4 hidden lg:table-cell text-gray-400">
<%= model.pdf_count %>
</td>
<td class="px-5 py-4">
<button
type="button"
class="visibility-toggle inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border transition-colors cursor-pointer
<%= model.is_public ? 'bg-green-500/10 border-green-500/30 text-green-400' : 'bg-gray-700/50 border-gray-700 text-gray-500' %>"
data-model-id="<%= model.id %>"
data-is-public="<%= model.is_public %>"
>
<span class="w-1.5 h-1.5 rounded-full <%= model.is_public ? 'bg-green-400' : 'bg-gray-500' %>"></span>
<%= model.is_public ? 'Public' : 'Private' %>
</button>
</td>
<td class="px-5 py-4">
<div class="flex items-center justify-end gap-2">
<!-- Copy link -->
<button
type="button"
title="Copy share link"
class="copy-link-btn p-1.5 rounded-lg text-gray-500 hover:text-white hover:bg-surface-700 transition-colors"
data-url="<%= baseUrl %>/view/<%= model.slug %>"
>
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.75">
<path stroke-linecap="round" stroke-linejoin="round" d="M13.19 8.688a4.5 4.5 0 011.242 7.244l-4.5 4.5a4.5 4.5 0 01-6.364-6.364l1.757-1.757m13.35-.622l1.757-1.757a4.5 4.5 0 00-6.364-6.364l-4.5 4.5a4.5 4.5 0 001.242 7.244" />
</svg>
</button>
<!-- View -->
<a href="/view/<%= model.slug %>" target="_blank" title="View model"
class="p-1.5 rounded-lg text-gray-500 hover:text-white hover:bg-surface-700 transition-colors">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.75">
<path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.641 0-8.574-3.007-9.964-7.178z" />
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
</a>
<!-- Edit -->
<a href="/admin/models/<%= model.id %>/edit" title="Edit model"
class="p-1.5 rounded-lg text-gray-500 hover:text-white hover:bg-surface-700 transition-colors">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.75">
<path stroke-linecap="round" stroke-linejoin="round" d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10" />
</svg>
</a>
<!-- Delete -->
<form method="POST" action="/admin/models/<%= model.id %>/delete" class="inline" onsubmit="return confirm('Delete «<%= model.name %>»? This cannot be undone.')">
<button type="submit" title="Delete model"
class="p-1.5 rounded-lg text-gray-500 hover:text-red-400 hover:bg-red-500/10 transition-colors">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.75">
<path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" />
</svg>
</button>
</form>
</div>
</td>
</tr>
<% }) %>
</tbody>
</table>
</div>
<% } %>
</div>
</div>
<!-- Toast notification -->
<div id="toast" class="fixed bottom-6 right-6 bg-surface-800 border border-gray-700 text-white text-sm px-4 py-3 rounded-xl shadow-2xl opacity-0 translate-y-2 transition-all duration-300 pointer-events-none z-50">
<span id="toast-msg"></span>
</div>
<script src="/admin.js"></script>
</body>
</html>
+118
View File
@@ -0,0 +1,118 @@
<%- include('../partials/head', { title: 'Edit Model' }) %>
<%- include('../partials/adminNav', { currentPath: '/admin' }) %>
<div class="pl-56 min-h-screen">
<%- include('../partials/adminBanner') %>
<div class="max-w-2xl mx-auto px-8 py-8">
<div class="flex items-center gap-3 mb-8">
<a href="/admin" class="text-gray-500 hover:text-white transition-colors">
<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.75">
<path stroke-linecap="round" stroke-linejoin="round" d="M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18" />
</svg>
</a>
<h1 class="text-xl font-semibold text-white">Edit Model</h1>
</div>
<% if (error) { %>
<div class="mb-6 flex items-start gap-3 bg-red-500/10 border border-red-500/30 rounded-lg px-4 py-3">
<p class="text-sm text-red-400"><%= error %></p>
</div>
<% } %>
<!-- Model details form -->
<form method="POST" action="/admin/models/<%= model.id %>/edit" class="bg-surface-900 border border-gray-800 rounded-2xl p-6 space-y-5 mb-6">
<div>
<label class="block text-xs font-medium text-gray-400 mb-1.5">Display Name <span class="text-red-400">*</span></label>
<input name="name" type="text" required value="<%= model.name %>"
class="w-full bg-surface-800 border border-gray-700 rounded-lg px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-accent transition-colors"
/>
</div>
<div>
<label class="block text-xs font-medium text-gray-400 mb-1.5">Description</label>
<textarea name="description" rows="3"
class="w-full bg-surface-800 border border-gray-700 rounded-lg px-3.5 py-2.5 text-sm text-white placeholder-gray-600 focus:outline-none focus:border-accent transition-colors resize-none"
><%= model.description || '' %></textarea>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-xs font-medium text-gray-400 mb-1.5">Category</label>
<select name="category_id"
class="w-full bg-surface-800 border border-gray-700 rounded-lg px-3 py-2.5 text-sm text-gray-300 focus:outline-none focus:border-accent transition-colors">
<option value="">Uncategorized</option>
<% categories.forEach(c => { %>
<option value="<%= c.id %>" <%= model.category_id == c.id ? 'selected' : '' %>><%= c.name %></option>
<% }) %>
</select>
</div>
<div class="flex items-end pb-0.5">
<label class="flex items-center gap-2.5 cursor-pointer">
<div class="relative">
<input name="is_public" type="checkbox" <%= model.is_public ? 'checked' : '' %> class="sr-only peer" />
<div class="w-9 h-5 bg-gray-700 rounded-full peer-checked:bg-accent transition-colors"></div>
<div class="absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform peer-checked:translate-x-4"></div>
</div>
<span class="text-sm text-gray-400">Public</span>
</label>
</div>
</div>
<div class="pt-2">
<button type="submit" class="btn-accent text-white rounded-lg px-5 py-2 text-sm font-medium transition-all">Save Changes</button>
</div>
</form>
<!-- Attached PDFs -->
<div class="bg-surface-900 border border-gray-800 rounded-2xl p-6 mb-6">
<h2 class="text-sm font-semibold text-white mb-4">Shop Diagrams / PDFs</h2>
<% if (pdfs.length === 0) { %>
<p class="text-sm text-gray-500 mb-4">No PDFs attached yet.</p>
<% } else { %>
<ul class="space-y-2 mb-4">
<% pdfs.forEach(pdf => { %>
<li class="flex items-center justify-between bg-surface-800 rounded-lg px-4 py-2.5">
<span class="text-sm text-gray-300"><%= pdf.display_name %></span>
<form method="POST" action="/admin/pdfs/<%= pdf.id %>/delete" onsubmit="return confirm('Remove this PDF?')">
<button type="submit" class="text-xs text-gray-500 hover:text-red-400 transition-colors">Remove</button>
</form>
</li>
<% }) %>
</ul>
<% } %>
<form method="POST" action="/admin/models/<%= model.id %>/pdf" enctype="multipart/form-data" class="flex gap-3 items-end">
<div class="flex-1">
<label class="block text-xs font-medium text-gray-400 mb-1.5">Attach PDF</label>
<input type="file" name="pdf_file" accept=".pdf" required
class="w-full text-sm text-gray-400 file:mr-3 file:py-1.5 file:px-3 file:rounded-lg file:border-0 file:text-xs file:font-medium file:bg-surface-700 file:text-gray-300 hover:file:bg-surface-600 transition-colors" />
</div>
<div class="flex-1">
<label class="block text-xs font-medium text-gray-400 mb-1.5">Display Name</label>
<input type="text" name="display_name" placeholder="e.g. Sheet 1 — Overview"
class="w-full bg-surface-800 border border-gray-700 rounded-lg px-3 py-2 text-sm text-white placeholder-gray-600 focus:outline-none focus:border-accent transition-colors" />
</div>
<button type="submit" class="bg-surface-700 hover:bg-surface-600 border border-gray-700 text-sm text-gray-300 rounded-lg px-4 py-2 transition-colors shrink-0">
Attach
</button>
</form>
</div>
<!-- Share link -->
<div class="bg-surface-900 border border-gray-800 rounded-2xl p-6">
<h2 class="text-sm font-semibold text-white mb-3">Share Link</h2>
<div class="flex items-center gap-3">
<input readonly value="<%= typeof baseUrl !== 'undefined' ? baseUrl : '' %>/view/<%= model.slug %>"
class="flex-1 bg-surface-800 border border-gray-700 rounded-lg px-3.5 py-2.5 text-sm text-gray-400 focus:outline-none" />
<button type="button" class="copy-link-btn btn-accent text-white rounded-lg px-4 py-2.5 text-sm font-medium transition-all shrink-0"
data-url="<%= typeof baseUrl !== 'undefined' ? baseUrl : '' %>/view/<%= model.slug %>">
Copy Link
</button>
</div>
</div>
</div>
</div>
<div id="toast" class="fixed bottom-6 right-6 bg-surface-800 border border-gray-700 text-white text-sm px-4 py-3 rounded-xl shadow-2xl opacity-0 translate-y-2 transition-all duration-300 pointer-events-none z-50">
<span id="toast-msg"></span>
</div>
<script src="/admin.js"></script>
</body>
</html>
+66
View File
@@ -0,0 +1,66 @@
<%- include('../partials/head', { title: 'Sign In' }) %>
<div class="min-h-screen flex items-center justify-center px-4">
<div class="w-full max-w-sm">
<!-- Logo / Brand -->
<div class="text-center mb-8">
<% if (brand.brand_logo_path) { %>
<img src="/brand/logo" alt="<%= brand.brand_name %>" class="h-12 w-auto mx-auto mb-4 object-contain" />
<% } else { %>
<div class="inline-flex items-center justify-center w-12 h-12 rounded-xl btn-accent mb-4">
<svg class="w-6 h-6 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M21 7.5l-9-5.25L3 7.5m18 0l-9 5.25m9-5.25v9l-9 5.25M3 7.5l9 5.25M3 7.5v9l9 5.25m0-9v9" />
</svg>
</div>
<% } %>
<h1 class="text-xl font-semibold text-white"><%= brand.brand_name %></h1>
<p class="text-sm text-gray-500 mt-1">Admin</p>
</div>
<!-- Card -->
<div class="bg-surface-900 border border-gray-800 rounded-2xl p-8 shadow-2xl">
<h2 class="text-base font-semibold text-white mb-6">Sign in to continue</h2>
<% if (error) { %>
<div class="mb-5 flex items-start gap-3 bg-red-500/10 border border-red-500/30 rounded-lg px-4 py-3">
<svg class="w-4 h-4 text-red-400 mt-0.5 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z" />
</svg>
<p class="text-sm text-red-400"><%= error %></p>
</div>
<% } %>
<form method="POST" action="/admin/login" class="space-y-4">
<input type="hidden" name="next" value="<%= next %>" />
<div>
<label class="block text-xs font-medium text-gray-400 mb-1.5" for="username">Username</label>
<input
id="username" name="username" type="text"
autocomplete="username" required
class="w-full bg-surface-800 border border-gray-700 rounded-lg px-3.5 py-2.5 text-sm text-white placeholder-gray-600 focus:outline-none focus:border-accent focus:ring-1 ring-accent transition-colors"
placeholder="admin"
/>
</div>
<div>
<label class="block text-xs font-medium text-gray-400 mb-1.5" for="password">Password</label>
<input
id="password" name="password" type="password"
autocomplete="current-password" required
class="w-full bg-surface-800 border border-gray-700 rounded-lg px-3.5 py-2.5 text-sm text-white placeholder-gray-600 focus:outline-none focus:border-accent focus:ring-1 ring-accent transition-colors"
placeholder="••••••••"
/>
</div>
<button type="submit" class="w-full btn-accent text-white rounded-lg px-4 py-2.5 text-sm font-semibold transition-all mt-2">
Sign in
</button>
</form>
</div>
</div>
</div>
</body>
</html>
+123
View File
@@ -0,0 +1,123 @@
<%- include('../partials/head', { title: 'Settings' }) %>
<%- include('../partials/adminNav', { currentPath: '/admin/settings' }) %>
<div class="pl-56 min-h-screen">
<%- include('../partials/adminBanner') %>
<div class="max-w-2xl mx-auto px-8 py-8">
<div class="mb-8">
<h1 class="text-xl font-semibold text-white">Settings</h1>
<p class="text-sm text-gray-500 mt-0.5">Branding, appearance, and app configuration</p>
</div>
<% if (saved) { %>
<div class="mb-6 flex items-start gap-3 bg-green-500/10 border border-green-500/30 rounded-lg px-4 py-3">
<svg class="w-4 h-4 text-green-400 mt-0.5 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<p class="text-sm text-green-400">Settings saved.</p>
</div>
<% } %>
<!-- Branding -->
<form method="POST" action="/admin/settings" class="bg-surface-900 border border-gray-800 rounded-2xl p-6 mb-6 space-y-5">
<h2 class="text-sm font-semibold text-white">Branding</h2>
<div>
<label class="block text-xs font-medium text-gray-400 mb-1.5">App Name</label>
<input name="brand_name" type="text" value="<%= settings.brand_name %>"
class="w-full bg-surface-800 border border-gray-700 rounded-lg px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-accent transition-colors"
placeholder="StepView" />
<p class="text-xs text-gray-600 mt-1.5">Shown in the browser tab, viewer overlay, and admin sidebar.</p>
</div>
<div>
<label class="block text-xs font-medium text-gray-400 mb-1.5">Tagline</label>
<input name="brand_tagline" type="text" value="<%= settings.brand_tagline %>"
class="w-full bg-surface-800 border border-gray-700 rounded-lg px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-accent transition-colors"
placeholder="3D Model Viewer" />
</div>
<div>
<label class="block text-xs font-medium text-gray-400 mb-1.5">Accent Color</label>
<div class="flex items-center gap-3">
<input type="color" name="brand_accent" value="<%= settings.brand_accent %>"
class="h-10 w-16 rounded-lg border border-gray-700 bg-surface-800 cursor-pointer p-1" />
<input type="text" id="accent-hex" value="<%= settings.brand_accent %>"
class="bg-surface-800 border border-gray-700 rounded-lg px-3.5 py-2.5 text-sm text-white font-mono w-32 focus:outline-none focus:border-accent transition-colors"
placeholder="#3b82f6" />
</div>
<p class="text-xs text-gray-600 mt-1.5">Used for buttons, highlights, and active nav items.</p>
</div>
<div class="pt-2">
<button type="submit" class="btn-accent text-white rounded-lg px-5 py-2 text-sm font-medium transition-all">
Save Branding
</button>
</div>
</form>
<!-- Logo -->
<div class="bg-surface-900 border border-gray-800 rounded-2xl p-6 mb-6">
<h2 class="text-sm font-semibold text-white mb-4">Logo</h2>
<% if (settings.brand_logo_path) { %>
<div class="flex items-center gap-4 mb-5 p-4 bg-surface-800 rounded-xl border border-gray-700">
<img src="/brand/logo" alt="Current logo" class="h-10 w-auto object-contain" />
<div class="flex-1">
<p class="text-sm text-gray-300">Logo uploaded</p>
<p class="text-xs text-gray-500 mt-0.5">PNG, SVG, or JPEG recommended</p>
</div>
<form method="POST" action="/admin/settings/logo/delete">
<button type="submit" class="text-xs text-gray-500 hover:text-red-400 transition-colors">Remove</button>
</form>
</div>
<% } else { %>
<p class="text-sm text-gray-500 mb-4">No logo uploaded. A default icon is shown.</p>
<% } %>
<form method="POST" action="/admin/settings/logo" enctype="multipart/form-data" class="flex items-end gap-3">
<div class="flex-1">
<label class="block text-xs font-medium text-gray-400 mb-1.5">Upload Logo</label>
<input type="file" name="logo" accept=".png,.jpg,.jpeg,.svg,.webp" required
class="w-full text-sm text-gray-400 file:mr-3 file:py-1.5 file:px-3 file:rounded-lg file:border-0 file:text-xs file:font-medium file:bg-surface-700 file:text-gray-300 hover:file:bg-surface-600 transition-colors" />
<p class="text-xs text-gray-600 mt-1">Max 2 MB. PNG or SVG recommended for best quality.</p>
</div>
<button type="submit" class="bg-surface-700 hover:bg-surface-600 border border-gray-700 text-sm text-gray-300 rounded-lg px-4 py-2 transition-colors shrink-0">
Upload
</button>
</form>
</div>
<!-- Favicon -->
<div class="bg-surface-900 border border-gray-800 rounded-2xl p-6">
<h2 class="text-sm font-semibold text-white mb-4">Favicon</h2>
<form method="POST" action="/admin/settings/favicon" enctype="multipart/form-data" class="flex items-end gap-3">
<div class="flex-1">
<label class="block text-xs font-medium text-gray-400 mb-1.5">Upload Favicon</label>
<input type="file" name="favicon" accept=".ico,.png,.svg" required
class="w-full text-sm text-gray-400 file:mr-3 file:py-1.5 file:px-3 file:rounded-lg file:border-0 file:text-xs file:font-medium file:bg-surface-700 file:text-gray-300 hover:file:bg-surface-600 transition-colors" />
<p class="text-xs text-gray-600 mt-1">ICO or PNG, max 512 KB. Ideal size: 32×32 px.</p>
</div>
<button type="submit" class="bg-surface-700 hover:bg-surface-600 border border-gray-700 text-sm text-gray-300 rounded-lg px-4 py-2 transition-colors shrink-0">
Upload
</button>
</form>
</div>
</div>
</div>
<script>
// Keep color picker and hex input in sync
const colorInput = document.querySelector('input[type="color"]')
const hexInput = document.getElementById('accent-hex')
if (colorInput && hexInput) {
colorInput.addEventListener('input', () => { hexInput.value = colorInput.value })
hexInput.addEventListener('input', () => {
if (/^#[0-9a-fA-F]{6}$/.test(hexInput.value)) colorInput.value = hexInput.value
})
}
</script>
<script src="/admin.js"></script>
</body>
</html>
+93
View File
@@ -0,0 +1,93 @@
<%- include('../partials/head', { title: 'Upload Model' }) %>
<%- include('../partials/adminNav', { currentPath: '/admin/upload' }) %>
<div class="pl-56 min-h-screen">
<%- include('../partials/adminBanner') %>
<div class="max-w-2xl mx-auto px-8 py-8">
<div class="mb-8">
<h1 class="text-xl font-semibold text-white">Upload Model</h1>
<p class="text-sm text-gray-500 mt-0.5">Supported formats: STEP, STP, STL</p>
</div>
<% if (error) { %>
<div class="mb-6 flex items-start gap-3 bg-red-500/10 border border-red-500/30 rounded-lg px-4 py-3">
<svg class="w-4 h-4 text-red-400 mt-0.5 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z" />
</svg>
<p class="text-sm text-red-400"><%= error %></p>
</div>
<% } %>
<form method="POST" action="/admin/models" enctype="multipart/form-data" class="space-y-6">
<!-- Drop zone -->
<div id="drop-zone" class="border-2 border-dashed border-gray-700 hover:border-accent rounded-2xl p-12 text-center transition-colors cursor-pointer">
<svg class="w-10 h-10 text-gray-600 mx-auto mb-3" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1">
<path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5" />
</svg>
<p class="text-sm text-gray-400">Drop a <span class="text-white font-medium">.STEP, .STP, or .STL</span> file here</p>
<p class="text-xs text-gray-600 mt-1">or</p>
<label class="mt-3 inline-block cursor-pointer">
<span class="text-sm text-accent underline">Browse files</span>
<input id="model_file" name="model_file" type="file" accept=".step,.stp,.stl" required class="hidden" />
</label>
<p id="file-name" class="text-xs text-gray-400 mt-3 hidden"></p>
</div>
<!-- Metadata -->
<div class="bg-surface-900 border border-gray-800 rounded-2xl p-6 space-y-5">
<div>
<label class="block text-xs font-medium text-gray-400 mb-1.5" for="name">Display Name <span class="text-red-400">*</span></label>
<input id="name" name="name" type="text" required
class="w-full bg-surface-800 border border-gray-700 rounded-lg px-3.5 py-2.5 text-sm text-white placeholder-gray-600 focus:outline-none focus:border-accent transition-colors"
placeholder="e.g. Main Assembly v3"
/>
</div>
<div>
<label class="block text-xs font-medium text-gray-400 mb-1.5" for="description">Description</label>
<textarea id="description" name="description" rows="3"
class="w-full bg-surface-800 border border-gray-700 rounded-lg px-3.5 py-2.5 text-sm text-white placeholder-gray-600 focus:outline-none focus:border-accent transition-colors resize-none"
placeholder="Optional notes about this model…"
></textarea>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-xs font-medium text-gray-400 mb-1.5" for="category_id">Category</label>
<select id="category_id" name="category_id"
class="w-full bg-surface-800 border border-gray-700 rounded-lg px-3 py-2.5 text-sm text-gray-300 focus:outline-none focus:border-accent transition-colors">
<option value="">Uncategorized</option>
<% categories.forEach(c => { %>
<option value="<%= c.id %>"><%= c.name %></option>
<% }) %>
</select>
</div>
<div class="flex items-end pb-0.5">
<label class="flex items-center gap-2.5 cursor-pointer">
<div class="relative">
<input id="is_public" name="is_public" type="checkbox" checked class="sr-only peer" />
<div class="w-9 h-5 bg-gray-700 rounded-full peer-checked:bg-accent transition-colors"></div>
<div class="absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform peer-checked:translate-x-4"></div>
</div>
<span class="text-sm text-gray-400">Make public</span>
</label>
</div>
</div>
</div>
<div class="flex gap-3">
<button type="submit" class="btn-accent text-white rounded-lg px-6 py-2.5 text-sm font-medium transition-all">
Upload Model
</button>
<a href="/admin" class="bg-surface-800 hover:bg-surface-700 border border-gray-700 text-gray-300 rounded-lg px-6 py-2.5 text-sm font-medium transition-colors">
Cancel
</a>
</div>
</form>
</div>
</div>
<script src="/admin.js"></script>
</body>
</html>