diff --git a/src/modules/index/index.go b/src/modules/index/index.go index 17942b5..4189ca2 100644 --- a/src/modules/index/index.go +++ b/src/modules/index/index.go @@ -19,11 +19,17 @@ func SetupRoutes(g *echo.Group) { } func indexPage(c echo.Context) error { + refreshQuery := c.QueryParam("refresh") + sessionToken, navidromeUrl := utils.Credentials(c) albums, err := getRandomAlbums(sessionToken, navidromeUrl, 10) if err != nil { return c.HTML(http.StatusBadRequest, fmt.Sprintf("%s", err)) } + if refreshQuery == "true" { + return utils.RenderTempl(c, http.StatusOK, RandomAlbumsFragment(albums)) + } + return utils.RenderTempl(c, http.StatusOK, IndexTempl(albums)) } diff --git a/src/modules/index/index.templ b/src/modules/index/index.templ index a5002ba..8aa5c61 100644 --- a/src/modules/index/index.templ +++ b/src/modules/index/index.templ @@ -3,6 +3,7 @@ package index import ( "acide/src/utils" "fmt" + "strconv" ) templ IndexTempl(albums []utils.Album) { @@ -15,17 +16,33 @@ templ IndexTempl(albums []utils.Album) { Albums -

+

Random Albums +

-
- for _, album := range albums { - @AlbumCard(album) - } -
+ @RandomAlbumsFragment(albums) } } +templ RandomAlbumsFragment(albums []utils.Album) { +
+ for _, album := range albums { + @AlbumCard(album) + } +
+} + templ AlbumCard(album utils.Album) {
@@ -44,3 +61,17 @@ templ AlbumCard(album utils.Album) {
} + +templ arrowClockwiseIcon(size int) { + + + +} diff --git a/src/utils/utils.templ b/src/utils/utils.templ index accbdd6..2872c63 100644 --- a/src/utils/utils.templ +++ b/src/utils/utils.templ @@ -19,8 +19,9 @@ templ SkeletonTempl() { + - +
{ children... }
@@ -79,7 +80,7 @@ templ MusicPlayer() { @fullMusicPlayer()