refactor: moved devices locations to cleaner name
This commit is contained in:
parent
9c1db28783
commit
1dc3617df3
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/gosimple/slug"
|
||||
"github.com/tigorlazuardi/redmage/pkg/errs"
|
||||
"github.com/tigorlazuardi/redmage/pkg/log"
|
||||
"github.com/tigorlazuardi/redmage/views/devicesview/put"
|
||||
"github.com/tigorlazuardi/redmage/views/devices/put"
|
||||
)
|
||||
|
||||
func (routes *Routes) DevicesValidateNameHTMX(rw http.ResponseWriter, req *http.Request) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/gosimple/slug"
|
||||
"github.com/tigorlazuardi/redmage/pkg/errs"
|
||||
"github.com/tigorlazuardi/redmage/pkg/log"
|
||||
"github.com/tigorlazuardi/redmage/views/devicesview/put"
|
||||
"github.com/tigorlazuardi/redmage/views/devices/put"
|
||||
)
|
||||
|
||||
func (routes *Routes) DevicesValidateSlugHTMX(rw http.ResponseWriter, req *http.Request) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/tigorlazuardi/redmage/pkg/errs"
|
||||
"github.com/tigorlazuardi/redmage/pkg/log"
|
||||
"github.com/tigorlazuardi/redmage/views"
|
||||
"github.com/tigorlazuardi/redmage/views/devicesview"
|
||||
"github.com/tigorlazuardi/redmage/views/devices"
|
||||
)
|
||||
|
||||
func (routes *Routes) PageDevices(rw http.ResponseWriter, req *http.Request) {
|
||||
|
@ -14,7 +14,7 @@ func (routes *Routes) PageDevices(rw http.ResponseWriter, req *http.Request) {
|
|||
defer start.End()
|
||||
|
||||
vc := views.NewContext(routes.Config, req)
|
||||
var data devicesview.Data
|
||||
var data devices.Data
|
||||
data.Params.FillFromQuery(req.URL.Query())
|
||||
|
||||
result, err := routes.API.DevicesList(ctx, data.Params)
|
||||
|
@ -23,14 +23,14 @@ func (routes *Routes) PageDevices(rw http.ResponseWriter, req *http.Request) {
|
|||
code, message := errs.HTTPMessage(err)
|
||||
rw.WriteHeader(code)
|
||||
data.Error = message
|
||||
if err := devicesview.Devices(vc, data).Render(ctx, rw); err != nil {
|
||||
if err := devices.View(vc, data).Render(ctx, rw); err != nil {
|
||||
log.New(ctx).Err(err).Error("failed to render devices error view")
|
||||
}
|
||||
}
|
||||
data.Devices = result.Devices
|
||||
data.Total = result.Total
|
||||
|
||||
if err := devicesview.Devices(vc, data).Render(ctx, rw); err != nil {
|
||||
if err := devices.View(vc, data).Render(ctx, rw); err != nil {
|
||||
log.New(ctx).Err(err).Error("failed to render devices view")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/tigorlazuardi/redmage/pkg/log"
|
||||
"github.com/tigorlazuardi/redmage/views"
|
||||
"github.com/tigorlazuardi/redmage/views/devicesview/put"
|
||||
"github.com/tigorlazuardi/redmage/views/devices/put"
|
||||
)
|
||||
|
||||
func (routes *Routes) PageDevicesAdd(rw http.ResponseWriter, req *http.Request) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/tigorlazuardi/redmage/pkg/errs"
|
||||
"github.com/tigorlazuardi/redmage/pkg/log"
|
||||
"github.com/tigorlazuardi/redmage/views"
|
||||
"github.com/tigorlazuardi/redmage/views/devicesview/devicedetails"
|
||||
"github.com/tigorlazuardi/redmage/views/devices/details"
|
||||
)
|
||||
|
||||
func (routes *Routes) PageDeviceDetails(rw http.ResponseWriter, req *http.Request) {
|
||||
|
@ -18,7 +18,7 @@ func (routes *Routes) PageDeviceDetails(rw http.ResponseWriter, req *http.Reques
|
|||
|
||||
slug := chi.URLParam(req, "slug")
|
||||
|
||||
var data devicedetails.Data
|
||||
var data details.Data
|
||||
data.Params.FillFromQuery(req.URL.Query())
|
||||
|
||||
var err error
|
||||
|
@ -29,7 +29,7 @@ func (routes *Routes) PageDeviceDetails(rw http.ResponseWriter, req *http.Reques
|
|||
code, message := errs.HTTPMessage(err)
|
||||
rw.WriteHeader(code)
|
||||
data.Error = message
|
||||
if err := devicedetails.View(c, data).Render(ctx, rw); err != nil {
|
||||
if err := details.View(c, data).Render(ctx, rw); err != nil {
|
||||
log.New(ctx).Err(err).Error("failed to render device details page")
|
||||
}
|
||||
return
|
||||
|
@ -43,7 +43,7 @@ func (routes *Routes) PageDeviceDetails(rw http.ResponseWriter, req *http.Reques
|
|||
code, message := errs.HTTPMessage(err)
|
||||
rw.WriteHeader(code)
|
||||
data.Error = message
|
||||
if err := devicedetails.View(c, data).Render(ctx, rw); err != nil {
|
||||
if err := details.View(c, data).Render(ctx, rw); err != nil {
|
||||
log.New(ctx).Err(err).Error("failed to render device details page")
|
||||
}
|
||||
return
|
||||
|
@ -52,7 +52,7 @@ func (routes *Routes) PageDeviceDetails(rw http.ResponseWriter, req *http.Reques
|
|||
data.Images = result.Images
|
||||
data.TotalImages = result.Total
|
||||
|
||||
if err := devicedetails.View(c, data).Render(ctx, rw); err != nil {
|
||||
if err := details.View(c, data).Render(ctx, rw); err != nil {
|
||||
log.New(ctx).Err(err).Error("failed to render device details page")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package devicedetails
|
||||
package details
|
||||
|
||||
import (
|
||||
"github.com/tigorlazuardi/redmage/api"
|
|
@ -1,4 +1,4 @@
|
|||
package devicedetails
|
||||
package details
|
||||
|
||||
import "fmt"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package devicedetails
|
||||
package details
|
||||
|
||||
import "github.com/tigorlazuardi/redmage/views"
|
||||
import "github.com/tigorlazuardi/redmage/views/components"
|
|
@ -1,4 +1,4 @@
|
|||
package devicesview
|
||||
package devices
|
||||
|
||||
import "github.com/tigorlazuardi/redmage/api"
|
||||
import "strconv"
|
|
@ -1,4 +1,4 @@
|
|||
package devicesview
|
||||
package devices
|
||||
|
||||
import "github.com/tigorlazuardi/redmage/views"
|
||||
import "github.com/tigorlazuardi/redmage/views/components"
|
||||
|
@ -15,16 +15,16 @@ type Data struct {
|
|||
Params api.DevicesListParams
|
||||
}
|
||||
|
||||
templ Devices(c *views.Context, data Data) {
|
||||
templ View(c *views.Context, data Data) {
|
||||
@components.Doctype() {
|
||||
@components.Head(c, components.HeadTitle("Redmage - Devices"))
|
||||
@components.Body(c) {
|
||||
@DevicesContent(c, data)
|
||||
@Content(c, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
templ DevicesContent(c *views.Context, data Data) {
|
||||
templ Content(c *views.Context, data Data) {
|
||||
<main class="prose min-w-full">
|
||||
@components.Container() {
|
||||
if data.Error != "" {
|
Loading…
Reference in a new issue