Initial working version

This commit is contained in:
lucio committed 2026-05-21 02:11:11 -07:00
commit 3d7c232b94
32 files changed
+4743

No files matched your search

+104
View File
@@ -0,0 +1,104 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{block "title" .}}Solis | Home Assets{{end}}</title>
<!-- Dynamic CSRF Metadata for HTMX requests -->
<meta name="csrf-token" content="{{.CSRFToken}}">
<!-- Styles & Fonts -->
<link rel="stylesheet" href="/static/css/styles.css">
<!-- Self-contained scripts serving fully offline -->
<script src="/static/js/htmx.min.js"></script>
<script src="/static/js/main.js"></script>
</head>
<body>
<div class="app-container">
<!-- Sidebar Navigation -->
<aside class="sidebar">
<div class="brand">
<div class="brand-logo">S</div>
<span class="brand-name">Solis</span>
</div>
<nav class="sidebar-nav">
<ul class="nav-list">
<li class="nav-item {{if eq .ActiveNav "items"}}active{{end}}">
<a href="/admin" class="nav-link">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M20.25 7.5l-.625 10.632a2.25 2.25 0 01-2.247 2.118H6.622a2.25 2.25 0 01-2.247-2.118L3.75 7.5M10 11.25h4M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125z" />
</svg>
Assets
</a>
</li>
<li class="nav-item {{if eq .ActiveNav "locations"}}active{{end}}">
<a href="/admin/locations" class="nav-link">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M15 10.5a3 3 0 11-6 0 3 3 0 016 0z" />
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 10.5c0 7.142-7.5 11.25-7.5 11.25s-7.5-4.108-7.5-11.25g3 3 0 1115 0z" />
</svg>
Locations
</a>
</li>
<li class="nav-item {{if eq .ActiveNav "tags"}}active{{end}}">
<a href="/admin/tags" class="nav-link">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M9.568 3H5.25A2.25 2.25 0 003 5.25v4.318c0 .597.237 1.17.659 1.591l9.581 9.581a1.125 1.125 0 001.591 0l4.318-4.318a1.125 1.125 0 000-1.591l-9.581-9.581A2.25 2.25 0 009.568 3z" />
<path stroke-linecap="round" stroke-linejoin="round" d="M6 6h.008v.008H6V6z" />
</svg>
Tags
</a>
</li>
<li class="nav-item {{if eq .ActiveNav "shortener"}}active{{end}}">
<a href="/admin/shortener" class="nav-link">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
<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>
Shortlinks
</a>
</li>
<li class="nav-item {{if eq .ActiveNav "print"}}active{{end}}">
<a href="/admin/print" class="nav-link">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M6.72 13.829c-.24.03-.48.062-.72.096m.72-.096a42.415 42.415 0 0110.56 0m-10.56 0L6.34 18m10.94-4.171c.24.03.48.062.72.096m-.72-.096L17.66 18m0 0a2.25 2.25 0 01-2.247 2.118H8.587A2.25 2.25 0 016.34 18m11.32 0h.008v.008h-.008V18zm-12 0h.008v.008H5.66V18zm0-11.25h12.75c.621 0 1.125.504 1.125 1.125v1.5c0 .621-.504 1.125-1.125 1.125H5.66c-.621 0-1.125-.504-1.125-1.125v-1.5c0-.621.504-1.125 1.125-1.125z" />
</svg>
Print Labels
</a>
</li>
</ul>
</nav>
<!-- Sidebar Footer -->
<div class="sidebar-footer">
<form action="/admin/logout" method="POST">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<button type="submit" class="btn btn-secondary" style="width: 100%;">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" style="width:16px;height:16px;margin-right:4px;">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 9V5.25A2.25 2.25 0 0013.5 3h-6a2.25 2.25 0 00-2.25 2.25v13.5A2.25 2.25 0 007.5 21h6a2.25 2.25 0 002.25-2.25V15M12 9l-3 3m0 0l3 3m-3-3h12.75" />
</svg>
Sign Out
</button>
</form>
</div>
</aside>
<!-- Main Content View Wrapper -->
<main class="main-wrapper">
{{template "content" .}}
</main>
</div>
<!-- Dynamic Slide-in Alert Toasts -->
<div id="toast-container">
{{if .Toast}}
<div class="toast {{if eq .ToastType "success"}}toast-success{{else}}toast-error{{end}}">
<div class="toast-message">{{.Toast}}</div>
<button class="toast-close" onclick="dismissToast(this)">&times;</button>
</div>
{{end}}
</div>
</body>
</html>
+469
View File
@@ -0,0 +1,469 @@
{{define "title"}}Solis | Assets{{end}}
{{define "content"}}
{{if .FormMode}}
<!-- ================== ASSET EDIT / CREATE FORM ================== -->
<div class="page-header">
<div class="page-title">
<h1>{{if .EditingItem}}Edit Asset: {{.EditingItem.Name}}{{else}}Add New Asset{{end}}</h1>
<p>Define inventory items, upload documentation, and generate automated QR codes.</p>
</div>
<div>
<a href="/admin" class="btn btn-secondary">Cancel</a>
</div>
</div>
<div class="card">
<form action="{{if .EditingItem}}/admin/items/edit/{{.EditingItem.ID}}{{else}}/admin/items/new{{end}}" method="POST" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<h3 style="font-weight: 700; margin-bottom: 1.5rem; color: var(--color-brand-primary); border-bottom: 1px solid var(--color-border); padding-bottom: 0.5rem;">Basic Information</h3>
<div style="display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem;">
<div class="form-group">
<label for="name" class="form-label">Asset Name</label>
<input type="text" id="name" name="name" class="form-control" placeholder="e.g. Cordless Hammer Drill" value="{{if .EditingItem}}{{.EditingItem.Name}}{{end}}" required>
</div>
<div class="form-group">
<label for="quantity" class="form-label">Quantity</label>
<input type="number" id="quantity" name="quantity" class="form-control" min="1" value="{{if .EditingItem}}{{.EditingItem.Quantity}}{{else}}1{{end}}" required>
</div>
</div>
<div class="form-group">
<label for="description" class="form-label">Description</label>
<textarea id="description" name="description" class="form-control" rows="3" placeholder="e.g. Brushless motor hammer drill, includes two 18V Li-ion batteries">{{if .EditingItem}}{{.EditingItem.Description}}{{end}}</textarea>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5rem;">
<div class="form-group">
<label for="model_number" class="form-label">Model Number</label>
<input type="text" id="model_number" name="model_number" class="form-control" placeholder="e.g. DCD796" value="{{if .EditingItem}}{{.EditingItem.ModelNumber}}{{end}}">
</div>
<div class="form-group">
<label for="serial_number" class="form-label">Serial Number</label>
<input type="text" id="serial_number" name="serial_number" class="form-control" placeholder="e.g. 2018-W42-9988" value="{{if .EditingItem}}{{.EditingItem.SerialNumber}}{{end}}">
</div>
<div class="form-group">
<label for="status" class="form-label">Status</label>
<select id="status" name="status" class="form-control">
<option value="In Use" {{if .EditingItem}}{{if eq .EditingItem.Status "In Use"}}selected{{end}}{{end}}>In Use</option>
<option value="In Storage" {{if .EditingItem}}{{if eq .EditingItem.Status "In Storage"}}selected{{end}}{{end}}>In Storage</option>
<option value="Borrowed" {{if .EditingItem}}{{if eq .EditingItem.Status "Borrowed"}}selected{{end}}{{end}}>Borrowed</option>
<option value="Lost" {{if .EditingItem}}{{if eq .EditingItem.Status "Lost"}}selected{{end}}{{end}}>Lost</option>
<option value="Disposed" {{if .EditingItem}}{{if eq .EditingItem.Status "Disposed"}}selected{{end}}{{end}}>Disposed</option>
</select>
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 2rem;">
<div class="form-group">
<label for="location_id" class="form-label">Location</label>
<select id="location_id" name="location_id" class="form-control" required>
{{range .Locations}}
<option value="{{.ID}}" {{if $.EditingItem}}{{if $.EditingItem.LocationID.Valid}}{{if eq .ID $.EditingItem.LocationID.Int64}}selected{{end}}{{end}}{{else}}{{if eq .ID 1}}selected{{end}}{{end}}>
{{.Name}}
</option>
{{end}}
</select>
</div>
<div class="form-group">
<label class="form-label">Tags / Categories</label>
<div style="display: flex; flex-wrap: wrap; gap: 0.75rem; border: 1px solid var(--color-border); padding: 0.625rem; border-radius: var(--radius-sm); background-color: var(--color-bg-base); max-height: 110px; overflow-y: auto;">
{{range .Tags}}
<label style="display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; font-weight: 500; cursor: pointer;">
<input type="checkbox" name="tag_ids" value="{{.ID}}" data-tag-name="{{.Name}}" {{if $.EditingItem}}{{if hasTag $.EditingItem.Tags .ID}}checked{{end}}{{end}}>
<span class="tag-pill" style="background-color: {{.Color}};">{{.Name}}</span>
</label>
{{end}}
</div>
</div>
</div>
<h3 style="font-weight: 700; margin-bottom: 1.5rem; color: var(--color-brand-primary); border-bottom: 1px solid var(--color-border); padding-bottom: 0.5rem; margin-top: 2rem;">Purchase & Warranty</h3>
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 1.5rem;">
<div class="form-group">
<label for="purchase_price" class="form-label">Purchase Price ($)</label>
<input type="number" id="purchase_price" name="purchase_price" class="form-control" step="0.01" min="0" placeholder="e.g. 149.99" value="{{if .EditingItem}}{{if .EditingItem.PurchasePrice.Valid}}{{.EditingItem.PurchasePrice.Float64}}{{end}}{{end}}">
</div>
<div class="form-group">
<label for="purchase_date" class="form-label">Purchase Date</label>
<input type="date" id="purchase_date" name="purchase_date" class="form-control" value="{{if .EditingItem}}{{if .EditingItem.PurchaseDate.Valid}}{{.EditingItem.PurchaseDate.String}}{{end}}{{end}}">
</div>
<div class="form-group">
<label for="warranty_months" class="form-label">Warranty (Months)</label>
<input type="number" id="warranty_months" name="warranty_months" class="form-control" min="0" placeholder="e.g. 24" value="{{if .EditingItem}}{{if .EditingItem.WarrantyMonths.Valid}}{{.EditingItem.WarrantyMonths.Int64}}{{end}}{{end}}">
</div>
<div class="form-group">
<label for="supplier" class="form-label">Supplier / Store</label>
<input type="text" id="supplier" name="supplier" class="form-control" placeholder="e.g. Home Depot" value="{{if .EditingItem}}{{.EditingItem.Supplier}}{{end}}">
</div>
</div>
<h3 style="font-weight: 700; margin-bottom: 1.5rem; color: var(--color-brand-primary); border-bottom: 1px solid var(--color-border); padding-bottom: 0.5rem; margin-top: 2rem;">Documentation & Visuals</h3>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;">
<div class="form-group">
<label for="image" class="form-label">Item Photo</label>
<input type="file" id="image" name="image" class="form-control" accept="image/*">
{{if .EditingItem}}{{if .EditingItem.ImagePath}}
<span style="font-size: 0.8rem; color: var(--color-brand-primary); margin-top: 0.25rem; display: block;">Active Image: {{.EditingItem.ImagePath}}</span>
{{end}}{{end}}
</div>
<div class="form-group">
<label for="receipt" class="form-label">Receipt / Invoice Document</label>
<input type="file" id="receipt" name="receipt" class="form-control" accept="image/*,application/pdf">
{{if .EditingItem}}{{if .EditingItem.ReceiptPath}}
<span style="font-size: 0.8rem; color: var(--color-brand-primary); margin-top: 0.25rem; display: block;">Active Receipt: {{.EditingItem.ReceiptPath}}</span>
{{end}}{{end}}
</div>
</div>
<h3 style="font-weight: 700; margin-bottom: 0.5rem; color: var(--color-brand-primary); border-bottom: 1px solid var(--color-border); padding-bottom: 0.5rem; margin-top: 2rem;">Custom Fields</h3>
<p style="font-size: 0.8rem; color: var(--color-text-muted); margin-bottom: 1rem;">Enter custom parameters one per line as <code>Key: Value</code> (e.g. <code>Battery: 18v Lithium</code>). These will be parsed into indexed SQLite JSON dynamically.</p>
<div class="form-group" style="margin-bottom: 2.5rem;">
<label for="custom_fields" class="form-label">Custom Fields Editor</label>
<textarea id="custom_fields" name="custom_fields" class="form-control" rows="4" placeholder="Battery: 18v&#10;MotorType: Brushless">{{.CustomFieldsRaw}}</textarea>
</div>
<button type="submit" class="btn btn-primary" style="padding: 0.75rem 2rem; font-size: 1rem;">
{{if .EditingItem}}Save Changes{{else}}Create Asset{{end}}
</button>
</form>
</div>
{{else if .ViewMode}}
<!-- ================== ASSET VIEW DETAILS MODE ================== -->
<div class="page-header">
<div class="page-title">
<span style="color: var(--color-text-light); font-size: 0.85rem; font-weight: 600; text-transform: uppercase;">Asset Details</span>
<h1 style="margin-top: 0.15rem;">{{.Item.Name}}</h1>
</div>
<div style="display: flex; gap: 0.5rem;">
<a href="/admin/items/edit/{{.Item.ID}}" class="btn btn-primary">
Edit Asset
</a>
<a href="/admin" class="btn btn-secondary">
Back to List
</a>
</div>
</div>
<div class="detail-grid">
<!-- Detail Main Section -->
<div class="detail-main">
<!-- Basic info card -->
<div class="card">
<div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.5rem;">
<div>
<div class="status-pill {{if eq .Item.Status "In Use"}}in-use{{else if eq .Item.Status "In Storage"}}in-storage{{else if eq .Item.Status "Borrowed"}}borrowed{{else if eq .Item.Status "Lost"}}lost{{else}}disposed{{end}}">
{{.Item.Status}}
</div>
<span style="margin-left: 0.5rem; font-size: 0.9rem; color: var(--color-text-muted); font-weight: 500;">
Quantity: <strong>{{.Item.Quantity}}</strong>
</span>
</div>
<div class="tag-list">
{{range .Item.Tags}}
<span class="tag-pill" style="background-color: {{.Color}};">{{.Name}}</span>
{{end}}
</div>
</div>
<h3 style="font-weight: 700; font-size: 1.15rem; margin-bottom: 0.75rem;">Description</h3>
<p style="color: var(--color-text-muted); margin-bottom: 1.75rem;">
{{if .Item.Description}}{{.Item.Description}}{{else}}<em>No description provided for this asset.</em>{{end}}
</p>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; border-top: 1px solid var(--color-border); padding-top: 1.5rem;">
<div>
<span style="font-size: 0.85rem; color: var(--color-text-light); text-transform: uppercase; font-weight: 600; display: block;">Model Number</span>
<span style="font-weight: 500; font-size: 1.05rem;">{{if .Item.ModelNumber}}{{.Item.ModelNumber}}{{else}}--{{end}}</span>
</div>
<div>
<span style="font-size: 0.85rem; color: var(--color-text-light); text-transform: uppercase; font-weight: 600; display: block;">Serial Number</span>
<span style="font-weight: 500; font-size: 1.05rem; font-family: monospace;">{{if .Item.SerialNumber}}{{.Item.SerialNumber}}{{else}}--{{end}}</span>
</div>
</div>
</div>
<!-- Image Visuals and Receipts -->
<div class="item-visuals">
<div class="card" style="padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem;">
<h4 style="font-weight: 600; font-size: 0.95rem; color: var(--color-text-muted); border-bottom:1px solid var(--color-border); padding-bottom:0.25rem;">Asset Photo</h4>
<div class="visual-box">
{{if .Item.ImagePath}}
<img src="/uploads/{{.Item.ImagePath}}" alt="Asset Photo">
{{else}}
<div class="visual-placeholder">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" style="width: 48px; height: 48px;">
<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V6.75zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z" />
</svg>
<span>No Photo Attached</span>
</div>
{{end}}
</div>
</div>
<div class="card" style="padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem;">
<h4 style="font-weight: 600; font-size: 0.95rem; color: var(--color-text-muted); border-bottom:1px solid var(--color-border); padding-bottom:0.25rem;">Receipt / Invoice</h4>
<div class="visual-box">
{{if .Item.ReceiptPath}}
<!-- receipts could be PDFs or images. Since we force downloads for PDFs, let's see. If it's pdf we show pdf icon, otherwise image -->
<img src="/uploads/{{.Item.ReceiptPath}}" alt="Receipt">
<div style="position: absolute; bottom: 0.5rem; right: 0.5rem;">
<a href="/uploads/{{.Item.ReceiptPath}}" target="_blank" class="btn btn-secondary" style="padding: 0.25rem 0.5rem; font-size: 0.75rem; background: white;">
Open Document
</a>
</div>
{{else}}
<div class="visual-placeholder">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" style="width: 48px; height: 48px;">
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z" />
</svg>
<span>No Receipt Document</span>
</div>
{{end}}
</div>
</div>
</div>
<!-- Custom fields card -->
<div class="card">
<h3 style="font-weight: 700; font-size: 1.15rem; margin-bottom: 1.25rem; color: var(--color-brand-primary); border-bottom: 1px solid var(--color-border); padding-bottom: 0.5rem;">Custom Asset Metadata</h3>
{{if .CustomFieldsMap}}
<div class="data-table-wrapper">
<table class="data-table">
<tbody>
{{range $key, $value := .CustomFieldsMap}}
<tr>
<td style="font-weight: 600; width: 200px; color: var(--color-text-muted); padding: 0.75rem 0.5rem;">{{$key}}</td>
<td style="font-family: monospace; font-size: 0.95rem; padding: 0.75rem 0.5rem;">{{$value}}</td>
</tr>
{{end}}
</tbody>
</table>
</div>
{{else}}
<p style="color: var(--color-text-light); font-size: 0.95rem; font-style: italic;">No custom metadata fields defined for this asset.</p>
{{end}}
</div>
</div>
<!-- Detail Sidebar Section -->
<div class="detail-sidebar">
<!-- QR code card -->
<div class="card qr-card">
<h4 style="font-weight: 700; color: var(--color-text-muted); font-size: 1.05rem;">Asset Label QR Code</h4>
{{if .Item.ShortSlug}}
<img class="qr-image" src="/admin/qr/{{.Item.ShortSlug}}" alt="QR Code">
<code style="font-family: monospace; background-color: var(--color-bg-base); padding: 0.35rem 0.75rem; border-radius: 4px; border: 1px solid var(--color-border); font-weight: 600; font-size: 0.95rem;">
s/{{.Item.ShortSlug}}
</code>
<a href="/admin/qr/{{.Item.ShortSlug}}" download="{{.Item.Name}}_QR.png" class="btn btn-secondary" style="width: 100%; font-size: 0.85rem;">
Download Label Image
</a>
{{else}}
<span style="color: var(--color-text-light); font-size: 0.85rem;">No short URL associated.</span>
{{end}}
</div>
<!-- Purchase particulars card -->
<div class="card" style="display: flex; flex-direction: column; gap: 1.25rem;">
<h4 style="font-weight: 700; color: var(--color-text-muted); font-size: 1.05rem; border-bottom: 1px solid var(--color-border); padding-bottom: 0.5rem; margin-bottom: 0.25rem;">Purchase Context</h4>
<div>
<span style="font-size: 0.75rem; color: var(--color-text-light); text-transform: uppercase; font-weight: 600; display: block;">Purchase Price</span>
<span style="font-weight: 700; font-size: 1.35rem; color: var(--color-brand-primary);">
{{if .Item.PurchasePrice.Valid}}{{formatPrice .Item.PurchasePrice}}{{else}}--{{end}}
</span>
</div>
<div>
<span style="font-size: 0.75rem; color: var(--color-text-light); text-transform: uppercase; font-weight: 600; display: block;">Supplier / Dealer</span>
<span style="font-weight: 600; font-size: 1rem;">
{{if .Item.Supplier}}{{.Item.Supplier}}{{else}}--{{end}}
</span>
</div>
<div>
<span style="font-size: 0.75rem; color: var(--color-text-light); text-transform: uppercase; font-weight: 600; display: block;">Purchase Date</span>
<span style="font-weight: 600; font-size: 1rem;">
{{if .Item.PurchaseDate.Valid}}{{formatDate .Item.PurchaseDate}}{{else}}--{{end}}
</span>
</div>
<div>
<span style="font-size: 0.75rem; color: var(--color-text-light); text-transform: uppercase; font-weight: 600; display: block;">Warranty Period</span>
<span style="font-weight: 600; font-size: 1rem;">
{{if .Item.WarrantyMonths.Valid}}{{.Item.WarrantyMonths.Int64}} Months{{else}}--{{end}}
</span>
</div>
<div>
<span style="font-size: 0.75rem; color: var(--color-text-light); text-transform: uppercase; font-weight: 600; display: block;">Assigned Location</span>
<span style="font-weight: 600; font-size: 1rem; color: var(--color-brand-primary);">
{{if .Item.LocationName.Valid}}
{{.Item.LocationName.String}}
{{else}}
<span style="color: var(--color-text-light); font-style: italic; font-weight: 500;">Unassigned</span>
{{end}}
</span>
</div>
</div>
</div>
</div>
{{else}}
<!-- ================== DEFAULT: MAIN INVENTORY LIST ================== -->
<div class="page-header">
<div class="page-title">
<h1>Asset Inventory</h1>
<p>Track, manage, and label your home equipment and tools.</p>
</div>
<div>
<a href="/admin/items/new" class="btn btn-primary">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor" style="width: 18px; height: 18px;">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>
Add Asset
</a>
</div>
</div>
<!-- Search & Filters -->
<form action="/admin" method="GET" class="filter-bar">
<div class="search-input-wrapper">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.604 10.604z" />
</svg>
<input type="text" name="search" class="form-control" placeholder="Search by asset name, model, serial number..." value="{{.SearchQuery}}">
</div>
<select name="status" class="form-control" style="width: 180px;" onchange="this.form.submit()">
<option value="">-- All Statuses --</option>
<option value="In Use" {{if eq .SelectedStatus "In Use"}}selected{{end}}>In Use</option>
<option value="In Storage" {{if eq .SelectedStatus "In Storage"}}selected{{end}}>In Storage</option>
<option value="Borrowed" {{if eq .SelectedStatus "Borrowed"}}selected{{end}}>Borrowed</option>
<option value="Lost" {{if eq .SelectedStatus "Lost"}}selected{{end}}>Lost</option>
<option value="Disposed" {{if eq .SelectedStatus "Disposed"}}selected{{end}}>Disposed</option>
</select>
<select name="location" class="form-control" style="width: 200px;" onchange="this.form.submit()">
<option value="">-- All Locations --</option>
{{range .Locations}}
<option value="{{.ID}}" {{if eq $.SelectedLocation .ID}}selected{{end}}>{{.Name}}</option>
{{end}}
</select>
<button type="submit" class="btn btn-secondary">Filter</button>
{{if or .SearchQuery (or .SelectedStatus .SelectedLocation)}}
<a href="/admin" class="btn btn-secondary" style="padding: 0.625rem;">Reset</a>
{{end}}
</form>
<!-- Assets Inventory Table -->
<div class="card" style="padding: 0;">
<div class="data-table-wrapper">
<table class="data-table">
<thead>
<tr>
<th style="width: 80px;">QR Label</th>
<th>Name</th>
<th>Location</th>
<th>Status</th>
<th>Quantity</th>
<th>Tags</th>
<th style="width: 140px; text-align: right;">Actions</th>
</tr>
</thead>
<tbody>
{{if .Items}}
{{range .Items}}
<tr>
<td style="text-align: center; vertical-align: middle;">
{{if .ShortSlug}}
<a href="/admin/qr/{{.ShortSlug}}" target="_blank">
<img src="/admin/qr/{{.ShortSlug}}" alt="QR Label" style="width: 42px; height: 42px; border: 1px solid var(--color-border); padding: 1px; border-radius: 4px; background: white;">
</a>
{{else}}
<span style="color: var(--color-text-light); font-size: 0.75rem;">--</span>
{{end}}
</td>
<td>
<div style="display: flex; flex-direction: column;">
<a href="/admin?view={{.ID}}" style="font-weight: 700; color: var(--color-text-main); text-decoration: none; font-size: 1.05rem;">
{{.Name}}
</a>
{{if .ModelNumber}}
<span style="color: var(--color-text-muted); font-size: 0.8rem; font-family: monospace;">Model: {{.ModelNumber}}</span>
{{end}}
</div>
</td>
<td>
{{if .LocationName.Valid}}
<span style="color: var(--color-brand-primary); font-weight: 500; font-size: 0.95rem;">
{{.LocationName.String}}
</span>
{{else}}
<span style="color: var(--color-text-light); font-style: italic; font-size: 0.9rem;">Unassigned</span>
{{end}}
</td>
<td>
<span class="status-pill {{if eq .Status "In Use"}}in-use{{else if eq .Status "In Storage"}}in-storage{{else if eq .Status "Borrowed"}}borrowed{{else if eq .Status "Lost"}}lost{{else}}disposed{{end}}">
{{.Status}}
</span>
</td>
<td style="font-weight: 600; font-size: 0.95rem; color: var(--color-text-muted); text-align: center;">
{{.Quantity}}
</td>
<td>
<div class="tag-list">
{{range .Tags}}
<span class="tag-pill" style="background-color: {{.Color}};">{{.Name}}</span>
{{end}}
</div>
</td>
<td style="text-align: right;">
<div style="display: inline-flex; gap: 0.5rem; align-items: center;">
<a href="/admin?view={{.ID}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
Details
</a>
<a href="/admin/items/edit/{{.ID}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
Edit
</a>
<form action="/admin/items/delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to delete this asset? This cannot be undone.')" style="margin: 0;">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<button type="submit" class="btn btn-danger" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
Delete
</button>
</form>
</div>
</td>
</tr>
{{end}}
{{else}}
<tr>
<td colspan="7" style="text-align: center; color: var(--color-text-light); padding: 5rem 1rem;">
<div style="display: flex; flex-direction: column; align-items: center; gap: 1rem;">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1" stroke="currentColor" style="width: 64px; height: 64px; color: var(--color-text-light);">
<path stroke-linecap="round" stroke-linejoin="round" d="M20.25 7.5l-.625 10.632a2.25 2.25 0 01-2.247 2.118H6.622a2.25 2.25 0 01-2.247-2.118L3.75 7.5M10 11.25h4M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125z" />
</svg>
<div>
<h3 style="font-weight:600; color:var(--color-text-muted);">No assets found</h3>
<p style="font-size:0.9rem; margin-top:0.25rem;">Try refining your filters or click "Add Asset" to start tracking equipment.</p>
</div>
</div>
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
</div>
{{end}}
{{end}}
+141
View File
@@ -0,0 +1,141 @@
{{define "title"}}Solis | Locations{{end}}
{{define "content"}}
<div class="page-header">
<div class="page-title">
<h1>Locations</h1>
<p>Define physical areas and hierarchical storage places (e.g., House > Kitchen > Drawer A)</p>
</div>
</div>
<div class="detail-grid">
<!-- Left Column: Locations List -->
<div class="detail-main">
<div class="card" style="padding: 0;">
<div class="data-table-wrapper">
<table class="data-table">
<thead>
<tr>
<th>Name</th>
<th>Parent Path</th>
<th>Description</th>
<th style="width: 120px; text-align: right;">Actions</th>
</tr>
</thead>
<tbody>
{{if .Locations}}
{{range .Locations}}
<tr>
<td style="font-weight: 600; color: var(--color-brand-primary);">{{.Name}}</td>
<td>
{{if .ParentName.Valid}}
<span style="color: var(--color-text-muted); font-size: 0.9rem;">
{{.ParentName.String}} &rarr;
</span>
{{else}}
<span style="color: var(--color-text-light); font-size: 0.85rem;">Root</span>
{{end}}
</td>
<td style="color: var(--color-text-muted); font-size: 0.9rem;">{{.Description}}</td>
<td style="text-align: right;">
<div style="display: inline-flex; gap: 0.5rem;">
<!-- Edit Location triggers loading edit state in the right-side form -->
<a href="/admin/locations?edit={{.ID}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
Edit
</a>
{{if ne .ID 1}}
<form action="/admin/locations/delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to delete this location? Sub-locations and assets will be detached.')" style="margin: 0;">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<button type="submit" class="btn btn-danger" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
Delete
</button>
</form>
{{else}}
<span style="color: var(--color-text-light); font-size: 0.8rem; font-style: italic; padding: 0.35rem 0.65rem;">Locked</span>
{{end}}
</div>
</td>
</tr>
{{end}}
{{else}}
<tr>
<td colspan="4" style="text-align: center; color: var(--color-text-light); padding: 3rem 1rem;">
No locations defined yet. Add one on the right to get started!
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
</div>
</div>
<!-- Right Column: Add/Edit Form -->
<div class="detail-sidebar">
<div class="card">
{{if .EditingLocation}}
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">Edit Location</h3>
<form action="/admin/locations/edit/{{.EditingLocation.ID}}" method="POST">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<div class="form-group">
<label for="name" class="form-label">Location Name</label>
<input type="text" id="name" name="name" class="form-control" value="{{.EditingLocation.Name}}" {{if eq .EditingLocation.ID 1}}readonly style="background-color: var(--color-bg-base); cursor: not-allowed;"{{end}} required>
</div>
<div class="form-group">
<label for="parent_id" class="form-label">Parent Location (Optional)</label>
<select id="parent_id" name="parent_id" class="form-control">
<option value="">-- None (Root Location) --</option>
{{range $.Locations}}
{{if ne .ID $.EditingLocation.ID}}
<option value="{{.ID}}" {{if $.EditingLocation.ParentID.Valid}}{{if eq .ID $.EditingLocation.ParentID.Int64}}selected{{end}}{{end}}>
{{.Name}}
</option>
{{end}}
{{end}}
</select>
</div>
<div class="form-group" style="margin-bottom: 1.75rem;">
<label for="description" class="form-label">Description</label>
<textarea id="description" name="description" class="form-control" rows="3" placeholder="e.g. Red plastic storage box on shelf 2">{{.EditingLocation.Description}}</textarea>
</div>
<div style="display: flex; gap: 0.5rem;">
<button type="submit" class="btn btn-primary" style="flex-grow: 1;">Save Changes</button>
<a href="/admin/locations" class="btn btn-secondary">Cancel</a>
</div>
</form>
{{else}}
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">Create Location</h3>
<form action="/admin/locations/new" method="POST">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<div class="form-group">
<label for="name" class="form-label">Location Name</label>
<input type="text" id="name" name="name" class="form-control" placeholder="e.g. Living Room, Drawer B" required>
</div>
<div class="form-group">
<label for="parent_id" class="form-label">Parent Location (Optional)</label>
<select id="parent_id" name="parent_id" class="form-control">
<option value="">-- None (Root Location) --</option>
{{range .Locations}}
<option value="{{.ID}}">{{.Name}}</option>
{{end}}
</select>
</div>
<div class="form-group" style="margin-bottom: 1.75rem;">
<label for="description" class="form-label">Description</label>
<textarea id="description" name="description" class="form-control" rows="3" placeholder="e.g. First floor living room cupboard"></textarea>
</div>
<button type="submit" class="btn btn-primary" style="width: 100%;">Add Location</button>
</form>
{{end}}
</div>
</div>
</div>
{{end}}
+45
View File
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Solis | Sign In</title>
<link rel="stylesheet" href="/static/css/styles.css">
</head>
<body class="login-container">
<div class="login-card">
<div class="login-header">
<div class="brand">
<div class="brand-logo">S</div>
<span class="brand-name">Solis</span>
</div>
<h2 style="font-weight:700;font-size:1.5rem;letter-spacing:-0.01em;">Sign in to your assets</h2>
<p style="color:var(--color-text-muted);font-size:0.9rem;margin-top:0.25rem;">Enter your administrator credentials below</p>
</div>
{{if .Error}}
<div style="background-color:#fee2e2; border:1px solid #fca5a5; color:#b91c1c; padding:0.75rem 1rem; border-radius:6px; font-size:0.9rem; margin-bottom:1.5rem; font-weight:500; text-align:center;">
{{.Error}}
</div>
{{end}}
<form action="/admin/login" method="POST">
<input type="hidden" name="csrf_token" value="{{.CSRFToken}}">
<div class="form-group">
<label for="username" class="form-label">Username</label>
<input type="text" id="username" name="username" class="form-control" placeholder="e.g. admin" required autofocus>
</div>
<div class="form-group" style="margin-bottom: 2rem;">
<label for="password" class="form-label">Password</label>
<input type="password" id="password" name="password" class="form-control" placeholder="••••••••" required>
</div>
<button type="submit" class="btn btn-primary" style="width: 100%; padding: 0.75rem 1.25rem; font-size: 1rem;">
Sign In
</button>
</form>
</div>
</body>
</html>
@@ -0,0 +1,51 @@
{{define "title"}}Solis | Print Labels{{end}}
{{define "content"}}
<div class="page-header">
<div class="page-title">
<h1>Printable QR Labels</h1>
<p>Generate high-fidelity label sheets for your inventory. Press <kbd style="font-family: monospace; background:#e7e5e4; padding:0.1rem 0.3rem; border-radius:3px; font-weight:600;">Ctrl + P</kbd> (or <kbd style="font-family: monospace; background:#e7e5e4; padding:0.1rem 0.3rem; border-radius:3px; font-weight:600;">Cmd + P</kbd>) to print sticker sheets. Standard print stylesheets are auto-applied.</p>
</div>
<div style="display: flex; gap: 0.5rem;">
<button onclick="window.print()" class="btn btn-primary">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" style="width:18px;height:18px;">
<path stroke-linecap="round" stroke-linejoin="round" d="M6.72 13.829c-.24.03-.48.062-.72.096m.72-.096a42.415 42.415 0 0110.56 0m-10.56 0L6.34 18m10.94-4.171c.24.03.48.062.72.096m-.72-.096L17.66 18m0 0a2.25 2.25 0 01-2.247 2.118H8.587A2.25 2.25 0 016.34 18m11.32 0h.008v.008h-.008V18zm-12 0h.008v.008h-.008V18zm0-11.25h12.75c.621 0 1.125.504 1.125 1.125v1.5c0 .621-.504 1.125-1.125 1.125H5.66c-.621 0-1.125-.504-1.125-1.125v-1.5c0-.621.504-1.125 1.125-1.125z" />
</svg>
Print Sheet
</button>
<a href="/admin" class="btn btn-secondary">Back to Assets</a>
</div>
</div>
<div class="card" style="margin-bottom: 2rem;">
<h3 style="font-weight: 700; margin-bottom: 0.5rem; color: var(--color-brand-primary);">Printing Guidelines</h3>
<ul style="margin-left: 1.5rem; color: var(--color-text-muted); font-size: 0.95rem; display: flex; flex-direction: column; gap: 0.25rem;">
<li>Set your margins to <strong>None</strong> or <strong>Minimum</strong> in the browser print dialogue.</li>
<li>Enable <strong>Background graphics</strong> to preserve borders and alignments.</li>
<li>Check the layout preview page size (standard Letter/A4) to ensure grid alignment on your sticker paper.</li>
</ul>
</div>
<!-- Dynamic Printable Grid -->
<div class="print-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; padding: 10px; background-color: white; border: 1px solid var(--color-border); border-radius: var(--radius-md);">
{{if .Items}}
{{range .Items}}
{{if .ShortSlug}}
<div class="print-label-item" style="border: 1px dashed var(--color-border); border-radius: var(--radius-sm); padding: 1rem; text-align: center; background-color: white; display: flex; flex-direction: column; align-items: center; justify-content: space-between; aspect-ratio: 1/1;">
<div class="print-label-name" style="font-weight: 700; font-size: 0.95rem; color: var(--color-text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%;" title="{{.Name}}">
{{.Name}}
</div>
<img class="print-label-qr" src="/admin/qr/{{.ShortSlug}}" alt="QR Code" style="width: 110px; height: 110px; margin: 0.5rem 0; border: 1px solid var(--color-border); padding: 2px;">
<div class="print-label-slug" style="font-family: monospace; font-size: 0.8rem; color: var(--color-text-muted); font-weight: 600;">
s/{{.ShortSlug}}
</div>
</div>
{{end}}
{{end}}
{{else}}
<div style="grid-column: 1/-1; text-align: center; color: var(--color-text-light); padding: 4rem 1rem;">
No items with active short links found. Create an asset to generate labels!
</div>
{{end}}
</div>
{{end}}
+143
View File
@@ -0,0 +1,143 @@
{{define "title"}}Solis | URL Shortener{{end}}
{{define "content"}}
<div class="page-header">
<div class="page-title">
<h1>URL Shortener</h1>
<p>Manage custom manual redirects (e.g. warranties, external manuals) or review auto-generated asset short URLs.</p>
</div>
</div>
<div class="detail-grid">
<!-- Left Column: Links List -->
<div class="detail-main">
<div class="card" style="padding: 0;">
<div class="data-table-wrapper">
<table class="data-table">
<thead>
<tr>
<th>Slug</th>
<th>Target URL</th>
<th>Link Type</th>
<th style="width: 80px; text-align: center;">Clicks</th>
<th style="width: 120px; text-align: right;">Actions</th>
</tr>
</thead>
<tbody>
{{if .Links}}
{{range .Links}}
<tr>
<td>
<div style="display: flex; flex-direction: column; gap: 0.15rem;">
<a href="/s/{{.Slug}}" target="_blank" style="font-weight: 700; color: var(--color-brand-primary); text-decoration: none;">
/s/{{.Slug}}
</a>
<!-- QR code link quick view in printer sheet -->
<a href="/admin/qr/{{.Slug}}" target="_blank" style="font-size: 0.75rem; color: var(--color-text-light); text-decoration: underline;">
View QR Code
</a>
</div>
</td>
<td>
<div style="max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: monospace; font-size: 0.85rem;" title="{{.URL}}">
{{.URL}}
</div>
</td>
<td>
{{if .ItemID.Valid}}
<span style="font-size: 0.8rem; font-weight: 600; color:#065f46; background-color:#d1fae5; padding: 0.2rem 0.5rem; border-radius: 4px;">
Asset #{{.ItemID.Int64}} Link
</span>
{{else}}
<span style="font-size: 0.8rem; font-weight: 600; color:#1e40af; background-color:#dbeafe; padding: 0.2rem 0.5rem; border-radius: 4px;">
Manual Redirect
</span>
{{end}}
</td>
<td style="text-align: center; font-weight: 600; font-size: 0.95rem; color: var(--color-text-muted);">
{{.Clicks}}
</td>
<td style="text-align: right;">
{{if .ItemID.Valid}}
<!-- Asset link modifications are handled through items CRUD -->
<span style="color: var(--color-text-light); font-size: 0.85rem; font-style: italic;">Managed by Asset</span>
{{else}}
<div style="display: inline-flex; gap: 0.5rem;">
<a href="/admin/shortener?edit={{.ID}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
Edit
</a>
<form action="/admin/shortener/delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to delete this custom redirect?')" style="margin: 0;">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<button type="submit" class="btn btn-danger" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
Delete
</button>
</form>
</div>
{{end}}
</td>
</tr>
{{end}}
{{else}}
<tr>
<td colspan="5" style="text-align: center; color: var(--color-text-light); padding: 3rem 1rem;">
No short links recorded. Create a custom redirect on the right!
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
</div>
</div>
<!-- Right Column: Add/Edit Form -->
<div class="detail-sidebar">
<div class="card">
{{if .EditingLink}}
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">Edit Redirect</h3>
<form action="/admin/shortener/edit/{{.EditingLink.ID}}" method="POST">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<div class="form-group">
<label for="slug" class="form-label">Short Slug</label>
<input type="text" id="slug" name="slug" class="form-control" value="{{.EditingLink.Slug}}" required>
</div>
<div class="form-group" style="margin-bottom: 1.75rem;">
<label for="url" class="form-label">Target Destination URL</label>
<input type="url" id="url" name="url" class="form-control" value="{{.EditingLink.URL}}" placeholder="e.g. https://brand.com/manual.pdf" required>
</div>
<div style="display: flex; gap: 0.5rem;">
<button type="submit" class="btn btn-primary" style="flex-grow: 1;">Save Changes</button>
<a href="/admin/shortener" class="btn btn-secondary">Cancel</a>
</div>
</form>
{{else}}
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">Create Redirect</h3>
<form action="/admin/shortener/new" method="POST">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<div class="form-group">
<label for="slug" class="form-label">Custom Slug (Optional)</label>
<div style="display: flex; gap: 0.5rem;">
<input type="text" id="slug" name="slug" class="form-control" placeholder="e.g. warranty1" style="flex-grow:1;">
<button type="button" class="btn btn-secondary" style="padding: 0 0.75rem;" onclick="document.getElementById('slug').value = Math.random().toString(36).substring(2, 6)">
Auto
</button>
</div>
<span style="font-size: 0.75rem; color: var(--color-text-light); margin-top: 0.25rem; display: block;">Leave blank to generate a random 4-character slug.</span>
</div>
<div class="form-group" style="margin-bottom: 1.75rem;">
<label for="url" class="form-label">Destination URL</label>
<input type="url" id="url" name="url" class="form-control" placeholder="e.g. https://support.brand.com/warranty" required>
</div>
<button type="submit" class="btn btn-primary" style="width: 100%;">Add Redirect</button>
</form>
{{end}}
</div>
</div>
</div>
{{end}}
+132
View File
@@ -0,0 +1,132 @@
{{define "title"}}Solis | Tags{{end}}
{{define "content"}}
<div class="page-header">
<div class="page-title">
<h1>Tags</h1>
<p>Label and categorize assets to easily group similar items together (e.g. Tools, Electronics, Fragile)</p>
</div>
</div>
<div class="detail-grid">
<!-- Left Column: Tags List -->
<div class="detail-main">
<div class="card" style="padding: 0;">
<div class="data-table-wrapper">
<table class="data-table">
<thead>
<tr>
<th style="width: 150px;">Tag</th>
<th>Color Hex</th>
<th>Description</th>
<th style="width: 120px; text-align: right;">Actions</th>
</tr>
</thead>
<tbody>
{{if .Tags}}
{{range .Tags}}
<tr>
<td>
<span class="tag-pill" style="background-color: {{.Color}}; color: #1c1917; padding: 0.35rem 0.75rem; font-size: 0.85rem;">
{{.Name}}
</span>
</td>
<td>
<code style="font-family: monospace; font-size: 0.9rem; background-color: var(--color-bg-base); padding: 0.15rem 0.35rem; border-radius: 4px; border: 1px solid var(--color-border);">
{{.Color}}
</code>
</td>
<td style="color: var(--color-text-muted); font-size: 0.9rem;">{{.Description}}</td>
<td style="text-align: right;">
<div style="display: inline-flex; gap: 0.5rem;">
<a href="/admin/tags?edit={{.ID}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
Edit
</a>
{{if ne .Name "Default Room"}}
<form action="/admin/tags/delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to delete this tag? All associated items will lose this tag reference.')" style="margin: 0;">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<button type="submit" class="btn btn-danger" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
Delete
</button>
</form>
{{else}}
<span style="color: var(--color-text-light); font-size: 0.8rem; font-style: italic; padding: 0.35rem 0.65rem;">Locked</span>
{{end}}
</div>
</td>
</tr>
{{end}}
{{else}}
<tr>
<td colspan="4" style="text-align: center; color: var(--color-text-light); padding: 3rem 1rem;">
No tags defined yet. Add one on the right to get started!
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
</div>
</div>
<!-- Right Column: Add/Edit Form -->
<div class="detail-sidebar">
<div class="card">
{{if .EditingTag}}
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">Edit Tag</h3>
<form action="/admin/tags/edit/{{.EditingTag.ID}}" method="POST">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<div class="form-group">
<label for="name" class="form-label">Tag Name</label>
<input type="text" id="name" name="name" class="form-control" value="{{.EditingTag.Name}}" {{if eq .EditingTag.Name "Default Room"}}readonly style="background-color: var(--color-bg-base); cursor: not-allowed;"{{end}} required>
</div>
<div class="form-group">
<label for="color" class="form-label">Tag Color</label>
<div style="display: flex; gap: 0.5rem; align-items: center;">
<input type="color" id="color-picker" class="form-control" style="width: 50px; height: 38px; padding: 2px; cursor: pointer;" value="{{.EditingTag.Color}}" oninput="document.getElementById('color').value = this.value">
<input type="text" id="color" name="color" class="form-control" style="flex-grow:1;" value="{{.EditingTag.Color}}" required placeholder="e.g. #3b82f6" oninput="document.getElementById('color-picker').value = this.value">
</div>
</div>
<div class="form-group" style="margin-bottom: 1.75rem;">
<label for="description" class="form-label">Description</label>
<textarea id="description" name="description" class="form-control" rows="3" placeholder="e.g. Kitchen appliances and tools">{{.EditingTag.Description}}</textarea>
</div>
<div style="display: flex; gap: 0.5rem;">
<button type="submit" class="btn btn-primary" style="flex-grow: 1;">Save Changes</button>
<a href="/admin/tags" class="btn btn-secondary">Cancel</a>
</div>
</form>
{{else}}
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">Create Tag</h3>
<form action="/admin/tags/new" method="POST">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<div class="form-group">
<label for="name" class="form-label">Tag Name</label>
<input type="text" id="name" name="name" class="form-control" placeholder="e.g. Tools, Kitchen" required>
</div>
<div class="form-group">
<label for="color" class="form-label">Tag Color</label>
<div style="display: flex; gap: 0.5rem; align-items: center;">
<input type="color" id="color-picker" class="form-control" style="width: 50px; height: 38px; padding: 2px; cursor: pointer;" value="#e2e8f0" oninput="document.getElementById('color').value = this.value">
<input type="text" id="color" name="color" class="form-control" style="flex-grow:1;" value="#e2e8f0" required placeholder="e.g. #3b82f6" oninput="document.getElementById('color-picker').value = this.value">
</div>
</div>
<div class="form-group" style="margin-bottom: 1.75rem;">
<label for="description" class="form-label">Description</label>
<textarea id="description" name="description" class="form-control" rows="3" placeholder="e.g. All electronic appliances"></textarea>
</div>
<button type="submit" class="btn btn-primary" style="width: 100%;">Add Tag</button>
</form>
{{end}}
</div>
</div>
</div>
{{end}}