Add i18n framework with English and Chinese support
Introduce an embedded-locale i18n package exposing a T() template function. UI strings across all templates and catalog category/item names are now translatable via locale JSON files, selectable through the new server.language config option. Falls back to English when a locale is missing or fails to load. Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
1 parent
5e82e32491
commit
ff1d1fc490
16 files changed
+1161
-318
No files matched your search
@@ -5,6 +5,9 @@ port = 8889
|
||||
base_url = "http://localhost:8889"
|
||||
read_timeout = "5s"
|
||||
write_timeout = "10s"
|
||||
# Language for the UI. Supported: "en" (English), "zh" (Chinese).
|
||||
# Add new languages by creating a JSON file in internal/i18n/locales/.
|
||||
language = "en"
|
||||
|
||||
[admin]
|
||||
username = "admin"
|
||||
|
||||
@@ -21,6 +21,7 @@ type ServerConfig struct {
|
||||
BaseURL string `toml:"base_url"`
|
||||
ReadTimeout string `toml:"read_timeout"`
|
||||
WriteTimeout string `toml:"write_timeout"`
|
||||
Language string `toml:"language"`
|
||||
}
|
||||
|
||||
type AdminConfig struct {
|
||||
@@ -65,6 +66,7 @@ func Load(path string) (*Config, error) {
|
||||
BaseURL: "http://localhost:8889",
|
||||
ReadTimeout: "5s",
|
||||
WriteTimeout: "10s",
|
||||
Language: "en",
|
||||
},
|
||||
Admin: AdminConfig{
|
||||
Username: "admin",
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package i18n
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
//go:embed locales
|
||||
var localesFS embed.FS
|
||||
|
||||
type Translator struct {
|
||||
lang string
|
||||
messages map[string]string
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
func New(lang string) (*Translator, error) {
|
||||
if lang == "" {
|
||||
lang = "en"
|
||||
}
|
||||
|
||||
t := &Translator{
|
||||
lang: lang,
|
||||
messages: make(map[string]string),
|
||||
}
|
||||
|
||||
data, err := localesFS.ReadFile(fmt.Sprintf("locales/%s.json", lang))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("loading locale %s: %w", lang, err)
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(data, &t.messages); err != nil {
|
||||
return nil, fmt.Errorf("parsing locale %s: %w", lang, err)
|
||||
}
|
||||
|
||||
return t, nil
|
||||
}
|
||||
|
||||
func (t *Translator) T(key string) string {
|
||||
t.mu.RLock()
|
||||
defer t.mu.RUnlock()
|
||||
if msg, ok := t.messages[key]; ok {
|
||||
return msg
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
func (t *Translator) TF(key string, args ...string) string {
|
||||
msg := t.T(key)
|
||||
for _, arg := range args {
|
||||
msg = strings.Replace(msg, "%s", arg, 1)
|
||||
}
|
||||
return msg
|
||||
}
|
||||
|
||||
func (t *Translator) Lang() string {
|
||||
return t.lang
|
||||
}
|
||||
@@ -0,0 +1,367 @@
|
||||
{
|
||||
"app.title": "Solis | Home Assets",
|
||||
"app.title.assets": "Solis | Assets",
|
||||
"app.title.tags": "Solis | Tags",
|
||||
"app.title.locations": "Solis | Locations",
|
||||
"app.title.shortlinks": "Solis | Shortlinks",
|
||||
"app.title.print": "Solis | Print Labels",
|
||||
"app.title.login": "Solis | Sign In",
|
||||
|
||||
"nav.assets": "Assets",
|
||||
"nav.locations": "Locations",
|
||||
"nav.tags": "Tags",
|
||||
"nav.shortlinks": "Shortlinks",
|
||||
"nav.print_labels": "Print Labels",
|
||||
"nav.sign_out": "Sign Out",
|
||||
"nav.admin_login": "Admin Login",
|
||||
|
||||
"common.cancel": "Cancel",
|
||||
"common.save": "Save Changes",
|
||||
"common.edit": "Edit",
|
||||
"common.delete": "Delete",
|
||||
"common.restore": "Restore",
|
||||
"common.delete_forever": "Delete Forever",
|
||||
"common.remove": "Remove",
|
||||
"common.archive": "Archive",
|
||||
"common.filter": "Filter",
|
||||
"common.reset": "Reset",
|
||||
"common.details": "Details",
|
||||
"common.locked": "Locked",
|
||||
"common.archived": "Archived",
|
||||
"common.root": "Root",
|
||||
"common.description": "Description",
|
||||
"common.actions": "Actions",
|
||||
"common.name": "Name",
|
||||
"common.back": "Back",
|
||||
"common.show_removed": "Show removed",
|
||||
"common.unassigned": "Unassigned",
|
||||
|
||||
"login.title": "Sign in to your assets",
|
||||
"login.subtitle": "Enter your administrator credentials below",
|
||||
"login.username": "Username",
|
||||
"login.password": "Password",
|
||||
"login.submit": "Sign In",
|
||||
|
||||
"items.title": "Asset Inventory",
|
||||
"items.subtitle": "Track, manage, and label your home equipment and tools.",
|
||||
"items.add": "Add Asset",
|
||||
"items.search_placeholder": "Search by asset name, model, serial number...",
|
||||
"items.all_statuses": "-- All Statuses --",
|
||||
"items.all_locations": "-- All Locations --",
|
||||
"items.all_tags": "-- All Tags --",
|
||||
"items.col.qr": "QR Label",
|
||||
"items.col.name": "Name",
|
||||
"items.col.location": "Location",
|
||||
"items.col.status": "Status",
|
||||
"items.col.quantity": "Quantity",
|
||||
"items.col.tags": "Tags",
|
||||
"items.empty.title": "No assets found",
|
||||
"items.empty.subtitle": "Try refining your filters or click \"Add Asset\" to start tracking equipment.",
|
||||
"items.remove_item": "Remove Item",
|
||||
"items.archive_item": "Archive Item",
|
||||
"items.confirm_delete": "Are you sure you want to permanently delete this asset? This will clean up all associated media files on disk and cannot be undone.",
|
||||
"items.model_prefix": "Model",
|
||||
|
||||
"items.detail.title": "Asset Details",
|
||||
"items.detail.edit": "Edit Asset",
|
||||
"items.detail.back_list": "Back to List",
|
||||
"items.detail.back_dir": "Back to Directory",
|
||||
"items.detail.description": "Description",
|
||||
"items.detail.no_description": "No description provided for this asset.",
|
||||
"items.detail.quantity": "Quantity",
|
||||
"items.detail.model_number": "Model Number",
|
||||
"items.detail.serial_number": "Serial Number",
|
||||
"items.detail.photo": "Asset Photo",
|
||||
"items.detail.no_photo": "No Photo Attached",
|
||||
"items.detail.receipt": "Receipt / Invoice",
|
||||
"items.detail.no_receipt": "No Receipt Document",
|
||||
"items.detail.open_doc": "Open Document",
|
||||
"items.detail.custom_fields": "Custom Asset Metadata",
|
||||
"items.detail.no_custom": "No custom metadata fields defined for this asset.",
|
||||
"items.detail.qr": "Asset Label QR Code",
|
||||
"items.detail.download_qr": "Download Label Image",
|
||||
"items.detail.no_short_url": "No short URL associated.",
|
||||
"items.detail.purchase_context": "Purchase Context",
|
||||
"items.detail.purchase_price": "Purchase Price",
|
||||
"items.detail.supplier": "Supplier / Dealer",
|
||||
"items.detail.purchase_date": "Purchase Date",
|
||||
"items.detail.warranty_period": "Warranty Period",
|
||||
"items.detail.months": "Months",
|
||||
"items.detail.assigned_location": "Assigned Location",
|
||||
|
||||
"items.edit.title_prefix": "Edit Asset",
|
||||
"items.edit.subtitle": "Define inventory items, upload documentation, and generate automated QR codes.",
|
||||
"items.edit.basic_info": "Basic Information",
|
||||
"items.edit.asset_name": "Asset Name",
|
||||
"items.edit.quantity": "Quantity",
|
||||
"items.edit.description": "Description",
|
||||
"items.edit.model_number": "Model Number",
|
||||
"items.edit.serial_number": "Serial Number",
|
||||
"items.edit.status": "Status",
|
||||
"items.edit.location": "Location",
|
||||
"items.edit.tags": "Tags / Categories",
|
||||
"items.edit.purchase_warranty": "Purchase & Warranty",
|
||||
"items.edit.purchase_price": "Purchase Price ($)",
|
||||
"items.edit.purchase_date": "Purchase Date",
|
||||
"items.edit.warranty_months": "Warranty (Months)",
|
||||
"items.edit.supplier": "Supplier / Store",
|
||||
"items.edit.docs_visuals": "Documentation & Visuals",
|
||||
"items.edit.photo": "Item Photo",
|
||||
"items.edit.active_image": "Active Image",
|
||||
"items.edit.receipt": "Receipt / Invoice Document",
|
||||
"items.edit.active_receipt": "Active Receipt",
|
||||
"items.edit.custom_fields": "Custom Fields",
|
||||
"items.edit.custom_fields_help": "Enter custom parameters one per line as Key: Value (e.g. Battery: 18v Lithium). These will be parsed into indexed SQLite JSON dynamically.",
|
||||
"items.edit.custom_fields_editor": "Custom Fields Editor",
|
||||
|
||||
"status.in_use": "In Use",
|
||||
"status.in_storage": "In Storage",
|
||||
"status.borrowed": "Borrowed",
|
||||
"status.lost": "Lost",
|
||||
"status.disposed": "Disposed",
|
||||
|
||||
"wizard.title": "Add New Asset",
|
||||
"wizard.subtitle": "Catalog any device, appliance, or item in seconds using our intuitive selection wizard.",
|
||||
"wizard.step_category": "Category",
|
||||
"wizard.step_item": "Item",
|
||||
"wizard.step_brand": "Brand",
|
||||
"wizard.category_question": "Which category of item do you want to add?",
|
||||
"wizard.item_question": "What kind of %s is it?",
|
||||
"wizard.brand_question": "What brand is the %s?",
|
||||
"wizard.other_unlisted": "Other / Unlisted",
|
||||
"wizard.other_item": "Other Item",
|
||||
"wizard.other_brand": "Other Brand",
|
||||
"wizard.back": "Back to previous step",
|
||||
"wizard.asset_suffix": "Asset",
|
||||
"wizard.new_asset": "New Asset",
|
||||
"wizard.auto_tag_desc": "Auto-created from catalog category",
|
||||
"wizard.auto_desc": "Automatically cataloged via Wizard: %s > %s > %s",
|
||||
|
||||
"tags.title": "Tags",
|
||||
"tags.subtitle": "Label and categorize assets to easily group similar items together (e.g. Tools, Electronics, Fragile)",
|
||||
"tags.col.tag": "Tag",
|
||||
"tags.col.color": "Color Hex",
|
||||
"tags.empty": "No tags defined yet. Add one on the right to get started!",
|
||||
"tags.show_removed": "Show removed tags",
|
||||
"tags.edit_tag": "Edit Tag",
|
||||
"tags.create_tag": "Create Tag",
|
||||
"tags.tag_name": "Tag Name",
|
||||
"tags.tag_color": "Tag Color",
|
||||
"tags.add_tag": "Add Tag",
|
||||
"tags.confirm_delete": "Are you sure you want to permanently delete this tag? All associated items will lose this tag reference.",
|
||||
|
||||
"locations.title": "Locations",
|
||||
"locations.subtitle": "Define physical areas and hierarchical storage places (e.g., House > Kitchen > Drawer A)",
|
||||
"locations.col.name": "Name",
|
||||
"locations.col.parent": "Parent Path",
|
||||
"locations.empty": "No locations defined yet. Add one on the right to get started!",
|
||||
"locations.show_removed": "Show removed locations",
|
||||
"locations.edit_location": "Edit Location",
|
||||
"locations.create_location": "Create Location",
|
||||
"locations.location_name": "Location Name",
|
||||
"locations.parent_location": "Parent Location (Optional)",
|
||||
"locations.none_root": "-- None (Root Location) --",
|
||||
"locations.add_location": "Add Location",
|
||||
"locations.confirm_delete": "Are you sure you want to permanently delete this location? Associated sub-locations and assets will be detached.",
|
||||
|
||||
"folder.home": "Home",
|
||||
"folder.show_removed": "Show removed items",
|
||||
"folder.edit_location": "Edit Location",
|
||||
"folder.add_asset_here": "Add Asset Here",
|
||||
"folder.drag_up": "Drag items or folders here to move up to the parent directory",
|
||||
"folder.folders": "Folders",
|
||||
"folder.no_subfolders": "No sub-folders in this location.",
|
||||
"folder.state.removed": "Removed",
|
||||
"folder.state.archived": "Archived",
|
||||
"folder.state.active": "Active",
|
||||
"folder.edit_folder": "Edit Folder",
|
||||
"folder.restore_folder": "Restore Folder",
|
||||
"folder.confirm_delete_location": "Are you sure you want to permanently delete this location? All items inside will be moved to the Default Room.",
|
||||
"folder.delete_permanently": "Delete Permanently",
|
||||
"folder.archive_folder": "Archive Folder",
|
||||
"folder.remove_folder": "Remove Folder",
|
||||
"folder.assets": "Assets",
|
||||
"folder.no_assets": "No assets found in this location.",
|
||||
"folder.qty": "Qty",
|
||||
"folder.edit_asset": "Edit Asset",
|
||||
"folder.show_qr": "Show QR Code",
|
||||
"folder.restore_asset": "Restore Asset",
|
||||
"folder.confirm_delete_asset": "Are you sure you want to permanently delete this asset? This cannot be undone.",
|
||||
"folder.archive_asset": "Archive Asset",
|
||||
"folder.remove_asset": "Remove Asset",
|
||||
|
||||
"shortener.title": "URL Shortener",
|
||||
"shortener.subtitle": "Manage custom manual redirects (e.g. warranties, external manuals) or review auto-generated asset short URLs.",
|
||||
"shortener.show_removed": "Show removed links",
|
||||
"shortener.col.slug": "Slug",
|
||||
"shortener.col.target_url": "Target URL",
|
||||
"shortener.col.link_type": "Link Type",
|
||||
"shortener.col.clicks": "Clicks",
|
||||
"shortener.view_qr": "View QR Code",
|
||||
"shortener.asset_link": "Asset Link",
|
||||
"shortener.manual_redirect": "Manual Redirect",
|
||||
"shortener.managed_by_asset": "Managed by Asset",
|
||||
"shortener.confirm_delete": "Are you sure you want to permanently delete this redirect? This action cannot be undone.",
|
||||
"shortener.empty": "No short links recorded. Create a custom redirect on the right!",
|
||||
"shortener.edit_redirect": "Edit Redirect",
|
||||
"shortener.short_slug": "Short Slug",
|
||||
"shortener.target_url": "Target Destination URL",
|
||||
"shortener.create_redirect": "Create Redirect",
|
||||
"shortener.custom_slug": "Custom Slug (Optional)",
|
||||
"shortener.auto": "Auto",
|
||||
"shortener.slug_hint": "Leave blank to generate a random 4-character slug.",
|
||||
"shortener.destination_url": "Destination URL",
|
||||
"shortener.add_redirect": "Add Redirect",
|
||||
"shortener.slug_length_title": "URL Slug Length",
|
||||
"shortener.slug_length_desc": "Controls the character length of auto-generated short URL slugs. Shorter slugs make smaller QR codes. Changes apply to newly created assets only.",
|
||||
"shortener.characters": "characters",
|
||||
|
||||
"print.title": "Printable QR Labels",
|
||||
"print.subtitle": "Generate high-fidelity label sheets for your inventory. Press Ctrl + P (or Cmd + P) to print sticker sheets. Standard print stylesheets are auto-applied.",
|
||||
"print.print_sheet": "Print Sheet",
|
||||
"print.back_to_assets": "Back to Assets",
|
||||
"print.guidelines_title": "Printing Guidelines",
|
||||
"print.guideline_margins": "Set your margins to None or Minimum in the browser print dialogue.",
|
||||
"print.guideline_graphics": "Enable Background graphics to preserve borders and alignments.",
|
||||
"print.guideline_size": "Check the layout preview page size (standard Letter/A4) to ensure grid alignment on your sticker paper.",
|
||||
"print.empty": "No items with active short links found. Create an asset to generate labels!",
|
||||
|
||||
"qr.preview": "QR Code Preview",
|
||||
"qr.download": "Download QR Image",
|
||||
|
||||
"Tech & Electronics": "Tech & Electronics",
|
||||
"Kitchen Appliances": "Kitchen Appliances",
|
||||
"Furniture": "Furniture",
|
||||
"Office Supplies": "Office Supplies",
|
||||
"Tools & Hardware": "Tools & Hardware",
|
||||
"Fitness & Sports": "Fitness & Sports",
|
||||
"Home Entertainment": "Home Entertainment",
|
||||
"Gardening & Outdoor": "Gardening & Outdoor",
|
||||
"Lighting & Lamps": "Lighting & Lamps",
|
||||
"Cleaning & Laundry": "Cleaning & Laundry",
|
||||
"Smart Home Devices": "Smart Home Devices",
|
||||
"Books & Stationery": "Books & Stationery",
|
||||
"Security & Safety": "Security & Safety",
|
||||
"Storage & Organization": "Storage & Organization",
|
||||
"Audio & Instruments": "Audio & Instruments",
|
||||
|
||||
"Smartphones": "Smartphones",
|
||||
"Laptops": "Laptops",
|
||||
"Tablets": "Tablets",
|
||||
"Smartwatches": "Smartwatches",
|
||||
"Desktop Computers": "Desktop Computers",
|
||||
"Computer Monitors": "Computer Monitors",
|
||||
"Keyboards": "Keyboards",
|
||||
"Computer Mice": "Computer Mice",
|
||||
"Coffee Makers": "Coffee Makers",
|
||||
"Blenders": "Blenders",
|
||||
"Toasters": "Toasters",
|
||||
"Microwaves": "Microwaves",
|
||||
"Air Fryers": "Air Fryers",
|
||||
"Food Processors": "Food Processors",
|
||||
"Juicers": "Juicers",
|
||||
"Rice Cookers": "Rice Cookers",
|
||||
"Office Chairs": "Office Chairs",
|
||||
"Desks": "Desks",
|
||||
"Sofas": "Sofas",
|
||||
"Dining Tables": "Dining Tables",
|
||||
"Mattresses": "Mattresses",
|
||||
"Bookshelves": "Bookshelves",
|
||||
"Coffee Tables": "Coffee Tables",
|
||||
"Bed Frames": "Bed Frames",
|
||||
"Paper Shredders": "Paper Shredders",
|
||||
"Label Printers": "Label Printers",
|
||||
"Staplers": "Staplers",
|
||||
"Notebooks": "Notebooks",
|
||||
"Pens": "Pens",
|
||||
"Whiteboards": "Whiteboards",
|
||||
"Desk Organizers": "Desk Organizers",
|
||||
"Calculators": "Calculators",
|
||||
"Power Drills": "Power Drills",
|
||||
"Screwdriver Sets": "Screwdriver Sets",
|
||||
"Hand Tool Sets": "Hand Tool Sets",
|
||||
"Tape Measures": "Tape Measures",
|
||||
"Hammers": "Hammers",
|
||||
"Wrenches": "Wrenches",
|
||||
"Pliers": "Pliers",
|
||||
"Utility Knives": "Utility Knives",
|
||||
"Treadmills": "Treadmills",
|
||||
"Exercise Bikes": "Exercise Bikes",
|
||||
"Dumbbells": "Dumbbells",
|
||||
"Yoga Mats": "Yoga Mats",
|
||||
"Resistance Bands": "Resistance Bands",
|
||||
"Fitness Trackers": "Fitness Trackers",
|
||||
"Kettlebells": "Kettlebells",
|
||||
"Foam Rollers": "Foam Rollers",
|
||||
"Televisions": "Televisions",
|
||||
"Soundbars": "Soundbars",
|
||||
"Streaming Devices": "Streaming Devices",
|
||||
"Projectors": "Projectors",
|
||||
"VR Headsets": "VR Headsets",
|
||||
"Game Consoles": "Game Consoles",
|
||||
"DVD/Blu-ray Players": "DVD/Blu-ray Players",
|
||||
"Remote Controls": "Remote Controls",
|
||||
"Lawn Mowers": "Lawn Mowers",
|
||||
"Leaf Blowers": "Leaf Blowers",
|
||||
"Pruning Shears": "Pruning Shears",
|
||||
"Garden Hoses": "Garden Hoses",
|
||||
"Watering Cans": "Watering Cans",
|
||||
"Wheelbarrows": "Wheelbarrows",
|
||||
"Weed Eaters": "Weed Eaters",
|
||||
"Patio Heaters": "Patio Heaters",
|
||||
"Desk Lamps": "Desk Lamps",
|
||||
"Floor Lamps": "Floor Lamps",
|
||||
"Smart Bulbs": "Smart Bulbs",
|
||||
"String Lights": "String Lights",
|
||||
"Flashlights": "Flashlights",
|
||||
"Night Lights": "Night Lights",
|
||||
"Ceiling Fans": "Ceiling Fans",
|
||||
"Grow Lights": "Grow Lights",
|
||||
"Vacuum Cleaners": "Vacuum Cleaners",
|
||||
"Steam Mops": "Steam Mops",
|
||||
"Air Purifiers": "Air Purifiers",
|
||||
"Washing Machines": "Washing Machines",
|
||||
"Clothes Dryers": "Clothes Dryers",
|
||||
"Ironing Boards": "Ironing Boards",
|
||||
"Steam Irons": "Steam Irons",
|
||||
"Robot Mops": "Robot Mops",
|
||||
"Smart Speakers": "Smart Speakers",
|
||||
"Smart Thermostats": "Smart Thermostats",
|
||||
"Security Cameras": "Security Cameras",
|
||||
"Smart Doorlocks": "Smart Doorlocks",
|
||||
"Video Doorbells": "Video Doorbells",
|
||||
"Smart Plugs": "Smart Plugs",
|
||||
"Robot Vacuums": "Robot Vacuums",
|
||||
"Smart Displays": "Smart Displays",
|
||||
"Planners": "Planners",
|
||||
"Sketchbooks": "Sketchbooks",
|
||||
"Colored Pencils": "Colored Pencils",
|
||||
"Fountain Pens": "Fountain Pens",
|
||||
"Highlighters": "Highlighters",
|
||||
"Sticky Notes": "Sticky Notes",
|
||||
"Pencil Cases": "Pencil Cases",
|
||||
"Smoke Detectors": "Smoke Detectors",
|
||||
"Fire Extinguishers": "Fire Extinguishers",
|
||||
"Safes": "Safes",
|
||||
"First Aid Kits": "First Aid Kits",
|
||||
"Safety Flashlights": "Safety Flashlights",
|
||||
"Door Barricades": "Door Barricades",
|
||||
"CO Detectors": "CO Detectors",
|
||||
"Motion Sensors": "Motion Sensors",
|
||||
"Plastic Bins": "Plastic Bins",
|
||||
"Storage Racks": "Storage Racks",
|
||||
"Shoe Racks": "Shoe Racks",
|
||||
"Closet Organizers": "Closet Organizers",
|
||||
"Food Containers": "Food Containers",
|
||||
"Hangers": "Hangers",
|
||||
"Cable Organizers": "Cable Organizers",
|
||||
"Toolboxes": "Toolboxes",
|
||||
"Headphones": "Headphones",
|
||||
"Microphones": "Microphones",
|
||||
"Bluetooth Speakers": "Bluetooth Speakers",
|
||||
"Keyboards & Pianos": "Keyboards & Pianos",
|
||||
"Guitars": "Guitars",
|
||||
"Audio Interfaces": "Audio Interfaces",
|
||||
"Studio Monitors": "Studio Monitors",
|
||||
"Turntables": "Turntables"
|
||||
}
|
||||
@@ -0,0 +1,367 @@
|
||||
{
|
||||
"app.title": "Solis | 家庭资产",
|
||||
"app.title.assets": "Solis | 资产",
|
||||
"app.title.tags": "Solis | 标签",
|
||||
"app.title.locations": "Solis | 位置",
|
||||
"app.title.shortlinks": "Solis | 短链接",
|
||||
"app.title.print": "Solis | 打印标签",
|
||||
"app.title.login": "Solis | 登录",
|
||||
|
||||
"nav.assets": "资产",
|
||||
"nav.locations": "位置",
|
||||
"nav.tags": "标签",
|
||||
"nav.shortlinks": "短链接",
|
||||
"nav.print_labels": "打印标签",
|
||||
"nav.sign_out": "退出登录",
|
||||
"nav.admin_login": "管理员登录",
|
||||
|
||||
"common.cancel": "取消",
|
||||
"common.save": "保存更改",
|
||||
"common.edit": "编辑",
|
||||
"common.delete": "删除",
|
||||
"common.restore": "恢复",
|
||||
"common.delete_forever": "永久删除",
|
||||
"common.remove": "移除",
|
||||
"common.archive": "归档",
|
||||
"common.filter": "筛选",
|
||||
"common.reset": "重置",
|
||||
"common.details": "详情",
|
||||
"common.locked": "已锁定",
|
||||
"common.archived": "已归档",
|
||||
"common.root": "根目录",
|
||||
"common.description": "描述",
|
||||
"common.actions": "操作",
|
||||
"common.name": "名称",
|
||||
"common.back": "返回",
|
||||
"common.show_removed": "显示已移除",
|
||||
"common.unassigned": "未分配",
|
||||
|
||||
"login.title": "登录您的资产管理系统",
|
||||
"login.subtitle": "请输入管理员凭据",
|
||||
"login.username": "用户名",
|
||||
"login.password": "密码",
|
||||
"login.submit": "登录",
|
||||
|
||||
"items.title": "资产清单",
|
||||
"items.subtitle": "追踪、管理和标记您的家庭设备和工具。",
|
||||
"items.add": "添加资产",
|
||||
"items.search_placeholder": "按资产名称、型号、序列号搜索...",
|
||||
"items.all_statuses": "-- 所有状态 --",
|
||||
"items.all_locations": "-- 所有位置 --",
|
||||
"items.all_tags": "-- 所有标签 --",
|
||||
"items.col.qr": "二维码",
|
||||
"items.col.name": "名称",
|
||||
"items.col.location": "位置",
|
||||
"items.col.status": "状态",
|
||||
"items.col.quantity": "数量",
|
||||
"items.col.tags": "标签",
|
||||
"items.empty.title": "未找到资产",
|
||||
"items.empty.subtitle": "请调整筛选条件,或点击「添加资产」开始记录设备。",
|
||||
"items.remove_item": "移除资产",
|
||||
"items.archive_item": "归档资产",
|
||||
"items.confirm_delete": "确定要永久删除此资产吗?这将清除磁盘上所有相关媒体文件且无法撤销。",
|
||||
"items.model_prefix": "型号",
|
||||
|
||||
"items.detail.title": "资产详情",
|
||||
"items.detail.edit": "编辑资产",
|
||||
"items.detail.back_list": "返回列表",
|
||||
"items.detail.back_dir": "返回目录",
|
||||
"items.detail.description": "描述",
|
||||
"items.detail.no_description": "此资产暂无描述。",
|
||||
"items.detail.quantity": "数量",
|
||||
"items.detail.model_number": "型号",
|
||||
"items.detail.serial_number": "序列号",
|
||||
"items.detail.photo": "资产照片",
|
||||
"items.detail.no_photo": "暂无照片",
|
||||
"items.detail.receipt": "收据 / 发票",
|
||||
"items.detail.no_receipt": "暂无收据文档",
|
||||
"items.detail.open_doc": "打开文档",
|
||||
"items.detail.custom_fields": "自定义资产元数据",
|
||||
"items.detail.no_custom": "此资产未定义自定义元数据字段。",
|
||||
"items.detail.qr": "资产标签二维码",
|
||||
"items.detail.download_qr": "下载标签图片",
|
||||
"items.detail.no_short_url": "暂无关联短链接。",
|
||||
"items.detail.purchase_context": "购买信息",
|
||||
"items.detail.purchase_price": "购买价格",
|
||||
"items.detail.supplier": "供应商 / 经销商",
|
||||
"items.detail.purchase_date": "购买日期",
|
||||
"items.detail.warranty_period": "保修期",
|
||||
"items.detail.months": "个月",
|
||||
"items.detail.assigned_location": "所在位置",
|
||||
|
||||
"items.edit.title_prefix": "编辑资产",
|
||||
"items.edit.subtitle": "定义库存物品、上传文档并生成自动二维码。",
|
||||
"items.edit.basic_info": "基本信息",
|
||||
"items.edit.asset_name": "资产名称",
|
||||
"items.edit.quantity": "数量",
|
||||
"items.edit.description": "描述",
|
||||
"items.edit.model_number": "型号",
|
||||
"items.edit.serial_number": "序列号",
|
||||
"items.edit.status": "状态",
|
||||
"items.edit.location": "位置",
|
||||
"items.edit.tags": "标签 / 分类",
|
||||
"items.edit.purchase_warranty": "购买与保修",
|
||||
"items.edit.purchase_price": "购买价格 ($)",
|
||||
"items.edit.purchase_date": "购买日期",
|
||||
"items.edit.warranty_months": "保修期(月)",
|
||||
"items.edit.supplier": "供应商 / 商店",
|
||||
"items.edit.docs_visuals": "文档与图片",
|
||||
"items.edit.photo": "物品照片",
|
||||
"items.edit.active_image": "当前图片",
|
||||
"items.edit.receipt": "收据 / 发票文档",
|
||||
"items.edit.active_receipt": "当前收据",
|
||||
"items.edit.custom_fields": "自定义字段",
|
||||
"items.edit.custom_fields_help": "每行输入一个自定义参数,格式为 键: 值(例如 电池: 18V锂电池)。这些将被动态解析为 SQLite JSON。",
|
||||
"items.edit.custom_fields_editor": "自定义字段编辑器",
|
||||
|
||||
"status.in_use": "使用中",
|
||||
"status.in_storage": "存放中",
|
||||
"status.borrowed": "已借出",
|
||||
"status.lost": "已丢失",
|
||||
"status.disposed": "已处置",
|
||||
|
||||
"wizard.title": "添加新资产",
|
||||
"wizard.subtitle": "通过直观的选择向导,在几秒钟内将任何设备、电器或物品编入目录。",
|
||||
"wizard.step_category": "分类",
|
||||
"wizard.step_item": "物品",
|
||||
"wizard.step_brand": "品牌",
|
||||
"wizard.category_question": "您要添加哪类物品?",
|
||||
"wizard.item_question": "这是什么类型的%s?",
|
||||
"wizard.brand_question": "%s是什么品牌?",
|
||||
"wizard.other_unlisted": "其他 / 未列出",
|
||||
"wizard.other_item": "其他物品",
|
||||
"wizard.other_brand": "其他品牌",
|
||||
"wizard.back": "返回上一步",
|
||||
"wizard.asset_suffix": "物品",
|
||||
"wizard.new_asset": "新资产",
|
||||
"wizard.auto_tag_desc": "从目录分类自动创建",
|
||||
"wizard.auto_desc": "通过向导自动分类:%s > %s > %s",
|
||||
|
||||
"tags.title": "标签",
|
||||
"tags.subtitle": "标记和分类资产,以便轻松将相似物品分组(如 工具、电子产品、易碎品)",
|
||||
"tags.col.tag": "标签",
|
||||
"tags.col.color": "颜色代码",
|
||||
"tags.empty": "尚未定义标签。在右侧添加一个开始使用!",
|
||||
"tags.show_removed": "显示已移除标签",
|
||||
"tags.edit_tag": "编辑标签",
|
||||
"tags.create_tag": "创建标签",
|
||||
"tags.tag_name": "标签名称",
|
||||
"tags.tag_color": "标签颜色",
|
||||
"tags.add_tag": "添加标签",
|
||||
"tags.confirm_delete": "确定要永久删除此标签吗?所有关联的物品将失去此标签引用。",
|
||||
|
||||
"locations.title": "位置",
|
||||
"locations.subtitle": "定义物理区域和分层存储位置(例如:房屋 > 厨房 > 抽屉A)",
|
||||
"locations.col.name": "名称",
|
||||
"locations.col.parent": "上级路径",
|
||||
"locations.empty": "尚未定义位置。在右侧添加一个开始使用!",
|
||||
"locations.show_removed": "显示已移除位置",
|
||||
"locations.edit_location": "编辑位置",
|
||||
"locations.create_location": "创建位置",
|
||||
"locations.location_name": "位置名称",
|
||||
"locations.parent_location": "上级位置(可选)",
|
||||
"locations.none_root": "-- 无(根位置)--",
|
||||
"locations.add_location": "添加位置",
|
||||
"locations.confirm_delete": "确定要永久删除此位置吗?关联的子位置和资产将被解除关联。",
|
||||
|
||||
"folder.home": "首页",
|
||||
"folder.show_removed": "显示已移除的项目",
|
||||
"folder.edit_location": "编辑位置",
|
||||
"folder.add_asset_here": "在此添加资产",
|
||||
"folder.drag_up": "将物品或文件夹拖到此处以移至上级目录",
|
||||
"folder.folders": "文件夹",
|
||||
"folder.no_subfolders": "此位置没有子文件夹。",
|
||||
"folder.state.removed": "已移除",
|
||||
"folder.state.archived": "已归档",
|
||||
"folder.state.active": "活跃",
|
||||
"folder.edit_folder": "编辑文件夹",
|
||||
"folder.restore_folder": "恢复文件夹",
|
||||
"folder.confirm_delete_location": "确定要永久删除此位置吗?内部所有物品将被移至默认房间。",
|
||||
"folder.delete_permanently": "永久删除",
|
||||
"folder.archive_folder": "归档文件夹",
|
||||
"folder.remove_folder": "移除文件夹",
|
||||
"folder.assets": "资产",
|
||||
"folder.no_assets": "此位置没有找到资产。",
|
||||
"folder.qty": "数量",
|
||||
"folder.edit_asset": "编辑资产",
|
||||
"folder.show_qr": "显示二维码",
|
||||
"folder.restore_asset": "恢复资产",
|
||||
"folder.confirm_delete_asset": "确定要永久删除此资产吗?此操作无法撤销。",
|
||||
"folder.archive_asset": "归档资产",
|
||||
"folder.remove_asset": "移除资产",
|
||||
|
||||
"shortener.title": "短链接管理",
|
||||
"shortener.subtitle": "管理自定义手动重定向(如保修单、外部手册)或查看自动生成的资产短链接。",
|
||||
"shortener.show_removed": "显示已移除链接",
|
||||
"shortener.col.slug": "短码",
|
||||
"shortener.col.target_url": "目标链接",
|
||||
"shortener.col.link_type": "链接类型",
|
||||
"shortener.col.clicks": "点击量",
|
||||
"shortener.view_qr": "查看二维码",
|
||||
"shortener.asset_link": "资产链接",
|
||||
"shortener.manual_redirect": "手动重定向",
|
||||
"shortener.managed_by_asset": "由资产管理",
|
||||
"shortener.confirm_delete": "确定要永久删除此重定向吗?此操作无法撤销。",
|
||||
"shortener.empty": "暂无短链接记录。在右侧创建自定义重定向!",
|
||||
"shortener.edit_redirect": "编辑重定向",
|
||||
"shortener.short_slug": "短码",
|
||||
"shortener.target_url": "目标链接地址",
|
||||
"shortener.create_redirect": "创建重定向",
|
||||
"shortener.custom_slug": "自定义短码(可选)",
|
||||
"shortener.auto": "自动",
|
||||
"shortener.slug_hint": "留空将自动生成4位随机短码。",
|
||||
"shortener.destination_url": "目标链接",
|
||||
"shortener.add_redirect": "添加重定向",
|
||||
"shortener.slug_length_title": "短链接长度",
|
||||
"shortener.slug_length_desc": "控制自动生成短链接的字符长度。较短的短码生成较小的二维码。更改仅适用于新创建的资产。",
|
||||
"shortener.characters": "个字符",
|
||||
|
||||
"print.title": "可打印二维码标签",
|
||||
"print.subtitle": "为您的库存生成高保真标签页。按 Ctrl + P(或 Cmd + P)打印贴纸页。将自动应用标准打印样式。",
|
||||
"print.print_sheet": "打印标签页",
|
||||
"print.back_to_assets": "返回资产",
|
||||
"print.guidelines_title": "打印指南",
|
||||
"print.guideline_margins": "在浏览器打印对话框中将页边距设置为「无」或「最小」。",
|
||||
"print.guideline_graphics": "启用「背景图形」以保留边框和对齐。",
|
||||
"print.guideline_size": "检查布局预览页面大小(标准 Letter/A4),确保贴纸纸上的网格对齐。",
|
||||
"print.empty": "未找到带有活跃短链接的物品。创建资产以生成标签!",
|
||||
|
||||
"qr.preview": "二维码预览",
|
||||
"qr.download": "下载二维码图片",
|
||||
|
||||
"Tech & Electronics": "科技与电子产品",
|
||||
"Kitchen Appliances": "厨房电器",
|
||||
"Furniture": "家具",
|
||||
"Office Supplies": "办公用品",
|
||||
"Tools & Hardware": "工具与五金",
|
||||
"Fitness & Sports": "健身与运动",
|
||||
"Home Entertainment": "家庭娱乐",
|
||||
"Gardening & Outdoor": "园艺与户外",
|
||||
"Lighting & Lamps": "照明与灯具",
|
||||
"Cleaning & Laundry": "清洁与洗衣",
|
||||
"Smart Home Devices": "智能家居设备",
|
||||
"Books & Stationery": "书籍与文具",
|
||||
"Security & Safety": "安防与安全",
|
||||
"Storage & Organization": "收纳与整理",
|
||||
"Audio & Instruments": "音频与乐器",
|
||||
|
||||
"Smartphones": "智能手机",
|
||||
"Laptops": "笔记本电脑",
|
||||
"Tablets": "平板电脑",
|
||||
"Smartwatches": "智能手表",
|
||||
"Desktop Computers": "台式电脑",
|
||||
"Computer Monitors": "电脑显示器",
|
||||
"Keyboards": "键盘",
|
||||
"Computer Mice": "鼠标",
|
||||
"Coffee Makers": "咖啡机",
|
||||
"Blenders": "搅拌机",
|
||||
"Toasters": "烤面包机",
|
||||
"Microwaves": "微波炉",
|
||||
"Air Fryers": "空气炸锅",
|
||||
"Food Processors": "食物处理器",
|
||||
"Juicers": "榨汁机",
|
||||
"Rice Cookers": "电饭煲",
|
||||
"Office Chairs": "办公椅",
|
||||
"Desks": "书桌",
|
||||
"Sofas": "沙发",
|
||||
"Dining Tables": "餐桌",
|
||||
"Mattresses": "床垫",
|
||||
"Bookshelves": "书架",
|
||||
"Coffee Tables": "茶几",
|
||||
"Bed Frames": "床架",
|
||||
"Paper Shredders": "碎纸机",
|
||||
"Label Printers": "标签打印机",
|
||||
"Staplers": "订书机",
|
||||
"Notebooks": "笔记本",
|
||||
"Pens": "笔",
|
||||
"Whiteboards": "白板",
|
||||
"Desk Organizers": "桌面收纳",
|
||||
"Calculators": "计算器",
|
||||
"Power Drills": "电钻",
|
||||
"Screwdriver Sets": "螺丝刀套装",
|
||||
"Hand Tool Sets": "手工具套装",
|
||||
"Tape Measures": "卷尺",
|
||||
"Hammers": "锤子",
|
||||
"Wrenches": "扳手",
|
||||
"Pliers": "钳子",
|
||||
"Utility Knives": "美工刀",
|
||||
"Treadmills": "跑步机",
|
||||
"Exercise Bikes": "健身车",
|
||||
"Dumbbells": "哑铃",
|
||||
"Yoga Mats": "瑜伽垫",
|
||||
"Resistance Bands": "阻力带",
|
||||
"Fitness Trackers": "健身追踪器",
|
||||
"Kettlebells": "壶铃",
|
||||
"Foam Rollers": "泡沫轴",
|
||||
"Televisions": "电视机",
|
||||
"Soundbars": "回音壁",
|
||||
"Streaming Devices": "流媒体设备",
|
||||
"Projectors": "投影仪",
|
||||
"VR Headsets": "VR头显",
|
||||
"Game Consoles": "游戏主机",
|
||||
"DVD/Blu-ray Players": "DVD/蓝光播放器",
|
||||
"Remote Controls": "遥控器",
|
||||
"Lawn Mowers": "割草机",
|
||||
"Leaf Blowers": "吹叶机",
|
||||
"Pruning Shears": "修枝剪",
|
||||
"Garden Hoses": "花园水管",
|
||||
"Watering Cans": "浇水壶",
|
||||
"Wheelbarrows": "手推车",
|
||||
"Weed Eaters": "除草机",
|
||||
"Patio Heaters": "户外取暖器",
|
||||
"Desk Lamps": "台灯",
|
||||
"Floor Lamps": "落地灯",
|
||||
"Smart Bulbs": "智能灯泡",
|
||||
"String Lights": "串灯",
|
||||
"Flashlights": "手电筒",
|
||||
"Night Lights": "小夜灯",
|
||||
"Ceiling Fans": "吊扇",
|
||||
"Grow Lights": "植物生长灯",
|
||||
"Vacuum Cleaners": "吸尘器",
|
||||
"Steam Mops": "蒸汽拖把",
|
||||
"Air Purifiers": "空气净化器",
|
||||
"Washing Machines": "洗衣机",
|
||||
"Clothes Dryers": "烘干机",
|
||||
"Ironing Boards": "熨衣板",
|
||||
"Steam Irons": "蒸汽熨斗",
|
||||
"Robot Mops": "拖地机器人",
|
||||
"Smart Speakers": "智能音箱",
|
||||
"Smart Thermostats": "智能温控器",
|
||||
"Security Cameras": "安防摄像头",
|
||||
"Smart Doorlocks": "智能门锁",
|
||||
"Video Doorbells": "视频门铃",
|
||||
"Smart Plugs": "智能插座",
|
||||
"Robot Vacuums": "扫地机器人",
|
||||
"Smart Displays": "智能显示屏",
|
||||
"Planners": "计划本",
|
||||
"Sketchbooks": "素描本",
|
||||
"Colored Pencils": "彩色铅笔",
|
||||
"Fountain Pens": "钢笔",
|
||||
"Highlighters": "荧光笔",
|
||||
"Sticky Notes": "便利贴",
|
||||
"Pencil Cases": "笔袋",
|
||||
"Smoke Detectors": "烟雾探测器",
|
||||
"Fire Extinguishers": "灭火器",
|
||||
"Safes": "保险箱",
|
||||
"First Aid Kits": "急救箱",
|
||||
"Safety Flashlights": "安全手电筒",
|
||||
"Door Barricades": "门挡",
|
||||
"CO Detectors": "一氧化碳探测器",
|
||||
"Motion Sensors": "运动传感器",
|
||||
"Plastic Bins": "塑料收纳箱",
|
||||
"Storage Racks": "储物架",
|
||||
"Shoe Racks": "鞋架",
|
||||
"Closet Organizers": "衣柜收纳",
|
||||
"Food Containers": "食品容器",
|
||||
"Hangers": "衣架",
|
||||
"Cable Organizers": "线缆收纳",
|
||||
"Toolboxes": "工具箱",
|
||||
"Headphones": "耳机",
|
||||
"Microphones": "麦克风",
|
||||
"Bluetooth Speakers": "蓝牙音箱",
|
||||
"Keyboards & Pianos": "键盘与钢琴",
|
||||
"Guitars": "吉他",
|
||||
"Audio Interfaces": "音频接口",
|
||||
"Studio Monitors": "监听音箱",
|
||||
"Turntables": "唱片机"
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"Solis/internal/config"
|
||||
"Solis/internal/db"
|
||||
"Solis/internal/slug"
|
||||
|
||||
@@ -22,6 +23,7 @@ import (
|
||||
|
||||
// Global View Data context
|
||||
type PageData struct {
|
||||
Lang string
|
||||
CSRFToken string
|
||||
ActiveNav string
|
||||
Toast string
|
||||
@@ -288,7 +290,7 @@ func (s *Server) handleItemNew(w http.ResponseWriter, r *http.Request) {
|
||||
locations, _ := s.db.ListLocations(false)
|
||||
tags, _ := s.db.ListTags(false)
|
||||
|
||||
catalogJSON, err := json.Marshal(s.catalog)
|
||||
catalogJSON, err := json.Marshal(s.localizedCatalog())
|
||||
if err != nil {
|
||||
catalogJSON = []byte("[]")
|
||||
}
|
||||
@@ -304,6 +306,25 @@ func (s *Server) handleItemNew(w http.ResponseWriter, r *http.Request) {
|
||||
s.render(w, r, "items.html", data)
|
||||
}
|
||||
|
||||
func (s *Server) localizedCatalog() []config.CatalogCategory {
|
||||
result := make([]config.CatalogCategory, len(s.catalog))
|
||||
for i, cat := range s.catalog {
|
||||
result[i] = config.CatalogCategory{
|
||||
ID: cat.ID,
|
||||
Name: s.i18n.T(cat.Name),
|
||||
Color: cat.Color,
|
||||
Items: make([]config.CatalogItem, len(cat.Items)),
|
||||
}
|
||||
for j, item := range cat.Items {
|
||||
result[i].Items[j] = config.CatalogItem{
|
||||
Name: s.i18n.T(item.Name),
|
||||
Brands: item.Brands,
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (s *Server) handleItemCreate(w http.ResponseWriter, r *http.Request) {
|
||||
// Limit file uploads to prevent resource exhaustion attacks
|
||||
r.Body = http.MaxBytesReader(w, r.Body, s.cfg.Upload.MaxSize*1024*1024)
|
||||
@@ -331,26 +352,26 @@ func (s *Server) handleItemCreate(w http.ResponseWriter, r *http.Request) {
|
||||
} else if itemVal != "" && itemVal != "Other" {
|
||||
name = itemVal
|
||||
} else if category != "" && category != "Other" {
|
||||
// Find category name from ID
|
||||
catName := category
|
||||
for _, cat := range s.catalog {
|
||||
if cat.ID == category {
|
||||
catName = cat.Name
|
||||
catName = s.i18n.T(cat.Name)
|
||||
break
|
||||
}
|
||||
}
|
||||
name = catName + " Asset"
|
||||
name = catName + " " + s.i18n.T("wizard.asset_suffix")
|
||||
} else {
|
||||
name = "New Asset"
|
||||
name = s.i18n.T("wizard.new_asset")
|
||||
}
|
||||
|
||||
// 3. Auto-tag with the selected catalog category
|
||||
var tagIDs []int64
|
||||
for _, cat := range s.catalog {
|
||||
if cat.ID == category {
|
||||
tag, err := s.db.GetTagByName(cat.Name)
|
||||
tagName := s.i18n.T(cat.Name)
|
||||
tag, err := s.db.GetTagByName(tagName)
|
||||
if err != nil {
|
||||
tag, err = s.db.CreateTag(cat.Name, cat.Color, "Auto-created from catalog category")
|
||||
tag, err = s.db.CreateTag(tagName, cat.Color, s.i18n.T("wizard.auto_tag_desc"))
|
||||
}
|
||||
if err == nil {
|
||||
tagIDs = append(tagIDs, tag.ID)
|
||||
@@ -365,11 +386,11 @@ func (s *Server) handleItemCreate(w http.ResponseWriter, r *http.Request) {
|
||||
catLabel := category
|
||||
for _, cat := range s.catalog {
|
||||
if cat.ID == category {
|
||||
catLabel = cat.Name
|
||||
catLabel = s.i18n.T(cat.Name)
|
||||
break
|
||||
}
|
||||
}
|
||||
desc = fmt.Sprintf("Automatically cataloged via Wizard: %s > %s > %s", catLabel, itemVal, brand)
|
||||
desc = s.i18n.TF("wizard.auto_desc", catLabel, itemVal, brand)
|
||||
|
||||
item := &db.Item{
|
||||
Name: name,
|
||||
@@ -1213,6 +1234,7 @@ func (s *Server) resolveRoomTag(locationID int64, tagIDs []int64) []int64 {
|
||||
|
||||
// render automatically injects IsAuthenticated based on the session token
|
||||
func (s *Server) render(w http.ResponseWriter, r *http.Request, name string, data PageData) {
|
||||
data.Lang = s.i18n.Lang()
|
||||
cookie, err := r.Cookie("session")
|
||||
data.IsAuthenticated = (err == nil && s.sessions.Valid(cookie.Value))
|
||||
if err := renderTemplate(w, name, data); err != nil {
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
"Solis/internal/config"
|
||||
"Solis/internal/db"
|
||||
"Solis/internal/i18n"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
@@ -21,6 +22,7 @@ type Server struct {
|
||||
sessions *sessionStore
|
||||
limiter *rateLimiter
|
||||
catalog []config.CatalogCategory
|
||||
i18n *i18n.Translator
|
||||
}
|
||||
|
||||
func New(cfg *config.Config, database *db.DB) *Server {
|
||||
@@ -30,12 +32,20 @@ func New(cfg *config.Config, database *db.DB) *Server {
|
||||
log.Printf("Warning: failed to load catalog.json: %v. Using empty catalog.", err)
|
||||
cat = []config.CatalogCategory{}
|
||||
}
|
||||
|
||||
translator, err := i18n.New(cfg.Server.Language)
|
||||
if err != nil {
|
||||
log.Printf("Warning: failed to load locale %q: %v. Falling back to English.", cfg.Server.Language, err)
|
||||
translator, _ = i18n.New("en")
|
||||
}
|
||||
|
||||
return &Server{
|
||||
cfg: cfg,
|
||||
db: database,
|
||||
sessions: newSessionStore(ttl),
|
||||
limiter: newRateLimiter(2 * time.Second), // 2 seconds between login attempts
|
||||
limiter: newRateLimiter(2 * time.Second),
|
||||
catalog: cat,
|
||||
i18n: translator,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +92,7 @@ func lowercasePath(next http.Handler) http.Handler {
|
||||
}
|
||||
|
||||
func (s *Server) Start() error {
|
||||
initTemplates()
|
||||
initTemplates(s.i18n)
|
||||
|
||||
// Ensure upload directory exists
|
||||
if err := os.MkdirAll(s.cfg.Upload.Dir, 0755); err != nil {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"Solis/internal/db"
|
||||
"Solis/internal/i18n"
|
||||
)
|
||||
|
||||
//go:embed all:templates
|
||||
@@ -22,6 +23,7 @@ var templates *template.Template
|
||||
var templateMap map[string]*template.Template
|
||||
|
||||
var templateFuncs = template.FuncMap{
|
||||
"T": func(key string) string { return key },
|
||||
"safeJS": func(s string) template.JS {
|
||||
return template.JS(s)
|
||||
},
|
||||
@@ -94,7 +96,8 @@ var templateFuncs = template.FuncMap{
|
||||
},
|
||||
}
|
||||
|
||||
func initTemplates() {
|
||||
func initTemplates(translator *i18n.Translator) {
|
||||
templateFuncs["T"] = translator.T
|
||||
templateMap = make(map[string]*template.Template)
|
||||
|
||||
// Pages that use the base layout — each gets its own template set
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="{{.Lang}}">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{block "title" .}}Solis | Home Assets{{end}}</title>
|
||||
<title>{{block "title" .}}{{T "app.title"}}{{end}}</title>
|
||||
|
||||
<!-- Dynamic CSRF Metadata for HTMX requests -->
|
||||
<meta name="csrf-token" content="{{.CSRFToken}}">
|
||||
@@ -32,7 +32,7 @@
|
||||
<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
|
||||
{{T "nav.assets"}}
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item {{if eq .ActiveNav "locations"}}active{{end}}">
|
||||
@@ -41,7 +41,7 @@
|
||||
<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.25" />
|
||||
</svg>
|
||||
Locations
|
||||
{{T "nav.locations"}}
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item {{if eq .ActiveNav "tags"}}active{{end}}">
|
||||
@@ -50,7 +50,7 @@
|
||||
<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
|
||||
{{T "nav.tags"}}
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item {{if eq .ActiveNav "shortener"}}active{{end}}">
|
||||
@@ -58,7 +58,7 @@
|
||||
<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
|
||||
{{T "nav.shortlinks"}}
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item {{if eq .ActiveNav "print"}}active{{end}}">
|
||||
@@ -66,7 +66,7 @@
|
||||
<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
|
||||
{{T "nav.print_labels"}}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -80,7 +80,7 @@
|
||||
<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
|
||||
{{T "nav.sign_out"}}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -97,7 +97,7 @@
|
||||
<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 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z" />
|
||||
</svg>
|
||||
Admin Login
|
||||
{{T "nav.admin_login"}}
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
@@ -123,10 +123,10 @@
|
||||
<div id="qr-modal-overlay" style="display:none; position:fixed; inset:0; z-index:9999; background:rgba(0,0,0,0.55); backdrop-filter:blur(4px); justify-content:center; align-items:center;">
|
||||
<div id="qr-modal-card" style="background:var(--color-bg-surface, #fff); border-radius:16px; padding:2.5rem 2rem 2rem; max-width:380px; width:90%; box-shadow:0 24px 48px -12px rgba(0,0,0,0.25); display:flex; flex-direction:column; align-items:center; gap:1.25rem; position:relative; animation:qrModalIn 0.25s cubic-bezier(0.16,1,0.3,1);">
|
||||
<button onclick="closeQRModal()" style="position:absolute; top:0.75rem; right:0.75rem; background:none; border:none; font-size:1.5rem; cursor:pointer; color:var(--color-text-light); line-height:1;" aria-label="Close">×</button>
|
||||
<h3 style="font-weight:700; font-size:1.15rem; color:var(--color-text-main); margin:0;">QR Code Preview</h3>
|
||||
<h3 style="font-weight:700; font-size:1.15rem; color:var(--color-text-main); margin:0;">{{T "qr.preview"}}</h3>
|
||||
<img id="qr-modal-image" src="" alt="QR Code" style="width:220px; height:220px; border:1px solid var(--color-border); border-radius:8px; background:#fff; padding:8px;">
|
||||
<code id="qr-modal-link" style="font-family:monospace; background:var(--color-bg-base, #f5f5f5); padding:0.4rem 0.85rem; border-radius:6px; border:1px solid var(--color-border); font-weight:600; font-size:0.95rem; word-break:break-all; text-align:center;"></code>
|
||||
<a id="qr-modal-download" download="" href="" class="btn btn-primary" style="width:100%; font-size:0.9rem; text-align:center;">Download QR Image</a>
|
||||
<a id="qr-modal-download" download="" href="" class="btn btn-primary" style="width:100%; font-size:0.9rem; text-align:center;">{{T "qr.download"}}</a>
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{define "title"}}Solis | Assets{{end}}
|
||||
{{define "title"}}{{T "app.title.assets"}}{{end}}
|
||||
|
||||
{{define "content"}}
|
||||
|
||||
@@ -7,60 +7,60 @@
|
||||
<!-- ================== ASSET EDIT / CREATE FORM ================== -->
|
||||
<div class="page-header">
|
||||
<div class="page-title">
|
||||
<h1>Edit Asset: {{.EditingItem.Name}}</h1>
|
||||
<p>Define inventory items, upload documentation, and generate automated QR codes.</p>
|
||||
<h1>{{T "items.edit.title_prefix"}}: {{.EditingItem.Name}}</h1>
|
||||
<p>{{T "items.edit.subtitle"}}</p>
|
||||
</div>
|
||||
<div>
|
||||
<a href="/admin" class="btn btn-secondary">Cancel</a>
|
||||
<a href="/admin" class="btn btn-secondary">{{T "common.cancel"}}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<form action="/admin/items/edit/{{.EditingItem.ID}}" 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>
|
||||
|
||||
|
||||
<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;">{{T "items.edit.basic_info"}}</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>
|
||||
<label for="name" class="form-label">{{T "items.edit.asset_name"}}</label>
|
||||
<input type="text" id="name" name="name" class="form-control" placeholder="e.g. Cordless Hammer Drill" value="{{.EditingItem.Name}}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="quantity" class="form-label">Quantity</label>
|
||||
<label for="quantity" class="form-label">{{T "items.edit.quantity"}}</label>
|
||||
<input type="number" id="quantity" name="quantity" class="form-control" min="1" value="{{.EditingItem.Quantity}}" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="description" class="form-label">Description</label>
|
||||
<label for="description" class="form-label">{{T "items.edit.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">{{.EditingItem.Description}}</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>
|
||||
<label for="model_number" class="form-label">{{T "items.edit.model_number"}}</label>
|
||||
<input type="text" id="model_number" name="model_number" class="form-control" placeholder="e.g. DCD796" value="{{.EditingItem.ModelNumber}}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="serial_number" class="form-label">Serial Number</label>
|
||||
<label for="serial_number" class="form-label">{{T "items.edit.serial_number"}}</label>
|
||||
<input type="text" id="serial_number" name="serial_number" class="form-control" placeholder="e.g. 2018-W42-9988" value="{{.EditingItem.SerialNumber}}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="status" class="form-label">Status</label>
|
||||
<label for="status" class="form-label">{{T "items.edit.status"}}</label>
|
||||
<select id="status" name="status" class="form-control">
|
||||
<option value="In Use" {{if eq .EditingItem.Status "In Use"}}selected{{end}}>In Use</option>
|
||||
<option value="In Storage" {{if eq .EditingItem.Status "In Storage"}}selected{{end}}>In Storage</option>
|
||||
<option value="Borrowed" {{if eq .EditingItem.Status "Borrowed"}}selected{{end}}>Borrowed</option>
|
||||
<option value="Lost" {{if eq .EditingItem.Status "Lost"}}selected{{end}}>Lost</option>
|
||||
<option value="Disposed" {{if eq .EditingItem.Status "Disposed"}}selected{{end}}>Disposed</option>
|
||||
<option value="In Use" {{if eq .EditingItem.Status "In Use"}}selected{{end}}>{{T "status.in_use"}}</option>
|
||||
<option value="In Storage" {{if eq .EditingItem.Status "In Storage"}}selected{{end}}>{{T "status.in_storage"}}</option>
|
||||
<option value="Borrowed" {{if eq .EditingItem.Status "Borrowed"}}selected{{end}}>{{T "status.borrowed"}}</option>
|
||||
<option value="Lost" {{if eq .EditingItem.Status "Lost"}}selected{{end}}>{{T "status.lost"}}</option>
|
||||
<option value="Disposed" {{if eq .EditingItem.Status "Disposed"}}selected{{end}}>{{T "status.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>
|
||||
<label for="location_id" class="form-label">{{T "items.edit.location"}}</label>
|
||||
<select id="location_id" name="location_id" class="form-control" required>
|
||||
{{range .Locations}}
|
||||
<option value="{{.ID}}" {{if $.EditingItem.LocationID.Valid}}{{if eq .ID $.EditingItem.LocationID.Int64}}selected{{end}}{{end}}>
|
||||
@@ -70,7 +70,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">Tags / Categories</label>
|
||||
<label class="form-label">{{T "items.edit.tags"}}</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;">
|
||||
@@ -82,56 +82,56 @@
|
||||
</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>
|
||||
|
||||
<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;">{{T "items.edit.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>
|
||||
<label for="purchase_price" class="form-label">{{T "items.edit.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.PurchasePrice.Valid}}{{.EditingItem.PurchasePrice.Float64}}{{end}}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="purchase_date" class="form-label">Purchase Date</label>
|
||||
<label for="purchase_date" class="form-label">{{T "items.edit.purchase_date"}}</label>
|
||||
<input type="date" id="purchase_date" name="purchase_date" class="form-control" value="{{if .EditingItem.PurchaseDate.Valid}}{{.EditingItem.PurchaseDate.String}}{{end}}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="warranty_months" class="form-label">Warranty (Months)</label>
|
||||
<label for="warranty_months" class="form-label">{{T "items.edit.warranty_months"}}</label>
|
||||
<input type="number" id="warranty_months" name="warranty_months" class="form-control" min="0" placeholder="e.g. 24" value="{{if .EditingItem.WarrantyMonths.Valid}}{{.EditingItem.WarrantyMonths.Int64}}{{end}}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="supplier" class="form-label">Supplier / Store</label>
|
||||
<label for="supplier" class="form-label">{{T "items.edit.supplier"}}</label>
|
||||
<input type="text" id="supplier" name="supplier" class="form-control" placeholder="e.g. Home Depot" value="{{.EditingItem.Supplier}}">
|
||||
</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>
|
||||
|
||||
<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;">{{T "items.edit.docs_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>
|
||||
<label for="image" class="form-label">{{T "items.edit.photo"}}</label>
|
||||
<input type="file" id="image" name="image" class="form-control" accept="image/*">
|
||||
{{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>
|
||||
<span style="font-size: 0.8rem; color: var(--color-brand-primary); margin-top: 0.25rem; display: block;">{{T "items.edit.active_image"}}: {{.EditingItem.ImagePath}}</span>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="receipt" class="form-label">Receipt / Invoice Document</label>
|
||||
<label for="receipt" class="form-label">{{T "items.edit.receipt"}}</label>
|
||||
<input type="file" id="receipt" name="receipt" class="form-control" accept="image/*,application/pdf">
|
||||
{{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>
|
||||
<span style="font-size: 0.8rem; color: var(--color-brand-primary); margin-top: 0.25rem; display: block;">{{T "items.edit.active_receipt"}}: {{.EditingItem.ReceiptPath}}</span>
|
||||
{{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>
|
||||
|
||||
<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;">{{T "items.edit.custom_fields"}}</h3>
|
||||
<p style="font-size: 0.8rem; color: var(--color-text-muted); margin-bottom: 1rem;">{{T "items.edit.custom_fields_help"}}</p>
|
||||
|
||||
<div class="form-group" style="margin-bottom: 2.5rem;">
|
||||
<label for="custom_fields" class="form-label">Custom Fields Editor</label>
|
||||
<label for="custom_fields" class="form-label">{{T "items.edit.custom_fields_editor"}}</label>
|
||||
<textarea id="custom_fields" name="custom_fields" class="form-control" rows="4" placeholder="Battery: 18v MotorType: Brushless">{{.CustomFieldsRaw}}</textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary" style="padding: 0.75rem 2rem; font-size: 1rem;">
|
||||
Save Changes
|
||||
{{T "common.save"}}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -139,11 +139,11 @@
|
||||
<!-- ================== PREMIUM ADD ASSET WIZARD ================== -->
|
||||
<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>
|
||||
<h1>{{T "wizard.title"}}</h1>
|
||||
<p>{{T "wizard.subtitle"}}</p>
|
||||
</div>
|
||||
<div>
|
||||
<a href="/admin" class="btn btn-secondary">Cancel</a>
|
||||
<a href="/admin" class="btn btn-secondary">{{T "common.cancel"}}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -151,17 +151,17 @@
|
||||
<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>
|
||||
<span class="step-label">{{T "wizard.step_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>
|
||||
<span class="step-label">{{T "wizard.step_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>
|
||||
<span class="step-label">{{T "wizard.step_brand"}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -182,13 +182,13 @@
|
||||
<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
|
||||
{{T "wizard.back"}}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Step 1: Category Screen -->
|
||||
<div class="wizard-screen active" id="screen-category">
|
||||
<h3 class="wizard-screen-title">Which category of item do you want to add?</h3>
|
||||
<h3 class="wizard-screen-title">{{T "wizard.category_question"}}</h3>
|
||||
<div class="category-grid" id="category-grid-container">
|
||||
<!-- Loaded dynamically via JS -->
|
||||
</div>
|
||||
@@ -196,7 +196,7 @@
|
||||
|
||||
<!-- Step 2: Item Screen -->
|
||||
<div class="wizard-screen" id="screen-item">
|
||||
<h3 class="wizard-screen-title" id="item-screen-heading">What kind of item is it?</h3>
|
||||
<h3 class="wizard-screen-title" id="item-screen-heading"></h3>
|
||||
<div class="pills-grid" id="item-grid-container">
|
||||
<!-- Loaded dynamically via JS -->
|
||||
</div>
|
||||
@@ -204,7 +204,7 @@
|
||||
|
||||
<!-- Step 3: Brand Screen -->
|
||||
<div class="wizard-screen" id="screen-brand">
|
||||
<h3 class="wizard-screen-title" id="brand-screen-heading">What brand is the item?</h3>
|
||||
<h3 class="wizard-screen-title" id="brand-screen-heading"></h3>
|
||||
<div class="pills-grid" id="brand-grid-container">
|
||||
<!-- Loaded dynamically via JS -->
|
||||
</div>
|
||||
@@ -439,6 +439,15 @@
|
||||
// Parse catalog JSON data dynamically injected by handler
|
||||
const catalog = {{safeJS .CatalogJSON}};
|
||||
|
||||
// i18n strings for the wizard
|
||||
const __t = {
|
||||
itemQuestion: "{{T "wizard.item_question"}}",
|
||||
brandQuestion: "{{T "wizard.brand_question"}}",
|
||||
otherUnlisted: "{{T "wizard.other_unlisted"}}",
|
||||
otherItem: "{{T "wizard.other_item"}}",
|
||||
otherBrand: "{{T "wizard.other_brand"}}"
|
||||
};
|
||||
|
||||
let currentStep = 1;
|
||||
let selectedCategory = null;
|
||||
let selectedItem = null;
|
||||
@@ -457,33 +466,33 @@
|
||||
}
|
||||
|
||||
categoryGrid.innerHTML = '';
|
||||
|
||||
|
||||
catalog.forEach(cat => {
|
||||
// Create beautiful HSL tints using the custom category color
|
||||
const color = cat.color || '#d97706';
|
||||
|
||||
|
||||
// Simple helper to convert HEX to RGBA / transparent tint
|
||||
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)`);
|
||||
|
||||
|
||||
// Pick beautiful stylized icon or stylized letter badge
|
||||
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);
|
||||
});
|
||||
|
||||
@@ -497,7 +506,7 @@
|
||||
otherCard.style.borderWidth = '2px';
|
||||
otherCard.innerHTML = `
|
||||
<div class="category-badge" style="font-weight: 500;">+</div>
|
||||
<div class="category-name">Other / Unlisted</div>
|
||||
<div class="category-name">${__t.otherUnlisted}</div>
|
||||
`;
|
||||
otherCard.addEventListener('click', () => {
|
||||
selectCategory({ id: 'Other', name: 'Other', items: [] });
|
||||
@@ -529,12 +538,12 @@
|
||||
// 3. Render Items Screen
|
||||
function renderItems(cat) {
|
||||
const heading = getEl('item-screen-heading');
|
||||
if (heading) heading.textContent = `What kind of ${cat.name.toLowerCase()} is it?`;
|
||||
if (heading) heading.textContent = __t.itemQuestion.replace('%s', cat.name);
|
||||
|
||||
const itemGrid = getEl('item-grid-container');
|
||||
if (!itemGrid) return;
|
||||
itemGrid.innerHTML = '';
|
||||
|
||||
|
||||
cat.items.forEach(item => {
|
||||
const btn = document.createElement('button');
|
||||
btn.type = 'button';
|
||||
@@ -545,11 +554,11 @@
|
||||
<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);
|
||||
});
|
||||
|
||||
@@ -558,7 +567,7 @@
|
||||
otherBtn.type = 'button';
|
||||
otherBtn.className = 'pill-button other-pill';
|
||||
otherBtn.innerHTML = `
|
||||
<span>Other Item</span>
|
||||
<span>${__t.otherItem}</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>
|
||||
@@ -591,12 +600,12 @@
|
||||
// 5. Render Brands Screen
|
||||
function renderBrands(item) {
|
||||
const heading = getEl('brand-screen-heading');
|
||||
if (heading) heading.textContent = `What brand is the ${item.name.toLowerCase()}?`;
|
||||
if (heading) heading.textContent = __t.brandQuestion.replace('%s', item.name);
|
||||
|
||||
const brandGrid = getEl('brand-grid-container');
|
||||
if (!brandGrid) return;
|
||||
brandGrid.innerHTML = '';
|
||||
|
||||
|
||||
item.brands.forEach(brand => {
|
||||
const btn = document.createElement('button');
|
||||
btn.type = 'button';
|
||||
@@ -607,11 +616,11 @@
|
||||
<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);
|
||||
});
|
||||
|
||||
@@ -620,7 +629,7 @@
|
||||
otherBtn.type = 'button';
|
||||
otherBtn.className = 'pill-button other-pill';
|
||||
otherBtn.innerHTML = `
|
||||
<span>Other Brand</span>
|
||||
<span>${__t.otherBrand}</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>
|
||||
@@ -636,7 +645,7 @@
|
||||
selectedBrand = brand;
|
||||
const inputBrand = getEl('input-brand');
|
||||
if (inputBrand) inputBrand.value = brand;
|
||||
|
||||
|
||||
// Submit the form immediately to complete creation
|
||||
const wizardForm = getEl('wizard-form');
|
||||
if (wizardForm) wizardForm.submit();
|
||||
@@ -645,7 +654,7 @@
|
||||
// 7. Navigation Step Controller
|
||||
function goToStep(step) {
|
||||
currentStep = step;
|
||||
|
||||
|
||||
const screenCategory = getEl('screen-category');
|
||||
const screenItem = getEl('screen-item');
|
||||
const screenBrand = getEl('screen-brand');
|
||||
@@ -664,7 +673,7 @@
|
||||
setTimeout(() => goToStep(step), 20);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Hide all screens
|
||||
screenCategory.classList.remove('active');
|
||||
screenItem.classList.remove('active');
|
||||
@@ -723,20 +732,20 @@
|
||||
<!-- ================== 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>
|
||||
<span style="color: var(--color-text-light); font-size: 0.85rem; font-weight: 600; text-transform: uppercase;">{{T "items.detail.title"}}</span>
|
||||
<h1 style="margin-top: 0.15rem;">{{.Item.Name}}</h1>
|
||||
</div>
|
||||
<div style="display: flex; gap: 0.5rem;">
|
||||
{{if .IsAuthenticated}}
|
||||
<a href="/admin/items/edit/{{.Item.ID}}" class="btn btn-primary">
|
||||
Edit Asset
|
||||
{{T "items.detail.edit"}}
|
||||
</a>
|
||||
<a href="/admin" class="btn btn-secondary">
|
||||
Back to List
|
||||
{{T "items.detail.back_list"}}
|
||||
</a>
|
||||
{{else}}
|
||||
<a href="{{with .CurrentLocation}}/{{.Slug}}{{else}}/default-room{{end}}" class="btn btn-secondary">
|
||||
Back to Directory
|
||||
{{T "items.detail.back_dir"}}
|
||||
</a>
|
||||
{{end}}
|
||||
</div>
|
||||
@@ -754,7 +763,7 @@
|
||||
</div>
|
||||
{{if .IsAuthenticated}}
|
||||
<span style="margin-left: 0.5rem; font-size: 0.9rem; color: var(--color-text-muted); font-weight: 500;">
|
||||
Quantity: <strong>{{.Item.Quantity}}</strong>
|
||||
{{T "items.detail.quantity"}}: <strong>{{.Item.Quantity}}</strong>
|
||||
</span>
|
||||
{{end}}
|
||||
</div>
|
||||
@@ -767,19 +776,19 @@
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<h3 style="font-weight: 700; font-size: 1.15rem; margin-bottom: 0.75rem;">Description</h3>
|
||||
<h3 style="font-weight: 700; font-size: 1.15rem; margin-bottom: 0.75rem;">{{T "items.detail.description"}}</h3>
|
||||
<p style="color: var(--color-text-muted); {{if .IsAuthenticated}}margin-bottom: 1.75rem;{{else}}margin-bottom: 0.5rem;{{end}}">
|
||||
{{if .Item.Description}}{{.Item.Description}}{{else}}<em>No description provided for this asset.</em>{{end}}
|
||||
{{if .Item.Description}}{{.Item.Description}}{{else}}<em>{{T "items.detail.no_description"}}</em>{{end}}
|
||||
</p>
|
||||
|
||||
{{if .IsAuthenticated}}
|
||||
<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-size: 0.85rem; color: var(--color-text-light); text-transform: uppercase; font-weight: 600; display: block;">{{T "items.detail.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-size: 0.85rem; color: var(--color-text-light); text-transform: uppercase; font-weight: 600; display: block;">{{T "items.detail.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>
|
||||
@@ -790,7 +799,7 @@
|
||||
<!-- 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>
|
||||
<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;">{{T "items.detail.photo"}}</h4>
|
||||
<div class="visual-box">
|
||||
{{if .Item.ImagePath}}
|
||||
<img src="/uploads/{{.Item.ImagePath}}" alt="Asset Photo">
|
||||
@@ -799,21 +808,20 @@
|
||||
<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>
|
||||
<span>{{T "items.detail.no_photo"}}</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>
|
||||
<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;">{{T "items.detail.receipt"}}</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
|
||||
{{T "items.detail.open_doc"}}
|
||||
</a>
|
||||
</div>
|
||||
{{else}}
|
||||
@@ -821,7 +829,7 @@
|
||||
<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>
|
||||
<span>{{T "items.detail.no_receipt"}}</span>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
@@ -830,7 +838,7 @@
|
||||
|
||||
<!-- 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>
|
||||
<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;">{{T "items.detail.custom_fields"}}</h3>
|
||||
{{if .CustomFieldsMap}}
|
||||
<div class="data-table-wrapper">
|
||||
<table class="data-table">
|
||||
@@ -845,7 +853,7 @@
|
||||
</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>
|
||||
<p style="color: var(--color-text-light); font-size: 0.95rem; font-style: italic;">{{T "items.detail.no_custom"}}</p>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
@@ -856,59 +864,59 @@
|
||||
<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>
|
||||
<h4 style="font-weight: 700; color: var(--color-text-muted); font-size: 1.05rem;">{{T "items.detail.qr"}}</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
|
||||
{{T "items.detail.download_qr"}}
|
||||
</a>
|
||||
{{else}}
|
||||
<span style="color: var(--color-text-light); font-size: 0.85rem;">No short URL associated.</span>
|
||||
<span style="color: var(--color-text-light); font-size: 0.85rem;">{{T "items.detail.no_short_url"}}</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>
|
||||
|
||||
<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;">{{T "items.detail.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-size: 0.75rem; color: var(--color-text-light); text-transform: uppercase; font-weight: 600; display: block;">{{T "items.detail.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-size: 0.75rem; color: var(--color-text-light); text-transform: uppercase; font-weight: 600; display: block;">{{T "items.detail.supplier"}}</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-size: 0.75rem; color: var(--color-text-light); text-transform: uppercase; font-weight: 600; display: block;">{{T "items.detail.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-size: 0.75rem; color: var(--color-text-light); text-transform: uppercase; font-weight: 600; display: block;">{{T "items.detail.warranty_period"}}</span>
|
||||
<span style="font-weight: 600; font-size: 1rem;">
|
||||
{{if .Item.WarrantyMonths.Valid}}{{.Item.WarrantyMonths.Int64}} Months{{else}}--{{end}}
|
||||
{{if .Item.WarrantyMonths.Valid}}{{.Item.WarrantyMonths.Int64}} {{T "items.detail.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-size: 0.75rem; color: var(--color-text-light); text-transform: uppercase; font-weight: 600; display: block;">{{T "items.detail.assigned_location"}}</span>
|
||||
<span style="font-weight: 600; font-size: 1rem;">
|
||||
{{if .Item.LocationName.Valid}}
|
||||
<a href="/{{.Item.LocationSlug.String}}" style="color: var(--color-brand-primary); text-decoration: none;">{{.Item.LocationName.String}}</a>
|
||||
{{else}}
|
||||
<span style="color: var(--color-text-light); font-style: italic; font-weight: 500;">Unassigned</span>
|
||||
<span style="color: var(--color-text-light); font-style: italic; font-weight: 500;">{{T "common.unassigned"}}</span>
|
||||
{{end}}
|
||||
</span>
|
||||
</div>
|
||||
@@ -921,15 +929,15 @@
|
||||
<!-- ================== 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>
|
||||
<h1>{{T "items.title"}}</h1>
|
||||
<p>{{T "items.subtitle"}}</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
|
||||
{{T "items.add"}}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -940,40 +948,40 @@
|
||||
<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}}">
|
||||
<input type="text" name="search" class="form-control" placeholder="{{T "items.search_placeholder"}}" 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>
|
||||
<option value="">{{T "items.all_statuses"}}</option>
|
||||
<option value="In Use" {{if eq .SelectedStatus "In Use"}}selected{{end}}>{{T "status.in_use"}}</option>
|
||||
<option value="In Storage" {{if eq .SelectedStatus "In Storage"}}selected{{end}}>{{T "status.in_storage"}}</option>
|
||||
<option value="Borrowed" {{if eq .SelectedStatus "Borrowed"}}selected{{end}}>{{T "status.borrowed"}}</option>
|
||||
<option value="Lost" {{if eq .SelectedStatus "Lost"}}selected{{end}}>{{T "status.lost"}}</option>
|
||||
<option value="Disposed" {{if eq .SelectedStatus "Disposed"}}selected{{end}}>{{T "status.disposed"}}</option>
|
||||
</select>
|
||||
|
||||
|
||||
<select name="location" class="form-control" style="width: 200px;" onchange="this.form.submit()">
|
||||
<option value="">-- All Locations --</option>
|
||||
<option value="">{{T "items.all_locations"}}</option>
|
||||
{{range .Locations}}
|
||||
<option value="{{.ID}}" {{if eq $.SelectedLocation .ID}}selected{{end}}>{{.Name}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
|
||||
|
||||
<select name="tag" class="form-control" style="width: 180px;" onchange="this.form.submit()">
|
||||
<option value="">-- All Tags --</option>
|
||||
<option value="">{{T "items.all_tags"}}</option>
|
||||
{{range .Tags}}
|
||||
<option value="{{.ID}}" {{if eq $.SelectedTag .ID}}selected{{end}}>{{.Name}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
|
||||
|
||||
<label style="display: flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; font-weight: 500; cursor: pointer; white-space: nowrap; margin: 0 0.5rem;">
|
||||
<input type="checkbox" name="show_removed" value="1" {{if .ShowRemoved}}checked{{end}} onchange="this.form.submit()">
|
||||
Show removed
|
||||
{{T "common.show_removed"}}
|
||||
</label>
|
||||
|
||||
<button type="submit" class="btn btn-secondary">Filter</button>
|
||||
|
||||
<button type="submit" class="btn btn-secondary">{{T "common.filter"}}</button>
|
||||
{{if or .SearchQuery (or .SelectedStatus (or .SelectedLocation (or .SelectedTag .ShowRemoved)))}}
|
||||
<a href="/admin" class="btn btn-secondary" style="padding: 0.625rem;">Reset</a>
|
||||
<a href="/admin" class="btn btn-secondary" style="padding: 0.625rem;">{{T "common.reset"}}</a>
|
||||
{{end}}
|
||||
</form>
|
||||
|
||||
@@ -984,13 +992,13 @@
|
||||
<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>
|
||||
<th style="width: 80px;">{{T "items.col.qr"}}</th>
|
||||
<th>{{T "items.col.name"}}</th>
|
||||
<th>{{T "items.col.location"}}</th>
|
||||
<th>{{T "items.col.status"}}</th>
|
||||
<th>{{T "items.col.quantity"}}</th>
|
||||
<th>{{T "items.col.tags"}}</th>
|
||||
<th style="width: 140px; text-align: right;">{{T "common.actions"}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -1012,7 +1020,7 @@
|
||||
{{.Name}}
|
||||
</a>
|
||||
{{if .ModelNumber}}
|
||||
<span style="color: var(--color-text-muted); font-size: 0.8rem; font-family: monospace;">Model: {{.ModelNumber}}</span>
|
||||
<span style="color: var(--color-text-muted); font-size: 0.8rem; font-family: monospace;">{{T "items.model_prefix"}}: {{.ModelNumber}}</span>
|
||||
{{end}}
|
||||
</div>
|
||||
</td>
|
||||
@@ -1022,12 +1030,12 @@
|
||||
<a href="/{{.LocationSlug.String}}" style="color: var(--color-brand-primary); text-decoration: none;">{{.LocationName.String}}</a>
|
||||
</span>
|
||||
{{else}}
|
||||
<span style="color: var(--color-text-light); font-style: italic; font-size: 0.9rem;">Unassigned</span>
|
||||
<span style="color: var(--color-text-light); font-style: italic; font-size: 0.9rem;">{{T "common.unassigned"}}</span>
|
||||
{{end}}
|
||||
</td>
|
||||
<td>
|
||||
{{if eq .LifecycleState "archived"}}
|
||||
<span class="status-pill archived">Archived</span>
|
||||
<span class="status-pill archived">{{T "common.archived"}}</span>
|
||||
{{else}}
|
||||
<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}}
|
||||
@@ -1051,43 +1059,43 @@
|
||||
<form action="/admin/items/restore/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; border-color: #10b981; color: #10b981;">
|
||||
Restore
|
||||
{{T "common.restore"}}
|
||||
</button>
|
||||
</form>
|
||||
<form action="/admin/items/permanent-delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to permanently delete this asset? This will clean up all associated media files on disk and cannot be undone.')" style="margin: 0;">
|
||||
<form action="/admin/items/permanent-delete/{{.ID}}" method="POST" onsubmit="return confirm('{{T "items.confirm_delete"}}')" 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 Forever
|
||||
{{T "common.delete_forever"}}
|
||||
</button>
|
||||
</form>
|
||||
{{else}}
|
||||
<!-- Active or Archived item actions -->
|
||||
<a href="/admin?view={{.ID}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Details
|
||||
{{T "common.details"}}
|
||||
</a>
|
||||
|
||||
|
||||
{{if ne .LifecycleState "archived"}}
|
||||
<a href="/admin/items/edit/{{.ID}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Edit
|
||||
{{T "common.edit"}}
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
<div class="actions-dropdown">
|
||||
<button class="btn btn-danger" onclick="toggleActionsDropdown(this, event)" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 0.25rem;">
|
||||
Delete <span style="font-size: 0.65rem;">▼</span>
|
||||
{{T "common.delete"}} <span style="font-size: 0.65rem;">▼</span>
|
||||
</button>
|
||||
<div class="actions-dropdown-menu">
|
||||
<form action="/admin/items/remove/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-danger">
|
||||
🗑 Remove Item
|
||||
🗑 {{T "items.remove_item"}}
|
||||
</button>
|
||||
</form>
|
||||
{{if ne .LifecycleState "archived"}}
|
||||
<form action="/admin/items/archive/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-warning">
|
||||
📦 Archive Item
|
||||
📦 {{T "items.archive_item"}}
|
||||
</button>
|
||||
</form>
|
||||
{{end}}
|
||||
@@ -1106,8 +1114,8 @@
|
||||
<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>
|
||||
<h3 style="font-weight:600; color:var(--color-text-muted);">{{T "items.empty.title"}}</h3>
|
||||
<p style="font-size:0.9rem; margin-top:0.25rem;">{{T "items.empty.subtitle"}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<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;">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25" />
|
||||
</svg>
|
||||
<span>Home</span>
|
||||
<span>{{T "folder.home"}}</span>
|
||||
</a>
|
||||
{{range $idx, $crumb := .Breadcrumbs}}
|
||||
{{if ne $crumb.ID 1}}
|
||||
@@ -27,13 +27,13 @@
|
||||
{{if .CurrentLocation.Description}}
|
||||
<p class="folder-description">{{.CurrentLocation.Description}}</p>
|
||||
{{end}}
|
||||
|
||||
|
||||
<div class="folder-controls" style="margin-top: 1rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem;">
|
||||
{{if .IsAuthenticated}}
|
||||
<div style="display: flex; gap: 0.5rem; align-items: center;">
|
||||
<label class="checkbox-container" style="display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; font-weight: 500; color: var(--color-text-muted); cursor: pointer;">
|
||||
<input type="checkbox" id="toggle-removed-checkbox" {{if .ShowRemoved}}checked{{end}} onchange="toggleShowRemoved(this)" style="accent-color: var(--color-brand-primary); cursor: pointer;">
|
||||
Show removed items
|
||||
{{T "folder.show_removed"}}
|
||||
</label>
|
||||
</div>
|
||||
{{end}}
|
||||
@@ -41,10 +41,10 @@
|
||||
{{if .IsAuthenticated}}
|
||||
<div style="display: flex; gap: 0.5rem;">
|
||||
<a href="/admin/locations/edit/{{.CurrentLocation.ID}}" class="btn btn-secondary" style="font-size: 0.85rem; padding: 0.5rem 1rem;">
|
||||
Edit Location
|
||||
{{T "folder.edit_location"}}
|
||||
</a>
|
||||
<a href="/admin/items/new?location_id={{.CurrentLocation.ID}}" class="btn btn-primary" style="font-size: 0.85rem; padding: 0.5rem 1rem;">
|
||||
Add Asset Here
|
||||
{{T "folder.add_asset_here"}}
|
||||
</a>
|
||||
</div>
|
||||
{{end}}
|
||||
@@ -59,7 +59,7 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" style="width: 20px; height: 20px; color: var(--color-brand-primary);">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 19.5v-15m0 0l-6.75 6.75M12 4.5l6.75 6.75" />
|
||||
</svg>
|
||||
<span>Drag items or folders here to move up to the parent directory</span>
|
||||
<span>{{T "folder.drag_up"}}</span>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
@@ -67,17 +67,17 @@
|
||||
<!-- Sub-folders Section -->
|
||||
{{if .IsAuthenticated}}
|
||||
<div class="directory-section">
|
||||
<h2 class="section-title">Folders</h2>
|
||||
<h2 class="section-title">{{T "folder.folders"}}</h2>
|
||||
<div class="folders-grid">
|
||||
{{if not .ChildLocations}}
|
||||
<div class="empty-state-card" style="grid-column: 1 / -1;">
|
||||
<p>No sub-folders in this location.</p>
|
||||
<p>{{T "folder.no_subfolders"}}</p>
|
||||
</div>
|
||||
{{else}}
|
||||
{{range .ChildLocations}}
|
||||
<div class="folder-card dropzone {{if eq .LifecycleState "removed"}}lifecycle-removed{{else if eq .LifecycleState "archived"}}lifecycle-archived{{end}}"
|
||||
{{if $.IsAuthenticated}}draggable="true"{{end}}
|
||||
data-location-id="{{.ID}}"
|
||||
<div class="folder-card dropzone {{if eq .LifecycleState "removed"}}lifecycle-removed{{else if eq .LifecycleState "archived"}}lifecycle-archived{{end}}"
|
||||
{{if $.IsAuthenticated}}draggable="true"{{end}}
|
||||
data-location-id="{{.ID}}"
|
||||
data-type="location">
|
||||
<div class="folder-card-main">
|
||||
<div class="folder-icon-wrapper">
|
||||
@@ -87,37 +87,37 @@
|
||||
</div>
|
||||
<div class="folder-info">
|
||||
<a href="/{{.Slug}}" class="folder-name-link">{{.Name}}</a>
|
||||
<span class="folder-badge">{{if eq .LifecycleState "removed"}}Removed{{else if eq .LifecycleState "archived"}}Archived{{else}}Active{{end}}</span>
|
||||
<span class="folder-badge">{{if eq .LifecycleState "removed"}}{{T "folder.state.removed"}}{{else if eq .LifecycleState "archived"}}{{T "folder.state.archived"}}{{else}}{{T "folder.state.active"}}{{end}}</span>
|
||||
</div>
|
||||
</div>
|
||||
{{if $.IsAuthenticated}}
|
||||
<div class="actions-dropdown">
|
||||
<button class="btn-icon" onclick="toggleActionsDropdown(this, event)" aria-label="Actions">
|
||||
<button class="btn-icon" onclick="toggleActionsDropdown(this, event)" aria-label="{{T "common.actions"}}">
|
||||
<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;">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 6.75a.75.75 0 110-1.5.75.75 0 010 1.5zM12 12.75a.75.75 0 110-1.5.75.75 0 010 1.5zM12 18.75a.75.75 0 110-1.5.75.75 0 010 1.5z" />
|
||||
</svg>
|
||||
</button>
|
||||
<div class="actions-dropdown-menu">
|
||||
<a href="/admin/locations/edit/{{.ID}}" class="actions-dropdown-item">
|
||||
Edit Folder
|
||||
{{T "folder.edit_folder"}}
|
||||
</a>
|
||||
{{if eq .LifecycleState "removed"}}
|
||||
<form action="/admin/locations/restore/{{.ID}}" method="POST" style="margin:0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-warning">Restore Folder</button>
|
||||
<button type="submit" class="actions-dropdown-item text-warning">{{T "folder.restore_folder"}}</button>
|
||||
</form>
|
||||
<form action="/admin/locations/delete/{{.ID}}" method="POST" style="margin:0;" onsubmit="return confirm('Are you sure you want to permanently delete this location? All items inside will be moved to the Default Room.');">
|
||||
<form action="/admin/locations/delete/{{.ID}}" method="POST" style="margin:0;" onsubmit="return confirm('{{T "folder.confirm_delete_location"}}');">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-danger">Delete Permanently</button>
|
||||
<button type="submit" class="actions-dropdown-item text-danger">{{T "folder.delete_permanently"}}</button>
|
||||
</form>
|
||||
{{else}}
|
||||
<form action="/admin/locations/archive/{{.ID}}" method="POST" style="margin:0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-warning">Archive Folder</button>
|
||||
<button type="submit" class="actions-dropdown-item text-warning">{{T "folder.archive_folder"}}</button>
|
||||
</form>
|
||||
<form action="/admin/locations/remove/{{.ID}}" method="POST" style="margin:0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-danger">Remove Folder</button>
|
||||
<button type="submit" class="actions-dropdown-item text-danger">{{T "folder.remove_folder"}}</button>
|
||||
</form>
|
||||
{{end}}
|
||||
</div>
|
||||
@@ -133,20 +133,20 @@
|
||||
<!-- Assets / Items Section -->
|
||||
{{if .IsAuthenticated}}
|
||||
<div class="directory-section" style="margin-top: 3rem;">
|
||||
<h2 class="section-title">Assets</h2>
|
||||
<h2 class="section-title">{{T "folder.assets"}}</h2>
|
||||
<div class="items-grid">
|
||||
{{if not .Items}}
|
||||
<div class="empty-state-card" style="grid-column: 1 / -1; padding: 3rem 2rem;">
|
||||
<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;color:var(--color-text-light);margin-bottom:0.75rem;">
|
||||
<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>
|
||||
<p style="color:var(--color-text-muted);font-weight:500;">No assets found in this location.</p>
|
||||
<p style="color:var(--color-text-muted);font-weight:500;">{{T "folder.no_assets"}}</p>
|
||||
</div>
|
||||
{{else}}
|
||||
{{range .Items}}
|
||||
<div class="item-card {{if eq .LifecycleState "removed"}}lifecycle-removed{{else if eq .LifecycleState "archived"}}lifecycle-archived{{end}}"
|
||||
{{if $.IsAuthenticated}}draggable="true"{{end}}
|
||||
data-item-id="{{.ID}}"
|
||||
<div class="item-card {{if eq .LifecycleState "removed"}}lifecycle-removed{{else if eq .LifecycleState "archived"}}lifecycle-archived{{end}}"
|
||||
{{if $.IsAuthenticated}}draggable="true"{{end}}
|
||||
data-item-id="{{.ID}}"
|
||||
data-type="item">
|
||||
<div class="item-card-image">
|
||||
{{if .ImagePath}}
|
||||
@@ -165,8 +165,8 @@
|
||||
<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>
|
||||
</div>
|
||||
<p class="item-card-meta">
|
||||
<span>Qty: <strong>{{.Quantity}}</strong></span>
|
||||
{{if .ModelNumber}}<span>• Model: <strong>{{.ModelNumber}}</strong></span>{{end}}
|
||||
<span>{{T "folder.qty"}}: <strong>{{.Quantity}}</strong></span>
|
||||
{{if .ModelNumber}}<span>• {{T "items.model_prefix"}}: <strong>{{.ModelNumber}}</strong></span>{{end}}
|
||||
</p>
|
||||
<div class="item-card-tags">
|
||||
{{range .Tags}}
|
||||
@@ -176,35 +176,35 @@
|
||||
</div>
|
||||
{{if $.IsAuthenticated}}
|
||||
<div class="actions-dropdown" style="position: absolute; top: 0.75rem; right: 0.75rem; z-index: 10;">
|
||||
<button class="btn-icon card-actions-btn" onclick="toggleActionsDropdown(this, event)" aria-label="Actions">
|
||||
<button class="btn-icon card-actions-btn" onclick="toggleActionsDropdown(this, event)" aria-label="{{T "common.actions"}}">
|
||||
<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;">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 6.75a.75.75 0 110-1.5.75.75 0 010 1.5zM12 12.75a.75.75 0 110-1.5.75.75 0 010 1.5zM12 18.75a.75.75 0 110-1.5.75.75 0 010 1.5z" />
|
||||
</svg>
|
||||
</button>
|
||||
<div class="actions-dropdown-menu">
|
||||
<a href="/admin/items/edit/{{.ID}}" class="actions-dropdown-item">
|
||||
Edit Asset
|
||||
{{T "folder.edit_asset"}}
|
||||
</a>
|
||||
<button type="button" class="actions-dropdown-item" onclick="openQRModal('{{.ShortSlug}}', '{{.Name}}')">
|
||||
Show QR Code
|
||||
{{T "folder.show_qr"}}
|
||||
</button>
|
||||
{{if eq .LifecycleState "removed"}}
|
||||
<form action="/admin/items/restore/{{.ID}}" method="POST" style="margin:0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-warning">Restore Asset</button>
|
||||
<button type="submit" class="actions-dropdown-item text-warning">{{T "folder.restore_asset"}}</button>
|
||||
</form>
|
||||
<form action="/admin/items/delete/{{.ID}}" method="POST" style="margin:0;" onsubmit="return confirm('Are you sure you want to permanently delete this asset? This cannot be undone.');">
|
||||
<form action="/admin/items/delete/{{.ID}}" method="POST" style="margin:0;" onsubmit="return confirm('{{T "folder.confirm_delete_asset"}}');">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-danger">Delete Permanently</button>
|
||||
<button type="submit" class="actions-dropdown-item text-danger">{{T "folder.delete_permanently"}}</button>
|
||||
</form>
|
||||
{{else}}
|
||||
<form action="/admin/items/archive/{{.ID}}" method="POST" style="margin:0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-warning">Archive Asset</button>
|
||||
<button type="submit" class="actions-dropdown-item text-warning">{{T "folder.archive_asset"}}</button>
|
||||
</form>
|
||||
<form action="/admin/items/remove/{{.ID}}" method="POST" style="margin:0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-danger">Remove Asset</button>
|
||||
<button type="submit" class="actions-dropdown-item text-danger">{{T "folder.remove_asset"}}</button>
|
||||
</form>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{{define "title"}}Solis | Locations{{end}}
|
||||
{{define "title"}}{{T "app.title.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>
|
||||
<h1>{{T "locations.title"}}</h1>
|
||||
<p>{{T "locations.subtitle"}}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
{{end}}
|
||||
<label style="display: flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; font-weight: 500; cursor: pointer; white-space: nowrap;">
|
||||
<input type="checkbox" name="show_removed" value="1" {{if .ShowRemoved}}checked{{end}} onchange="this.form.submit()">
|
||||
Show removed locations
|
||||
{{T "locations.show_removed"}}
|
||||
</label>
|
||||
</form>
|
||||
|
||||
@@ -27,10 +27,10 @@
|
||||
<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>
|
||||
<th>{{T "locations.col.name"}}</th>
|
||||
<th>{{T "locations.col.parent"}}</th>
|
||||
<th>{{T "common.description"}}</th>
|
||||
<th style="width: 120px; text-align: right;">{{T "common.actions"}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -40,7 +40,7 @@
|
||||
<td style="font-weight: 600;">
|
||||
<a href="/{{.Slug}}" style="color: var(--color-brand-primary); text-decoration: none;">{{.Name}}</a>
|
||||
{{if eq .LifecycleState "archived"}}
|
||||
<span class="status-pill archived" style="margin-left: 0.5rem; font-size: 0.7rem; padding: 0.1rem 0.4rem;">Archived</span>
|
||||
<span class="status-pill archived" style="margin-left: 0.5rem; font-size: 0.7rem; padding: 0.1rem 0.4rem;">{{T "common.archived"}}</span>
|
||||
{{end}}
|
||||
</td>
|
||||
<td>
|
||||
@@ -49,52 +49,52 @@
|
||||
{{.ParentName.String}} →
|
||||
</span>
|
||||
{{else}}
|
||||
<span style="color: var(--color-text-light); font-size: 0.85rem;">Root</span>
|
||||
<span style="color: var(--color-text-light); font-size: 0.85rem;">{{T "common.root"}}</span>
|
||||
{{end}}
|
||||
</td>
|
||||
<td style="color: var(--color-text-muted); font-size: 0.9rem;">{{.Description}}</td>
|
||||
<td class="actions-cell" style="text-align: right;">
|
||||
<div style="display: inline-flex; gap: 0.5rem; align-items: center;">
|
||||
{{if eq .ID 1}}
|
||||
<span style="color: var(--color-text-light); font-size: 0.8rem; font-style: italic; padding: 0.35rem 0.65rem;">Locked</span>
|
||||
<span style="color: var(--color-text-light); font-size: 0.8rem; font-style: italic; padding: 0.35rem 0.65rem;">{{T "common.locked"}}</span>
|
||||
{{else if eq .LifecycleState "removed"}}
|
||||
<!-- Soft removed actions -->
|
||||
<form action="/admin/locations/restore/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; border-color: #10b981; color: #10b981;">
|
||||
Restore
|
||||
{{T "common.restore"}}
|
||||
</button>
|
||||
</form>
|
||||
<form action="/admin/locations/permanent-delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to permanently delete this location? Associated sub-locations and assets will be detached.')" style="margin: 0;">
|
||||
<form action="/admin/locations/permanent-delete/{{.ID}}" method="POST" onsubmit="return confirm('{{T "locations.confirm_delete"}}')" 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 Forever
|
||||
{{T "common.delete_forever"}}
|
||||
</button>
|
||||
</form>
|
||||
{{else}}
|
||||
<!-- Active / Archived actions -->
|
||||
{{if ne .LifecycleState "archived"}}
|
||||
<a href="/admin/locations?edit={{.ID}}&show_removed={{if $.ShowRemoved}}1{{else}}0{{end}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Edit
|
||||
{{T "common.edit"}}
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
<div class="actions-dropdown">
|
||||
<button class="btn btn-danger" onclick="toggleActionsDropdown(this, event)" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 0.25rem;">
|
||||
Delete <span style="font-size: 0.65rem;">▼</span>
|
||||
{{T "common.delete"}} <span style="font-size: 0.65rem;">▼</span>
|
||||
</button>
|
||||
<div class="actions-dropdown-menu">
|
||||
<form action="/admin/locations/remove/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-danger">
|
||||
🗑 Remove
|
||||
🗑 {{T "common.remove"}}
|
||||
</button>
|
||||
</form>
|
||||
{{if ne .LifecycleState "archived"}}
|
||||
<form action="/admin/locations/archive/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-warning">
|
||||
📦 Archive
|
||||
📦 {{T "common.archive"}}
|
||||
</button>
|
||||
</form>
|
||||
{{end}}
|
||||
@@ -108,7 +108,7 @@
|
||||
{{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!
|
||||
{{T "locations.empty"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
@@ -122,19 +122,19 @@
|
||||
<div class="detail-sidebar">
|
||||
<div class="card">
|
||||
{{if .EditingLocation}}
|
||||
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">Edit Location</h3>
|
||||
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">{{T "locations.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>
|
||||
<label for="name" class="form-label">{{T "locations.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>
|
||||
<label for="parent_id" class="form-label">{{T "locations.parent_location"}}</label>
|
||||
<select id="parent_id" name="parent_id" class="form-control">
|
||||
<option value="">-- None (Root Location) --</option>
|
||||
<option value="">{{T "locations.none_root"}}</option>
|
||||
{{range $.Locations}}
|
||||
{{if ne .ID $.EditingLocation.ID}}
|
||||
<option value="{{.ID}}" {{if $.EditingLocation.ParentID.Valid}}{{if eq .ID $.EditingLocation.ParentID.Int64}}selected{{end}}{{end}}>
|
||||
@@ -146,29 +146,29 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="margin-bottom: 1.75rem;">
|
||||
<label for="description" class="form-label">Description</label>
|
||||
<label for="description" class="form-label">{{T "common.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>
|
||||
<button type="submit" class="btn btn-primary" style="flex-grow: 1;">{{T "common.save"}}</button>
|
||||
<a href="/admin/locations" class="btn btn-secondary">{{T "common.cancel"}}</a>
|
||||
</div>
|
||||
</form>
|
||||
{{else}}
|
||||
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">Create Location</h3>
|
||||
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">{{T "locations.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>
|
||||
<label for="name" class="form-label">{{T "locations.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>
|
||||
<label for="parent_id" class="form-label">{{T "locations.parent_location"}}</label>
|
||||
<select id="parent_id" name="parent_id" class="form-control">
|
||||
<option value="">-- None (Root Location) --</option>
|
||||
<option value="">{{T "locations.none_root"}}</option>
|
||||
{{range .Locations}}
|
||||
<option value="{{.ID}}">{{.Name}}</option>
|
||||
{{end}}
|
||||
@@ -176,11 +176,11 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="margin-bottom: 1.75rem;">
|
||||
<label for="description" class="form-label">Description</label>
|
||||
<label for="description" class="form-label">{{T "common.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>
|
||||
<button type="submit" class="btn btn-primary" style="width: 100%;">{{T "locations.add_location"}}</button>
|
||||
</form>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="{{.Lang}}">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Solis | Sign In</title>
|
||||
<title>{{T "app.title.login"}}</title>
|
||||
<link rel="stylesheet" href="/static/css/styles.css">
|
||||
</head>
|
||||
<body class="login-container">
|
||||
@@ -13,8 +13,8 @@
|
||||
<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>
|
||||
<h2 style="font-weight:700;font-size:1.5rem;letter-spacing:-0.01em;">{{T "login.title"}}</h2>
|
||||
<p style="color:var(--color-text-muted);font-size:0.9rem;margin-top:0.25rem;">{{T "login.subtitle"}}</p>
|
||||
</div>
|
||||
|
||||
{{if .Error}}
|
||||
@@ -25,19 +25,19 @@
|
||||
|
||||
<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>
|
||||
<label for="username" class="form-label">{{T "login.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>
|
||||
<label for="password" class="form-label">{{T "login.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
|
||||
{{T "login.submit"}}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
{{define "title"}}Solis | Print Labels{{end}}
|
||||
{{define "title"}}{{T "app.title.print"}}{{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>
|
||||
<h1>{{T "print.title"}}</h1>
|
||||
<p>{{T "print.subtitle"}}</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
|
||||
{{T "print.print_sheet"}}
|
||||
</button>
|
||||
<a href="/admin" class="btn btn-secondary">Back to Assets</a>
|
||||
<a href="/admin" class="btn btn-secondary">{{T "print.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>
|
||||
<h3 style="font-weight: 700; margin-bottom: 0.5rem; color: var(--color-brand-primary);">{{T "print.guidelines_title"}}</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>
|
||||
<li>{{T "print.guideline_margins"}}</li>
|
||||
<li>{{T "print.guideline_graphics"}}</li>
|
||||
<li>{{T "print.guideline_size"}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
{{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!
|
||||
{{T "print.empty"}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{{define "title"}}Solis | URL Shortener{{end}}
|
||||
{{define "title"}}{{T "app.title.shortlinks"}}{{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>
|
||||
<h1>{{T "shortener.title"}}</h1>
|
||||
<p>{{T "shortener.subtitle"}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<form action="/admin/shortener" method="GET" class="filter-bar" style="margin-bottom: 1.5rem; justify-content: flex-end;">
|
||||
@@ -13,7 +13,7 @@
|
||||
{{end}}
|
||||
<label style="display: flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; font-weight: 500; cursor: pointer; white-space: nowrap;">
|
||||
<input type="checkbox" name="show_removed" value="1" {{if .ShowRemoved}}checked{{end}} onchange="this.form.submit()">
|
||||
Show removed links
|
||||
{{T "shortener.show_removed"}}
|
||||
</label>
|
||||
</form>
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
<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>
|
||||
<th>{{T "shortener.col.slug"}}</th>
|
||||
<th>{{T "shortener.col.target_url"}}</th>
|
||||
<th>{{T "shortener.col.link_type"}}</th>
|
||||
<th style="width: 80px; text-align: center;">{{T "shortener.col.clicks"}}</th>
|
||||
<th style="width: 120px; text-align: right;">{{T "common.actions"}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -43,12 +43,12 @@
|
||||
/s/{{.Slug}}
|
||||
</a>
|
||||
{{if eq .LifecycleState "archived"}}
|
||||
<span class="status-pill archived" style="font-size: 0.7rem; padding: 0.1rem 0.4rem;">Archived</span>
|
||||
<span class="status-pill archived" style="font-size: 0.7rem; padding: 0.1rem 0.4rem;">{{T "common.archived"}}</span>
|
||||
{{end}}
|
||||
</div>
|
||||
<!-- QR code link quick view in printer sheet -->
|
||||
<a href="javascript:void(0)" onclick="openQRModal('{{.Slug}}', '{{.Slug}}')" style="font-size: 0.75rem; color: var(--color-text-light); text-decoration: underline; cursor: pointer;">
|
||||
View QR Code
|
||||
{{T "shortener.view_qr"}}
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
@@ -60,11 +60,11 @@
|
||||
<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
|
||||
{{T "shortener.asset_link"}} #{{.ItemID.Int64}}
|
||||
</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
|
||||
{{T "shortener.manual_redirect"}}
|
||||
</span>
|
||||
{{end}}
|
||||
</td>
|
||||
@@ -74,20 +74,20 @@
|
||||
<td class="actions-cell" 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>
|
||||
<span style="color: var(--color-text-light); font-size: 0.85rem; font-style: italic;">{{T "shortener.managed_by_asset"}}</span>
|
||||
{{else if eq .LifecycleState "removed"}}
|
||||
<!-- Soft removed manual redirects -->
|
||||
<div style="display: inline-flex; gap: 0.5rem; align-items: center;">
|
||||
<form action="/admin/shortener/restore/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; border-color: #10b981; color: #10b981;">
|
||||
Restore
|
||||
{{T "common.restore"}}
|
||||
</button>
|
||||
</form>
|
||||
<form action="/admin/shortener/permanent-delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to permanently delete this redirect? This action cannot be undone.')" style="margin: 0;">
|
||||
<form action="/admin/shortener/permanent-delete/{{.ID}}" method="POST" onsubmit="return confirm('{{T "shortener.confirm_delete"}}')" 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 Forever
|
||||
{{T "common.delete_forever"}}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -96,26 +96,26 @@
|
||||
<div style="display: inline-flex; gap: 0.5rem; align-items: center;">
|
||||
{{if ne .LifecycleState "archived"}}
|
||||
<a href="/admin/shortener?edit={{.ID}}&show_removed={{if $.ShowRemoved}}1{{else}}0{{end}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Edit
|
||||
{{T "common.edit"}}
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
<div class="actions-dropdown">
|
||||
<button class="btn btn-danger" onclick="toggleActionsDropdown(this, event)" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 0.25rem;">
|
||||
Delete <span style="font-size: 0.65rem;">▼</span>
|
||||
{{T "common.delete"}} <span style="font-size: 0.65rem;">▼</span>
|
||||
</button>
|
||||
<div class="actions-dropdown-menu">
|
||||
<form action="/admin/shortener/remove/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-danger">
|
||||
🗑 Remove
|
||||
🗑 {{T "common.remove"}}
|
||||
</button>
|
||||
</form>
|
||||
{{if ne .LifecycleState "archived"}}
|
||||
<form action="/admin/shortener/archive/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-warning">
|
||||
📦 Archive
|
||||
📦 {{T "common.archive"}}
|
||||
</button>
|
||||
</form>
|
||||
{{end}}
|
||||
@@ -129,7 +129,7 @@
|
||||
{{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!
|
||||
{{T "shortener.empty"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
@@ -143,61 +143,61 @@
|
||||
<div class="detail-sidebar">
|
||||
<div class="card">
|
||||
{{if .EditingLink}}
|
||||
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">Edit Redirect</h3>
|
||||
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">{{T "shortener.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>
|
||||
<label for="slug" class="form-label">{{T "shortener.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>
|
||||
<label for="url" class="form-label">{{T "shortener.target_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>
|
||||
<button type="submit" class="btn btn-primary" style="flex-grow: 1;">{{T "common.save"}}</button>
|
||||
<a href="/admin/shortener" class="btn btn-secondary">{{T "common.cancel"}}</a>
|
||||
</div>
|
||||
</form>
|
||||
{{else}}
|
||||
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">Create Redirect</h3>
|
||||
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">{{T "shortener.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>
|
||||
<label for="slug" class="form-label">{{T "shortener.custom_slug"}}</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
|
||||
{{T "shortener.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>
|
||||
<span style="font-size: 0.75rem; color: var(--color-text-light); margin-top: 0.25rem; display: block;">{{T "shortener.slug_hint"}}</span>
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="margin-bottom: 1.75rem;">
|
||||
<label for="url" class="form-label">Destination URL</label>
|
||||
<label for="url" class="form-label">{{T "shortener.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>
|
||||
<button type="submit" class="btn btn-primary" style="width: 100%;">{{T "shortener.add_redirect"}}</button>
|
||||
</form>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<!-- Slug Length Settings -->
|
||||
<div class="card" style="margin-top: 1rem;">
|
||||
<h3 style="font-weight: 700; margin-bottom: 0.5rem; font-size: 1rem;">URL Slug Length</h3>
|
||||
<p style="font-size: 0.8rem; color: var(--color-text-light); margin-bottom: 1rem;">Controls the character length of auto-generated short URL slugs. Shorter slugs make smaller QR codes. Changes apply to newly created assets only.</p>
|
||||
<h3 style="font-weight: 700; margin-bottom: 0.5rem; font-size: 1rem;">{{T "shortener.slug_length_title"}}</h3>
|
||||
<p style="font-size: 0.8rem; color: var(--color-text-light); margin-bottom: 1rem;">{{T "shortener.slug_length_desc"}}</p>
|
||||
<form action="/admin/shortener/slug-length" method="POST">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<div style="display: flex; gap: 0.5rem; align-items: center;">
|
||||
<input type="number" name="slug_length" class="form-control" value="{{.SlugLength}}" min="3" max="16" style="width: 80px; text-align: center; font-weight: 700; font-size: 1.1rem;">
|
||||
<span style="font-size: 0.85rem; color: var(--color-text-muted);">characters</span>
|
||||
<button type="submit" class="btn btn-primary" style="margin-left: auto; padding: 0.5rem 1rem; font-size: 0.85rem;">Save</button>
|
||||
<span style="font-size: 0.85rem; color: var(--color-text-muted);">{{T "shortener.characters"}}</span>
|
||||
<button type="submit" class="btn btn-primary" style="margin-left: auto; padding: 0.5rem 1rem; font-size: 0.85rem;">{{T "common.save"}}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{{define "title"}}Solis | Tags{{end}}
|
||||
{{define "title"}}{{T "app.title.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>
|
||||
<h1>{{T "tags.title"}}</h1>
|
||||
<p>{{T "tags.subtitle"}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<form action="/admin/tags" method="GET" class="filter-bar" style="margin-bottom: 1.5rem; justify-content: flex-end;">
|
||||
@@ -13,7 +13,7 @@
|
||||
{{end}}
|
||||
<label style="display: flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; font-weight: 500; cursor: pointer; white-space: nowrap;">
|
||||
<input type="checkbox" name="show_removed" value="1" {{if .ShowRemoved}}checked{{end}} onchange="this.form.submit()">
|
||||
Show removed tags
|
||||
{{T "tags.show_removed"}}
|
||||
</label>
|
||||
</form>
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
<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>
|
||||
<th style="width: 150px;">{{T "tags.col.tag"}}</th>
|
||||
<th>{{T "tags.col.color"}}</th>
|
||||
<th>{{T "common.description"}}</th>
|
||||
<th style="width: 120px; text-align: right;">{{T "common.actions"}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -40,7 +40,7 @@
|
||||
{{.Name}}
|
||||
</span>
|
||||
{{if eq .LifecycleState "archived"}}
|
||||
<span class="status-pill archived" style="margin-left: 0.5rem; font-size: 0.7rem; padding: 0.1rem 0.4rem;">Archived</span>
|
||||
<span class="status-pill archived" style="margin-left: 0.5rem; font-size: 0.7rem; padding: 0.1rem 0.4rem;">{{T "common.archived"}}</span>
|
||||
{{end}}
|
||||
</td>
|
||||
<td>
|
||||
@@ -52,45 +52,45 @@
|
||||
<td class="actions-cell" style="text-align: right;">
|
||||
<div style="display: inline-flex; gap: 0.5rem; align-items: center;">
|
||||
{{if eq .Name "Default Room"}}
|
||||
<span style="color: var(--color-text-light); font-size: 0.8rem; font-style: italic; padding: 0.35rem 0.65rem;">Locked</span>
|
||||
<span style="color: var(--color-text-light); font-size: 0.8rem; font-style: italic; padding: 0.35rem 0.65rem;">{{T "common.locked"}}</span>
|
||||
{{else if eq .LifecycleState "removed"}}
|
||||
<!-- Soft removed actions -->
|
||||
<form action="/admin/tags/restore/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; border-color: #10b981; color: #10b981;">
|
||||
Restore
|
||||
{{T "common.restore"}}
|
||||
</button>
|
||||
</form>
|
||||
<form action="/admin/tags/permanent-delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to permanently delete this tag? All associated items will lose this tag reference.')" style="margin: 0;">
|
||||
<form action="/admin/tags/permanent-delete/{{.ID}}" method="POST" onsubmit="return confirm('{{T "tags.confirm_delete"}}')" 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 Forever
|
||||
{{T "common.delete_forever"}}
|
||||
</button>
|
||||
</form>
|
||||
{{else}}
|
||||
<!-- Active / Archived actions -->
|
||||
{{if ne .LifecycleState "archived"}}
|
||||
<a href="/admin/tags?edit={{.ID}}&show_removed={{if $.ShowRemoved}}1{{else}}0{{end}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Edit
|
||||
{{T "common.edit"}}
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
<div class="actions-dropdown">
|
||||
<button class="btn btn-danger" onclick="toggleActionsDropdown(this, event)" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 0.25rem;">
|
||||
Delete <span style="font-size: 0.65rem;">▼</span>
|
||||
{{T "common.delete"}} <span style="font-size: 0.65rem;">▼</span>
|
||||
</button>
|
||||
<div class="actions-dropdown-menu">
|
||||
<form action="/admin/tags/remove/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-danger">
|
||||
🗑 Remove
|
||||
🗑 {{T "common.remove"}}
|
||||
</button>
|
||||
</form>
|
||||
{{if ne .LifecycleState "archived"}}
|
||||
<form action="/admin/tags/archive/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-warning">
|
||||
📦 Archive
|
||||
📦 {{T "common.archive"}}
|
||||
</button>
|
||||
</form>
|
||||
{{end}}
|
||||
@@ -104,7 +104,7 @@
|
||||
{{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!
|
||||
{{T "tags.empty"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
@@ -118,17 +118,17 @@
|
||||
<div class="detail-sidebar">
|
||||
<div class="card">
|
||||
{{if .EditingTag}}
|
||||
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">Edit Tag</h3>
|
||||
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">{{T "tags.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>
|
||||
<label for="name" class="form-label">{{T "tags.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>
|
||||
<label for="color" class="form-label">{{T "tags.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">
|
||||
@@ -136,27 +136,27 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="margin-bottom: 1.75rem;">
|
||||
<label for="description" class="form-label">Description</label>
|
||||
<label for="description" class="form-label">{{T "common.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>
|
||||
<button type="submit" class="btn btn-primary" style="flex-grow: 1;">{{T "common.save"}}</button>
|
||||
<a href="/admin/tags" class="btn btn-secondary">{{T "common.cancel"}}</a>
|
||||
</div>
|
||||
</form>
|
||||
{{else}}
|
||||
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">Create Tag</h3>
|
||||
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">{{T "tags.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>
|
||||
<label for="name" class="form-label">{{T "tags.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>
|
||||
<label for="color" class="form-label">{{T "tags.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">
|
||||
@@ -164,11 +164,11 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="margin-bottom: 1.75rem;">
|
||||
<label for="description" class="form-label">Description</label>
|
||||
<label for="description" class="form-label">{{T "common.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>
|
||||
<button type="submit" class="btn btn-primary" style="width: 100%;">{{T "tags.add_tag"}}</button>
|
||||
</form>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user