devices: moved endpoints
This commit is contained in:
parent
bfff9a698f
commit
9c1db28783
|
@ -63,9 +63,8 @@ func (routes *Routes) registerHTMXRoutes(router chi.Router) {
|
||||||
router.Post("/subreddits/check", routes.SubredditCheckHTMX)
|
router.Post("/subreddits/check", routes.SubredditCheckHTMX)
|
||||||
router.Get("/subreddits/validate/schedule", routes.SubredditValidateScheduleHTMX)
|
router.Get("/subreddits/validate/schedule", routes.SubredditValidateScheduleHTMX)
|
||||||
|
|
||||||
router.Post("/devices/add", routes.DevicesCreateHTMX)
|
router.Get("/devices/add/validate/slug", routes.DevicesValidateSlugHTMX)
|
||||||
router.Post("/devices/add/validate/slug", routes.DevicesValidateSlugHTMX)
|
router.Get("/devices/add/validate/name", routes.DevicesValidateNameHTMX)
|
||||||
router.Post("/devices/add/validate/name", routes.DevicesValidateNameHTMX)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (routes *Routes) registerWWWRoutes(router chi.Router) {
|
func (routes *Routes) registerWWWRoutes(router chi.Router) {
|
||||||
|
@ -87,6 +86,7 @@ func (routes *Routes) registerWWWRoutes(router chi.Router) {
|
||||||
r.Get("/config", routes.PageConfig)
|
r.Get("/config", routes.PageConfig)
|
||||||
r.Get("/devices", routes.PageDevices)
|
r.Get("/devices", routes.PageDevices)
|
||||||
r.Get("/devices/add", routes.PageDevicesAdd)
|
r.Get("/devices/add", routes.PageDevicesAdd)
|
||||||
|
r.Post("/devices/add", routes.DevicesCreateHTMX)
|
||||||
r.Get("/devices/details/{slug}", routes.PageDeviceDetails)
|
r.Get("/devices/details/{slug}", routes.PageDeviceDetails)
|
||||||
r.Get("/schedules", routes.PageScheduleHistory)
|
r.Get("/schedules", routes.PageScheduleHistory)
|
||||||
})
|
})
|
||||||
|
|
|
@ -21,7 +21,7 @@ templ NameInput(data NameInputData) {
|
||||||
if !data.DisableValidation {
|
if !data.DisableValidation {
|
||||||
required
|
required
|
||||||
x-data={ fmt.Sprintf(`{ init() { $el.setCustomValidity(%q) } }`, data.Error) }
|
x-data={ fmt.Sprintf(`{ init() { $el.setCustomValidity(%q) } }`, data.Error) }
|
||||||
hx-post="/htmx/devices/add/validate/name"
|
hx-get="/htmx/devices/add/validate/name"
|
||||||
hx-include="[name='slug']"
|
hx-include="[name='slug']"
|
||||||
hx-trigger="change"
|
hx-trigger="change"
|
||||||
hx-target="#name-input-form"
|
hx-target="#name-input-form"
|
||||||
|
|
|
@ -49,10 +49,10 @@ templ SlugInput(data SlugInputData) {
|
||||||
if data.Disabled {
|
if data.Disabled {
|
||||||
disabled
|
disabled
|
||||||
} else {
|
} else {
|
||||||
hx-post="/htmx/devices/add/validate/slug"
|
hx-get="/htmx/devices/add/validate/slug"
|
||||||
hx-trigger="change, input delay:2s"
|
hx-trigger="change, input delay:2s"
|
||||||
hx-target="#slug-input-form"
|
hx-target="#slug-input-form"
|
||||||
hx-target-409="#slug-input-form"
|
hx-target-error="#slug-input-form"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
placeholder="my-awesome-device"
|
placeholder="my-awesome-device"
|
||||||
title="Url Friendly Characters Only"
|
title="Url Friendly Characters Only"
|
||||||
|
|
Loading…
Reference in a new issue