package details import "github.com/tigorlazuardi/redmage/views" import "github.com/tigorlazuardi/redmage/views/components" import "github.com/tigorlazuardi/redmage/views/icons" import "fmt" import "github.com/tigorlazuardi/redmage/models" import "strconv" templ View(c *views.Context, data Data) { @components.Doctype() { if data.Device == nil { @components.Head(c, components.HeadTitle("Redmage - Device Not Found")) } else { @components.Head(c, components.HeadTitle(fmt.Sprintf("Redmage - %s", data.Device.Name))) } @components.Body(c) { @Content(c, data) @components.NotificationContainer() { if data.FlashMessageSuccess != "" { @components.SuccessNotification(data.FlashMessageSuccess) } } } } } templ Content(c *views.Context, data Data) {
@components.Container() { if data.Error != "" { @components.ErrorToast(data.Error) } else {

{ data.Device.Name }

@actionButton(data)
@filter(c, data)

{ strconv.FormatInt(data.TotalImages, 10) } Images

if data.TotalImages > 0 {
@components.Pagination(c, components.PaginationData{ BaseURL: "/devices/details/" + data.Device.Slug, Limit: data.Params.Limit, Offset: data.Params.Offset, Total: data.TotalImages, })

Showing from { strconv.FormatInt(data.Params.Offset + 1, 10) } to { strconv.FormatInt(min(data.Params.Limit+data.Params.Offset, data.TotalImages), 10) }

} for _, group := range data.splitImages() {

{ group.Subreddit }

@imageList(group.Images) }
@components.Pagination(c, components.PaginationData{ BaseURL: "/devices/details/" + data.Device.Slug, Limit: data.Params.Limit, Offset: data.Params.Offset, Total: data.TotalImages, })
} }
} templ actionButton(data Data) {
} templ imageList(images models.ImageSlice) { @components.HorizontalImageWell() { for _, data := range images { @components.ImageCard(data, 0) } } }