package devices import "github.com/tigorlazuardi/redmage/views" import "github.com/tigorlazuardi/redmage/views/components" import "github.com/tigorlazuardi/redmage/models" import "github.com/tigorlazuardi/redmage/api" import "strconv" import "fmt" import "github.com/tigorlazuardi/redmage/views/utils" type Data struct { Error string Devices models.DeviceSlice Total int64 Params api.DevicesListParams } templ View(c *views.Context, data Data) { @components.Doctype() { @components.Head(c, components.HeadTitle("Redmage - Devices")) @components.Body(c) { @Content(c, data) } } } templ Content(c *views.Context, data Data) {
@components.Container() { if data.Error != "" { @components.ErrorToast(data.Error) } else {

Devices

Add Device
@filter(data)

{ strconv.FormatInt(data.Total, 10) } Devices

@devicesList(data) } }
} templ devicesList(data Data) {
for _, device := range data.Devices {

{ device.Name }

{ device.Slug }

{ fmt.Sprintf("%.0f \u00d7 %.0f", device.ResolutionX, device.ResolutionY) } px

Filter
if device.NSFW == 1 {
NSFW
}
Tolerance: { fmt.Sprintf("%.2f", device.AspectRatioTolerance) }
if device.MaxX > 0 {
Max Width: { strconv.Itoa(int(device.MaxX)) }px
} if device.MaxY > 0 {
Max Height: { strconv.Itoa(int(device.MaxY)) }px
} if device.MinX > 0 {
Min Width: { strconv.Itoa(int(device.MinX)) }px
} if device.MinY > 0 {
Min Height: { strconv.Itoa(int(device.MinY)) }px
}
}
}