diff --git a/app/backend/internal/handler/dashboard.go b/app/backend/internal/handler/dashboard.go index 40b8bd1..0e861bc 100644 --- a/app/backend/internal/handler/dashboard.go +++ b/app/backend/internal/handler/dashboard.go @@ -51,6 +51,12 @@ func parsePort(s string, def int) int { } func CreateHost(c *fiber.Ctx) error { + hostID := c.FormValue("hostId") + + if hostID != "" { + return UpdateHost(c) + } + name := c.FormValue("name") ip := c.FormValue("ip") if name == "" || ip == "" { @@ -77,9 +83,8 @@ func CreateHost(c *fiber.Ctx) error { h.AuthType = "key" } - created := hostStore.AddFull(h) + hostStore.AddFull(h) hosts := hostStore.All() - _ = created return c.Render("host_list", fiber.Map{ "Hosts": hosts, "Active": countByStatus(hosts, "active"), @@ -89,6 +94,9 @@ func CreateHost(c *fiber.Ctx) error { func UpdateHost(c *fiber.Ctx) error { id := c.Params("id") + if id == "" { + id = c.FormValue("hostId") + } existing, found := hostStore.Get(id) if !found { return c.Status(404).SendString("host not found") diff --git a/app/backend/views/host_modal.html b/app/backend/views/host_modal.html index 415823d..e0ad7eb 100644 --- a/app/backend/views/host_modal.html +++ b/app/backend/views/host_modal.html @@ -15,11 +15,11 @@ -