Add rack height field to create form

The rack creation form now includes a Height (U) input defaulting to 42.
The handler reads it instead of hardcoding. Previously every rack was
silently locked at 42U until you went to the rack page to edit it.
master
Joca 2026-06-09 18:56:23 -03:00
parent b9ebc1d141
commit 2aeb66de33
Signed by: jocadbz
GPG Key ID: B1836DCE2F50BDF7
2 changed files with 7 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package handlers
import (
"net/http"
"strconv"
"lostcavewireplanner/internal/models"
)
@ -47,6 +48,11 @@ func (h *Handlers) RackCreate(w http.ResponseWriter, r *http.Request) {
rackType := r.FormValue("rack_type")
depth := r.FormValue("depth")
heightUnits := 42
if huStr := r.FormValue("height_units"); huStr != "" {
if n, err := strconv.Atoi(huStr); err == nil && n > 0 {
heightUnits = n
}
}
if name == "" {
h.renderError(w, "overview.html", "Name is required")

View File

@ -21,6 +21,7 @@
<label>Name <input name="name" required></label>
<label>Type <select name="rack_type"><option value="network">Network</option><option value="server">Server</option></select></label>
<label>Depth <select name="depth"><option value="shallow">Shallow</option><option value="deep">Deep</option></select></label>
<label>Height (U) <input type="number" name="height_units" value="42" min="1" style="width:6em"></label>
<button type="submit">Create Rack</button>
</form>
</details>