Implement non-destructive Remove & Archive lifecycle system across assets, locations, tags, and shortlinks
This commit is contained in:
1 parent
3391257f6c
commit
960c375557
20 files changed
+1751
-185
No files matched your search
@@ -0,0 +1,97 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"os"
|
||||
|
||||
"Solis/internal/config"
|
||||
"Solis/internal/db"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 1. Load catalog
|
||||
cat, err := config.LoadCatalog("../catalog.json")
|
||||
if err != nil {
|
||||
fmt.Printf("Error loading catalog: %v\n", err)
|
||||
return
|
||||
}
|
||||
catalogJSON, _ := json.Marshal(cat)
|
||||
|
||||
// 2. Define PageData struct matching internal/server/handlers.go
|
||||
type PageData struct {
|
||||
CSRFToken string
|
||||
ActiveNav string
|
||||
Toast string
|
||||
ToastType string
|
||||
Error string
|
||||
Items []db.Item
|
||||
Item *db.Item
|
||||
Locations []db.Location
|
||||
Tags []db.Tag
|
||||
Links []db.Link
|
||||
EditingLocation *db.Location
|
||||
EditingTag *db.Tag
|
||||
EditingLink *db.Link
|
||||
EditingItem *db.Item
|
||||
FormMode bool
|
||||
ViewMode bool
|
||||
CustomFieldsRaw string
|
||||
CustomFieldsMap map[string]string
|
||||
SearchQuery string
|
||||
SelectedStatus string
|
||||
SelectedLocation int64
|
||||
CatalogJSON string
|
||||
}
|
||||
|
||||
data := PageData{
|
||||
FormMode: true,
|
||||
CatalogJSON: string(catalogJSON),
|
||||
}
|
||||
|
||||
// 3. Define the template functions matching internal/server/templates.go
|
||||
templateFuncs := template.FuncMap{
|
||||
"safeJS": func(s string) template.JS {
|
||||
return template.JS(s)
|
||||
},
|
||||
"formatPrice": func(p any) string {
|
||||
return ""
|
||||
},
|
||||
"formatDate": func(d any) string {
|
||||
return ""
|
||||
},
|
||||
"dict": func(values ...interface{}) (map[string]interface{}, error) {
|
||||
return nil, nil
|
||||
},
|
||||
"hasTag": func(itemTags []db.Tag, tagID int64) bool {
|
||||
return false
|
||||
},
|
||||
}
|
||||
|
||||
// 4. Parse templates
|
||||
t, err := template.New("base.html").Funcs(templateFuncs).ParseFiles(
|
||||
"../internal/server/templates/base.html",
|
||||
"../internal/server/templates/items.html",
|
||||
)
|
||||
if err != nil {
|
||||
fmt.Printf("Error parsing templates: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
// 5. Render template
|
||||
out, err := os.Create("rendered.html")
|
||||
if err != nil {
|
||||
fmt.Printf("Error creating output file: %v\n", err)
|
||||
return
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
err = t.Execute(out, data)
|
||||
if err != nil {
|
||||
fmt.Printf("Error executing template: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("Render completed successfully!")
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"os"
|
||||
|
||||
"Solis/internal/config"
|
||||
"Solis/internal/db"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 1. Load catalog
|
||||
cat, err := config.LoadCatalog("../catalog.json")
|
||||
if err != nil {
|
||||
fmt.Printf("Error loading catalog: %v\n", err)
|
||||
return
|
||||
}
|
||||
catalogJSON, _ := json.Marshal(cat)
|
||||
|
||||
// 2. Define PageData struct matching internal/server/handlers.go
|
||||
type PageData struct {
|
||||
CSRFToken string
|
||||
ActiveNav string
|
||||
Toast string
|
||||
ToastType string
|
||||
Error string
|
||||
Items []db.Item
|
||||
Item *db.Item
|
||||
Locations []db.Location
|
||||
Tags []db.Tag
|
||||
Links []db.Link
|
||||
EditingLocation *db.Location
|
||||
EditingTag *db.Tag
|
||||
EditingLink *db.Link
|
||||
EditingItem *db.Item
|
||||
FormMode bool
|
||||
ViewMode bool
|
||||
CustomFieldsRaw string
|
||||
CustomFieldsMap map[string]string
|
||||
SearchQuery string
|
||||
SelectedStatus string
|
||||
SelectedLocation int64
|
||||
CatalogJSON string
|
||||
}
|
||||
|
||||
data := PageData{
|
||||
FormMode: true,
|
||||
CatalogJSON: string(catalogJSON),
|
||||
}
|
||||
|
||||
// 3. Define the template functions matching internal/server/templates.go
|
||||
templateFuncs := template.FuncMap{
|
||||
"safeJS": func(s string) template.JS {
|
||||
return template.JS(s)
|
||||
},
|
||||
"formatPrice": func(p any) string {
|
||||
return ""
|
||||
},
|
||||
"formatDate": func(d any) string {
|
||||
return ""
|
||||
},
|
||||
"dict": func(values ...interface{}) (map[string]interface{}, error) {
|
||||
return nil, nil
|
||||
},
|
||||
"hasTag": func(itemTags []db.Tag, tagID int64) bool {
|
||||
return false
|
||||
},
|
||||
}
|
||||
|
||||
// 4. Parse templates
|
||||
t, err := template.New("base.html").Funcs(templateFuncs).ParseFiles(
|
||||
"../internal/server/templates/base.html",
|
||||
"../internal/server/templates/items.html",
|
||||
)
|
||||
if err != nil {
|
||||
fmt.Printf("Error parsing templates: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
// 5. Render template
|
||||
out, err := os.Create("rendered.html")
|
||||
if err != nil {
|
||||
fmt.Printf("Error creating output file: %v\n", err)
|
||||
return
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
err = t.Execute(out, data)
|
||||
if err != nil {
|
||||
fmt.Printf("Error executing template: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("Render completed successfully!")
|
||||
}
|
||||
@@ -0,0 +1,663 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Solis | Assets</title>
|
||||
|
||||
|
||||
<meta name="csrf-token" content="">
|
||||
|
||||
|
||||
<link rel="stylesheet" href="/static/css/styles.css">
|
||||
|
||||
|
||||
<script src="/static/js/htmx.min.js"></script>
|
||||
<script src="/static/js/main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="app-container">
|
||||
|
||||
<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 ">
|
||||
<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 ">
|
||||
<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 ">
|
||||
<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 ">
|
||||
<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 ">
|
||||
<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>
|
||||
|
||||
|
||||
<div class="sidebar-footer">
|
||||
<form action="/admin/logout" method="POST">
|
||||
<input type="hidden" name="csrf_token" value="">
|
||||
<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 class="main-wrapper">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-header">
|
||||
<div class="page-title">
|
||||
<h1>Add New Asset</h1>
|
||||
<p>Catalog any device, appliance, or item in seconds using our intuitive selection wizard.</p>
|
||||
</div>
|
||||
<div>
|
||||
<a href="/admin" class="btn btn-secondary">Cancel</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="wizard-progress-bar">
|
||||
<div class="wizard-step active" id="progress-step-1">
|
||||
<span class="step-num">1</span>
|
||||
<span class="step-label">Category</span>
|
||||
</div>
|
||||
<div class="wizard-line" id="progress-line-1"></div>
|
||||
<div class="wizard-step" id="progress-step-2">
|
||||
<span class="step-num">2</span>
|
||||
<span class="step-label">Item</span>
|
||||
</div>
|
||||
<div class="wizard-line" id="progress-line-2"></div>
|
||||
<div class="wizard-step" id="progress-step-3">
|
||||
<span class="step-num">3</span>
|
||||
<span class="step-label">Brand</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card" style="padding: 2.25rem;">
|
||||
|
||||
<form id="wizard-form" action="/admin/items/new" method="POST">
|
||||
<input type="hidden" name="csrf_token" value="">
|
||||
<input type="hidden" name="wizard_flow" value="true">
|
||||
<input type="hidden" id="input-category" name="category" value="">
|
||||
<input type="hidden" id="input-item" name="item" value="">
|
||||
<input type="hidden" id="input-brand" name="brand" value="">
|
||||
</form>
|
||||
|
||||
|
||||
<div style="margin-bottom: 2rem; display: none;" id="wizard-back-wrapper">
|
||||
<button type="button" class="btn btn-secondary" id="btn-wizard-back" style="padding: 0.5rem 1rem; font-size: 0.85rem; border-radius: var(--radius-sm);">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor" style="width: 14px; height: 14px;">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5" />
|
||||
</svg>
|
||||
Back to previous step
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="wizard-screen active" id="screen-category">
|
||||
<h3 class="wizard-screen-title">Which category of item do you want to add?</h3>
|
||||
<div class="category-grid" id="category-grid-container">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="wizard-screen" id="screen-item">
|
||||
<h3 class="wizard-screen-title" id="item-screen-heading">What kind of item is it?</h3>
|
||||
<div class="pills-grid" id="item-grid-container">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="wizard-screen" id="screen-brand">
|
||||
<h3 class="wizard-screen-title" id="brand-screen-heading">What brand is the item?</h3>
|
||||
<div class="pills-grid" id="brand-grid-container">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<style>
|
||||
.wizard-progress-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 2.5rem;
|
||||
max-width: 600px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.wizard-step {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.wizard-step .step-num {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
background-color: var(--color-bg-base);
|
||||
border: 2px solid var(--color-border);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: 700;
|
||||
color: var(--color-text-light);
|
||||
font-size: 0.95rem;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.wizard-step .step-label {
|
||||
font-size: 0.85rem;
|
||||
font-weight: 600;
|
||||
color: var(--color-text-light);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.wizard-step.active .step-num {
|
||||
background-color: var(--color-brand-primary);
|
||||
border-color: var(--color-brand-primary);
|
||||
color: white;
|
||||
box-shadow: 0 4px 10px rgba(217, 119, 6, 0.3);
|
||||
}
|
||||
|
||||
.wizard-step.active .step-label {
|
||||
color: var(--color-brand-primary);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.wizard-step.completed .step-num {
|
||||
background-color: #10b981;
|
||||
border-color: #10b981;
|
||||
color: white;
|
||||
box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
|
||||
}
|
||||
|
||||
.wizard-step.completed .step-label {
|
||||
color: #10b981;
|
||||
}
|
||||
|
||||
.wizard-line {
|
||||
flex-grow: 1;
|
||||
height: 3px;
|
||||
background-color: var(--color-border);
|
||||
margin: 0 -0.5rem;
|
||||
transform: translateY(-13px);
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.wizard-line.completed {
|
||||
background-color: #10b981;
|
||||
}
|
||||
|
||||
.wizard-line.active {
|
||||
background-color: var(--color-brand-primary);
|
||||
}
|
||||
|
||||
.wizard-screen {
|
||||
display: none;
|
||||
animation: wizardFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
|
||||
.wizard-screen.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@keyframes wizardFadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(8px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.wizard-screen-title {
|
||||
font-size: 1.35rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 2rem;
|
||||
color: var(--color-text-main);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
.category-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.category-card {
|
||||
aspect-ratio: 1/1;
|
||||
background-color: var(--color-bg-surface);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-md);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 1.5rem 1rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
box-shadow: var(--shadow-sm);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.category-card:hover {
|
||||
transform: translateY(-4px);
|
||||
box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.08);
|
||||
border-color: var(--cat-color);
|
||||
background-color: var(--cat-color-bg);
|
||||
}
|
||||
|
||||
.category-badge {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 12px;
|
||||
background-color: var(--cat-color-badge-bg);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 1.4rem;
|
||||
font-weight: 700;
|
||||
color: var(--cat-color);
|
||||
margin-bottom: 1rem;
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.category-card:hover .category-badge {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.category-name {
|
||||
font-size: 0.95rem;
|
||||
font-weight: 600;
|
||||
color: var(--color-text-main);
|
||||
}
|
||||
|
||||
|
||||
.pills-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.pill-button {
|
||||
background-color: var(--color-bg-surface);
|
||||
border: 1.5px solid var(--color-border);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 1rem 1.25rem;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
color: var(--color-text-main);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
.pill-button:hover {
|
||||
border-color: var(--color-brand-primary);
|
||||
background-color: #fefaf0;
|
||||
color: var(--color-brand-primary);
|
||||
transform: translateX(2px);
|
||||
}
|
||||
|
||||
.pill-button svg {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
color: var(--color-text-light);
|
||||
transition: transform 0.2s ease, color 0.2s ease;
|
||||
}
|
||||
|
||||
.pill-button:hover svg {
|
||||
transform: translateX(3px);
|
||||
color: var(--color-brand-primary);
|
||||
}
|
||||
|
||||
.pill-button.other-pill {
|
||||
border-style: dashed;
|
||||
border-width: 2px;
|
||||
background-color: var(--color-bg-base);
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.pill-button.other-pill:hover {
|
||||
border-color: var(--color-text-muted);
|
||||
background-color: var(--color-border);
|
||||
color: var(--color-text-main);
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
|
||||
const catalog = [{"id":"tech","name":"Tech \u0026 Electronics","color":"#3b82f6","items":[{"name":"Smartphones","brands":["Apple","Samsung","Google","OnePlus","Xiaomi","Sony","Motorola","Oppo"]},{"name":"Laptops","brands":["Dell","HP","Lenovo","Apple","ASUS","Acer","Microsoft","MSI"]},{"name":"Tablets","brands":["Apple","Samsung","Lenovo","Microsoft","Amazon","Huawei","Xiaomi","OnePlus"]},{"name":"Smartwatches","brands":["Apple","Samsung","Garmin","Fitbit","Fossil","Amazfit","Huawei","Google"]},{"name":"Desktop Computers","brands":["Dell","HP","Lenovo","Apple","ASUS","Acer","Corsair","CyberPowerPC"]},{"name":"Computer Monitors","brands":["Dell","LG","Samsung","ASUS","Acer","BenQ","HP","MSI"]},{"name":"Keyboards","brands":["Logitech","SteelSeries","Razer","Corsair","Keychron","Ducky","HyperX","Redragon"]},{"name":"Computer Mice","brands":["Logitech","Razer","Corsair","SteelSeries","HyperX","Glorious","ASUS","Roccat"]}]},{"id":"kitchen","name":"Kitchen Appliances","color":"#ec4899","items":[{"name":"Coffee Makers","brands":["Keurig","Nespresso","Breville","De'Longhi","Cuisinart","Mr. Coffee","Philips","Krups"]},{"name":"Blenders","brands":["Vitamix","Ninja","Blendtec","KitchenAid","NutriBullet","Oster","Breville","Cuisinart"]},{"name":"Toasters","brands":["Breville","Cuisinart","KitchenAid","Black+Decker","Hamilton Beach","SMEG","Zojirushi","Oster"]},{"name":"Microwaves","brands":["Panasonic","Toshiba","Samsung","LG","GE","Sharp","Whirlpool","Farberware"]},{"name":"Air Fryers","brands":["Ninja","Instant Pot","Cosori","Philips","Chefman","Tefal","Breville","GoWISE"]},{"name":"Food Processors","brands":["Cuisinart","Breville","KitchenAid","Ninja","Hamilton Beach","Braun","Magimix","Kenwood"]},{"name":"Juicers","brands":["Breville","Omega","Hurom","Hamilton Beach","Cuisinart","Nama","Tribest","Mueller"]},{"name":"Rice Cookers","brands":["Zojirushi","Tiger","Instant Pot","Cuckoo","Hamilton Beach","Aroma","Panasonic","Toshiba"]}]},{"id":"furniture","name":"Furniture","color":"#8b5cf6","items":[{"name":"Office Chairs","brands":["Herman Miller","Steelcase","Ergohuman","Autonomous","Secretlab","Branch","Haworth","Hon"]},{"name":"Desks","brands":["IKEA","Uplift","Jarvis","FlexiSpot","Branch","Fully","Sauder","Bush Furniture"]},{"name":"Sofas","brands":["West Elm","Article","Joybird","IKEA","Pottery Barn","Wayfair","La-Z-Boy","Crate \u0026 Barrel"]},{"name":"Dining Tables","brands":["West Elm","Pottery Barn","IKEA","Wayfair","Crate \u0026 Barrel","Floyd","Castlery","Rove Concepts"]},{"name":"Mattresses","brands":["Casper","Purple","Tempur-Pedic","Nectar","Saatva","Helix","Tuft \u0026 Needle","Sealy"]},{"name":"Bookshelves","brands":["IKEA","West Elm","Wayfair","CB2","Crate \u0026 Barrel","Pottery Barn","Target","Sauder"]},{"name":"Coffee Tables","brands":["West Elm","IKEA","Wayfair","CB2","Article","Pottery Barn","Target","Floyd"]},{"name":"Bed Frames","brands":["Zinus","Thuma","IKEA","West Elm","Tuft \u0026 Needle","Wayfair","Casper","Floyd"]}]},{"id":"office","name":"Office Supplies","color":"#06b6d4","items":[{"name":"Paper Shredders","brands":["Fellowes","AmazonBasics","Aurora","Bonsaii","Swingline","Royal","Sentinel","GBC"]},{"name":"Label Printers","brands":["Dymo","Brother","Rollo","Munbyn","Phomemo","Zebra","Epson","Arkscan"]},{"name":"Staplers","brands":["Swingline","Bostitch","Paper Mate","Rapid","Rexel","Maped","Officemate","AmazonBasics"]},{"name":"Notebooks","brands":["Moleskine","Leuchtturm1917","Rhodia","Field Notes","Rocketbook","Clairefontaine","Paperchase","Oxford"]},{"name":"Pens","brands":["Pilot","Uni-ball","Pentel","Zebra","Parker","Lamy","Montblanc","Sharpie"]},{"name":"Whiteboards","brands":["Quartet","UBrands","Maxtek","Viz-Pro","Audio-Visual Direct","BoardGeeks","Lockways","AmazonBasics"]},{"name":"Desk Organizers","brands":["Rolodex","Jerry \u0026 Maggie","Simple Trending","Mind Reader","DecoBros","AmazonBasics","Safco","Deli"]},{"name":"Calculators","brands":["Texas Instruments","Casio","HP","Sharp","Canon","Citizen","Victor","Datexx"]}]},{"id":"tools","name":"Tools \u0026 Hardware","color":"#f97316","items":[{"name":"Power Drills","brands":["DeWalt","Milwaukee","Makita","Bosch","Ryobi","Black+Decker","Porter-Cable","Craftsman"]},{"name":"Screwdriver Sets","brands":["Wera","Wiha","Klein Tools","Craftsman","Stanley","DeWalt","Milwaukee","Gearwrench"]},{"name":"Hand Tool Sets","brands":["Stanley","Craftsman","DeWalt","Workpro","Crescent","Husky","Kobalt","Gearwrench"]},{"name":"Tape Measures","brands":["Stanley","Lufkin","Milwaukee","Komelon","Craftsman","DeWalt","Tajima","Starrett"]},{"name":"Hammers","brands":["Estwing","Stanley","Stiletto","Vaughan","Milwaukee","DeWalt","Craftsman","IRWIN"]},{"name":"Wrenches","brands":["Gearwrench","Crescent","Tekton","Craftsman","Milwaukee","DeWalt","Stanley","Proto"]},{"name":"Pliers","brands":["Knipex","Channellock","Klein Tools","IRWIN","Milwaukee","DeWalt","Stanley","Crescent"]},{"name":"Utility Knives","brands":["Stanley","OLFA","MilwaukLine truncated
|
||||
|
||||
let currentStep = 1;
|
||||
let selectedCategory = null;
|
||||
let selectedItem = null;
|
||||
let selectedBrand = null;
|
||||
|
||||
|
||||
const screenCategory = document.getElementById('screen-category');
|
||||
const screenItem = document.getElementById('screen-item');
|
||||
const screenBrand = document.getElementById('screen-brand');
|
||||
|
||||
const categoryGrid = document.getElementById('category-grid-container');
|
||||
const itemGrid = document.getElementById('item-grid-container');
|
||||
const brandGrid = document.getElementById('brand-grid-container');
|
||||
|
||||
const inputCategory = document.getElementById('input-category');
|
||||
const inputItem = document.getElementById('input-item');
|
||||
const inputBrand = document.getElementById('input-brand');
|
||||
|
||||
const wizardForm = document.getElementById('wizard-form');
|
||||
const backBtnWrapper = document.getElementById('wizard-back-wrapper');
|
||||
const backBtn = document.getElementById('btn-wizard-back');
|
||||
|
||||
|
||||
const step1 = document.getElementById('progress-step-1');
|
||||
const step2 = document.getElementById('progress-step-2');
|
||||
const step3 = document.getElementById('progress-step-3');
|
||||
|
||||
const line1 = document.getElementById('progress-line-1');
|
||||
const line2 = document.getElementById('progress-line-2');
|
||||
|
||||
|
||||
function initWizard() {
|
||||
categoryGrid.innerHTML = '';
|
||||
|
||||
catalog.forEach(cat => {
|
||||
|
||||
const color = cat.color || '#d97706';
|
||||
|
||||
|
||||
const r = parseInt(color.slice(1, 3), 16);
|
||||
const g = parseInt(color.slice(3, 5), 16);
|
||||
const b = parseInt(color.slice(5, 7), 16);
|
||||
|
||||
const card = document.createElement('div');
|
||||
card.className = 'category-card';
|
||||
card.style.setProperty('--cat-color', color);
|
||||
card.style.setProperty('--cat-color-bg', `rgba(${r}, ${g}, ${b}, 0.04)`);
|
||||
card.style.setProperty('--cat-color-badge-bg', `rgba(${r}, ${g}, ${b}, 0.1)`);
|
||||
|
||||
|
||||
const initial = cat.name.charAt(0);
|
||||
card.innerHTML = `
|
||||
<div class="category-badge">${initial}</div>
|
||||
<div class="category-name">${cat.name}</div>
|
||||
`;
|
||||
|
||||
card.addEventListener('click', () => {
|
||||
selectCategory(cat);
|
||||
});
|
||||
|
||||
categoryGrid.appendChild(card);
|
||||
});
|
||||
|
||||
|
||||
const otherCard = document.createElement('div');
|
||||
otherCard.className = 'category-card';
|
||||
otherCard.style.setProperty('--cat-color', 'var(--color-text-muted)');
|
||||
otherCard.style.setProperty('--cat-color-bg', 'var(--color-bg-base)');
|
||||
otherCard.style.setProperty('--cat-color-badge-bg', 'var(--color-border)');
|
||||
otherCard.style.borderStyle = 'dashed';
|
||||
otherCard.style.borderWidth = '2px';
|
||||
otherCard.innerHTML = `
|
||||
<div class="category-badge" style="font-weight: 500;">+</div>
|
||||
<div class="category-name">Other / Unlisted</div>
|
||||
`;
|
||||
otherCard.addEventListener('click', () => {
|
||||
selectCategory({ id: 'Other', name: 'Other', items: [] });
|
||||
});
|
||||
categoryGrid.appendChild(otherCard);
|
||||
}
|
||||
|
||||
|
||||
function selectCategory(cat) {
|
||||
selectedCategory = cat.id;
|
||||
inputCategory.value = cat.id;
|
||||
|
||||
if (cat.id === 'Other') {
|
||||
|
||||
inputItem.value = 'Other';
|
||||
inputBrand.value = 'Other';
|
||||
wizardForm.submit();
|
||||
return;
|
||||
}
|
||||
|
||||
renderItems(cat);
|
||||
goToStep(2);
|
||||
}
|
||||
|
||||
|
||||
function renderItems(cat) {
|
||||
const heading = document.getElementById('item-screen-heading');
|
||||
heading.textContent = `What kind of ${cat.name.toLowerCase()} is it?`;
|
||||
|
||||
itemGrid.innerHTML = '';
|
||||
|
||||
cat.items.forEach(item => {
|
||||
const btn = document.createElement('button');
|
||||
btn.type = 'button';
|
||||
btn.className = 'pill-button';
|
||||
btn.innerHTML = `
|
||||
<span>${item.name}</span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />
|
||||
</svg>
|
||||
`;
|
||||
|
||||
btn.addEventListener('click', () => {
|
||||
selectItem(cat, item);
|
||||
});
|
||||
|
||||
itemGrid.appendChild(btn);
|
||||
});
|
||||
|
||||
|
||||
const otherBtn = document.createElement('button');
|
||||
otherBtn.type = 'button';
|
||||
otherBtn.className = 'pill-button other-pill';
|
||||
otherBtn.innerHTML = `
|
||||
<span>Other Item</span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
|
||||
</svg>
|
||||
`;
|
||||
otherBtn.addEventListener('click', () => {
|
||||
selectItem(cat, { name: 'Other', brands: [] });
|
||||
});
|
||||
itemGrid.appendChild(otherBtn);
|
||||
}
|
||||
|
||||
|
||||
function selectItem(cat, item) {
|
||||
selectedItem = item.name;
|
||||
inputItem.value = item.name;
|
||||
|
||||
if (item.name === 'Other') {
|
||||
|
||||
inputBrand.value = 'Other';
|
||||
wizardForm.submit();
|
||||
return;
|
||||
}
|
||||
|
||||
renderBrands(item);
|
||||
goToStep(3);
|
||||
}
|
||||
|
||||
|
||||
function renderBrands(item) {
|
||||
const heading = document.getElementById('brand-screen-heading');
|
||||
heading.textContent = `What brand is the ${item.name.toLowerCase()}?`;
|
||||
|
||||
brandGrid.innerHTML = '';
|
||||
|
||||
item.brands.forEach(brand => {
|
||||
const btn = document.createElement('button');
|
||||
btn.type = 'button';
|
||||
btn.className = 'pill-button';
|
||||
btn.innerHTML = `
|
||||
<span>${brand}</span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor">
|
||||
<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>
|
||||
`;
|
||||
|
||||
btn.addEventListener('click', () => {
|
||||
selectBrand(brand);
|
||||
});
|
||||
|
||||
brandGrid.appendChild(btn);
|
||||
});
|
||||
|
||||
|
||||
const otherBtn = document.createElement('button');
|
||||
otherBtn.type = 'button';
|
||||
otherBtn.className = 'pill-button other-pill';
|
||||
otherBtn.innerHTML = `
|
||||
<span>Other Brand</span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
|
||||
</svg>
|
||||
`;
|
||||
otherBtn.addEventListener('click', () => {
|
||||
selectBrand('Other');
|
||||
});
|
||||
brandGrid.appendChild(otherBtn);
|
||||
}
|
||||
|
||||
|
||||
function selectBrand(brand) {
|
||||
selectedBrand = brand;
|
||||
inputBrand.value = brand;
|
||||
|
||||
|
||||
wizardForm.submit();
|
||||
}
|
||||
|
||||
|
||||
function goToStep(step) {
|
||||
currentStep = step;
|
||||
|
||||
|
||||
screenCategory.classList.remove('active');
|
||||
screenItem.classList.remove('active');
|
||||
screenBrand.classList.remove('active');
|
||||
|
||||
|
||||
step1.className = 'wizard-step';
|
||||
step2.className = 'wizard-step';
|
||||
step3.className = 'wizard-step';
|
||||
|
||||
line1.className = 'wizard-line';
|
||||
line2.className = 'wizard-line';
|
||||
|
||||
if (step === 1) {
|
||||
screenCategory.classList.add('active');
|
||||
step1.classList.add('active');
|
||||
backBtnWrapper.style.display = 'none';
|
||||
} else if (step === 2) {
|
||||
screenItem.classList.add('active');
|
||||
step1.classList.add('completed');
|
||||
step2.classList.add('active');
|
||||
line1.classList.add('completed');
|
||||
backBtnWrapper.style.display = 'block';
|
||||
} else if (step === 3) {
|
||||
screenBrand.classList.add('active');
|
||||
step1.classList.add('completed');
|
||||
step2.classList.add('completed');
|
||||
step3.classList.add('active');
|
||||
line1.classList.add('completed');
|
||||
line2.classList.add('completed');
|
||||
backBtnWrapper.style.display = 'block';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
backBtn.addEventListener('click', () => {
|
||||
if (currentStep > 1) {
|
||||
goToStep(currentStep - 1);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
initWizard();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
</main>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="toast-container">
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"Solis/internal/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cat, err := config.LoadCatalog("../catalog.json")
|
||||
if err != nil {
|
||||
log.Fatalf("Error: %v", err)
|
||||
}
|
||||
fmt.Printf("Loaded %d categories\n", len(cat))
|
||||
}
|
||||
Reference in new issue
Block a user