Added Plates and Items Models and connected them with the Frontend

This commit is contained in:
2026-05-26 16:16:30 +02:00
parent 8ec5472355
commit 50e677c729
14 changed files with 951 additions and 79 deletions
+25
View File
@@ -0,0 +1,25 @@
package model
import "time"
// ItemSpec holds mask parameters (from template CLI).
type ItemSpec struct {
SizeMM float64 `json:"size_mm"`
BleedMM float64 `json:"bleed_mm"`
MarginMM float64 `json:"margin_mm"`
PaddingMM float64 `json:"padding_mm"`
}
// Item is a printable product type (SVG mask) placed on a plate.
type Item struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Spec ItemSpec `json:"spec"`
SVGTemplate string `json:"svg_template"`
CreatedAt time.Time `json:"created_at"`
}
// MetaFilename returns the sidecar metadata path for an SVG basename.
func MetaFilename(svgBasename string) string {
return svgBasename + ".meta.json"
}
+26
View File
@@ -0,0 +1,26 @@
package model
import "time"
// Plate describes a print bed with outer dimensions and margins on each side.
type Plate struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
WidthMM float64 `json:"width_mm"`
HeightMM float64 `json:"height_mm"`
MarginTop float64 `json:"margin_top_mm"`
MarginRight float64 `json:"margin_right_mm"`
MarginBottom float64 `json:"margin_bottom_mm"`
MarginLeft float64 `json:"margin_left_mm"`
CreatedAt time.Time `json:"created_at"`
}
// PrintableWidth returns the usable width inside the margins.
func (p Plate) PrintableWidth() float64 {
return p.WidthMM - p.MarginLeft - p.MarginRight
}
// PrintableHeight returns the usable height inside the margins.
func (p Plate) PrintableHeight() float64 {
return p.HeightMM - p.MarginTop - p.MarginBottom
}