commit b57a3ce797f4558a3bc49fee92e37c67156f6bbf
parent 90ac1a2fba7a2fe507056ae58e919f74737df402
Author: mtmn <miro@haravara.org>
Date: Mon, 20 Apr 2026 16:16:06 +0200
feat: add track filter and make all filters clickable
Diffstat:
5 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/docs/architecture.md b/docs/architecture.md
@@ -19,7 +19,7 @@ A Single Page Application (SPA) built with [Elm](https://elm-lang.org).
- **Filtering & Search**: Supports deep filtering by genre, label, or release year.
- **Search Functionality**: Global search across tracks, artists, albums, and labels with real-time results.
- **About Page**: Provides system information, feature list, and links to related resources.
-- **Label Integration**: Clickable labels in track listings for quick filtering.
+- **Clickable Metadata**: Track name, artist, album, and label in listen entries are all clickable for quick filtering.
- **Responsive UI**: Designed for both desktop and mobile viewing with a "retro-modern" aesthetic.
### Database
diff --git a/src/Client.elm b/src/Client.elm
@@ -935,8 +935,8 @@ renderListen userSlug currentTime failedCovers hoveredCover similarStates idx li
li [ class "success" ]
[ div [ class "track-info" ]
[ div [ class "track-name" ]
- [ text (Maybe.withDefault "Unknown Track" listen.trackName) ]
- , div [ class "track-artist" ] [ text artist ]
+ [ button [ class "track-link", onClick (FilterBy "track" (Maybe.withDefault "Unknown Track" listen.trackName)) ] [ text (Maybe.withDefault "Unknown Track" listen.trackName) ] ]
+ , div [ class "track-artist" ] [ button [ class "artist-link", onClick (FilterBy "artist" artist) ] [ text artist ] ]
, div [ class "track-time" ]
[ span []
(button [ class "album-link", onClick (FilterBy "album" release) ] [ text release ]
diff --git a/src/Db.purs b/src/Db.purs
@@ -36,7 +36,7 @@ import Metrics as Metrics
foreign import data Connection :: Type
-data FilterField = FilterArtist | FilterAlbum | FilterLabel | FilterYear | FilterGenre
+data FilterField = FilterArtist | FilterAlbum | FilterLabel | FilterYear | FilterGenre | FilterTrack
derive instance Eq FilterField
@@ -46,6 +46,7 @@ instance Show FilterField where
show FilterLabel = "FilterLabel"
show FilterYear = "FilterYear"
show FilterGenre = "FilterGenre"
+ show FilterTrack = "FilterTrack"
foreign import connectImpl :: Fn2 String (Nullable Error -> Nullable Connection -> Effect Unit) (Effect Unit)
foreign import runImpl :: Fn4 Connection String (Array Foreign) (Nullable Error -> Effect Unit) (Effect Unit)
@@ -231,6 +232,10 @@ filterQuery FilterGenre =
scrobbleCols <> scrobbleFromInner
<> " WHERE rm.genre = ?"
<> scrobbleOrderPage
+filterQuery FilterTrack =
+ scrobbleCols <> scrobbleFromLeft
+ <> " WHERE s.track_name = ?"
+ <> scrobbleOrderPage
initReleaseMetadata :: Connection -> Aff Unit
initReleaseMetadata conn = do
diff --git a/src/Main.purs b/src/Main.purs
@@ -439,6 +439,7 @@ parseFilterField "album" = Just FilterAlbum
parseFilterField "label" = Just FilterLabel
parseFilterField "year" = Just FilterYear
parseFilterField "genre" = Just FilterGenre
+parseFilterField "track" = Just FilterTrack
parseFilterField _ = Nothing
sanitizeKey :: String -> String
diff --git a/src/Templates.purs b/src/Templates.purs
@@ -93,6 +93,29 @@ indexHtml userSlug allUsers =
margin-top: 2px;
}
+ .track-link {
+ background: none;
+ border: none;
+ padding: 0;
+ color: #ffffff;
+ font-weight: bold;
+ font-size: 16px;
+ font-family: inherit;
+ cursor: pointer;
+ text-align: left;
+ }
+
+ .artist-link {
+ background: none;
+ border: none;
+ padding: 0;
+ color: #a0c0d0;
+ font-size: 14px;
+ font-family: inherit;
+ cursor: pointer;
+ text-align: left;
+ }
+
.album-link {
background: none;
border: none;