devices: added view page
This commit is contained in:
parent
6bd219ea4f
commit
b8fcb37db8
20
server/routes/page_devices_add.go
Normal file
20
server/routes/page_devices_add.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package routes
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/tigorlazuardi/redmage/pkg/log"
|
||||
"github.com/tigorlazuardi/redmage/views"
|
||||
"github.com/tigorlazuardi/redmage/views/devicesview/adddevice"
|
||||
)
|
||||
|
||||
func (routes *Routes) PageDevicesAdd(rw http.ResponseWriter, req *http.Request) {
|
||||
ctx, span := tracer.Start(req.Context(), "*Routes.PageDevicesAdd")
|
||||
defer span.End()
|
||||
|
||||
c := views.NewContext(routes.Config, req)
|
||||
|
||||
if err := adddevice.View(c).Render(ctx, rw); err != nil {
|
||||
log.New(ctx).Err(err).Error("failed to render add device page")
|
||||
}
|
||||
}
|
|
@ -82,6 +82,7 @@ func (routes *Routes) registerWWWRoutes(router chi.Router) {
|
|||
r.Get("/subreddits/add", routes.PageSubredditsAdd)
|
||||
r.Get("/config", routes.PageConfig)
|
||||
r.Get("/devices", routes.PageDevices)
|
||||
r.Get("/devices/add", routes.PageDevicesAdd)
|
||||
r.Get("/devices/details/{slug}", routes.PageDeviceDetails)
|
||||
r.Get("/schedules", routes.PageScheduleHistory)
|
||||
})
|
||||
|
|
22
views/devicesview/adddevice/view.templ
Normal file
22
views/devicesview/adddevice/view.templ
Normal file
|
@ -0,0 +1,22 @@
|
|||
package adddevice
|
||||
|
||||
import "github.com/tigorlazuardi/redmage/views"
|
||||
import "github.com/tigorlazuardi/redmage/views/components"
|
||||
|
||||
templ View(c *views.Context) {
|
||||
@components.Doctype() {
|
||||
@components.Head(c, components.HeadTitle("Device - Add"))
|
||||
@components.Body(c) {
|
||||
@Content(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
templ Content(c *views.Context) {
|
||||
<main class="prose min-w-full">
|
||||
@components.Container() {
|
||||
<h1>Add Device</h1>
|
||||
<div class="divider"></div>
|
||||
}
|
||||
</main>
|
||||
}
|
|
@ -13,7 +13,7 @@ templ filter(data Data) {
|
|||
hx-select="main"
|
||||
hx-swap="outerHTML"
|
||||
hx-push-url="true"
|
||||
class="grid md:grid-cols-2 gap-4"
|
||||
class="grid md:grid-cols-[1fr,3fr] lg:grid-cols-2 gap-4"
|
||||
>
|
||||
<label class="input input-bordered flex items-center gap-2">
|
||||
<input
|
||||
|
|
|
@ -30,7 +30,10 @@ templ DevicesContent(c *views.Context, data Data) {
|
|||
if data.Error != "" {
|
||||
@components.ErrorToast(data.Error)
|
||||
} else {
|
||||
<h1>Devices</h1>
|
||||
<div class="flex justify-between items-center">
|
||||
<h1 class="my-auto">Devices</h1>
|
||||
<a href="/devices/add" class="btn btn-primary no-underline text-base-100">Add Device</a>
|
||||
</div>
|
||||
<div class="divider"></div>
|
||||
@filter(data)
|
||||
<h2>{ strconv.FormatInt(data.Total, 10) } Devices</h2>
|
||||
|
|
Loading…
Reference in a new issue