devices: moved endpoints

This commit is contained in:
Tigor Hutasuhut 2024-05-08 11:19:14 +07:00
parent bfff9a698f
commit 9c1db28783
3 changed files with 6 additions and 6 deletions

View file

@ -63,9 +63,8 @@ func (routes *Routes) registerHTMXRoutes(router chi.Router) {
router.Post("/subreddits/check", routes.SubredditCheckHTMX)
router.Get("/subreddits/validate/schedule", routes.SubredditValidateScheduleHTMX)
router.Post("/devices/add", routes.DevicesCreateHTMX)
router.Post("/devices/add/validate/slug", routes.DevicesValidateSlugHTMX)
router.Post("/devices/add/validate/name", routes.DevicesValidateNameHTMX)
router.Get("/devices/add/validate/slug", routes.DevicesValidateSlugHTMX)
router.Get("/devices/add/validate/name", routes.DevicesValidateNameHTMX)
}
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("/devices", routes.PageDevices)
r.Get("/devices/add", routes.PageDevicesAdd)
r.Post("/devices/add", routes.DevicesCreateHTMX)
r.Get("/devices/details/{slug}", routes.PageDeviceDetails)
r.Get("/schedules", routes.PageScheduleHistory)
})

View file

@ -21,7 +21,7 @@ templ NameInput(data NameInputData) {
if !data.DisableValidation {
required
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-trigger="change"
hx-target="#name-input-form"

View file

@ -49,10 +49,10 @@ templ SlugInput(data SlugInputData) {
if data.Disabled {
disabled
} else {
hx-post="/htmx/devices/add/validate/slug"
hx-get="/htmx/devices/add/validate/slug"
hx-trigger="change, input delay:2s"
hx-target="#slug-input-form"
hx-target-409="#slug-input-form"
hx-target-error="#slug-input-form"
hx-swap="outerHTML"
placeholder="my-awesome-device"
title="Url Friendly Characters Only"