fix(users/Profpatsch/whatcd-resolver): add page chrome to artist

Change-Id: Id13553c450603b04c6bba0085d7f3246fe0d54af
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11682
Autosubmit: Profpatsch <mail@profpatsch.de>
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
This commit is contained in:
Profpatsch 2024-05-16 22:26:51 +02:00 committed by clbot
parent c5555f25da
commit 54ea3eeacb

View file

@ -24,6 +24,7 @@ import FieldParser (FieldParser, FieldParser' (..))
import FieldParser qualified as Field import FieldParser qualified as Field
import Html qualified import Html qualified
import IHP.HSX.QQ (hsx) import IHP.HSX.QQ (hsx)
import IHP.HSX.ToHtml (ToHtml)
import Json qualified import Json qualified
import Json.Enc (Enc) import Json.Enc (Enc)
import Json.Enc qualified as Enc import Json.Enc qualified as Enc
@ -259,9 +260,41 @@ htmlUi = do
bestTorrentsTable <- getBestTorrentsTable Nothing bestTorrentsTable <- getBestTorrentsTable Nothing
-- transmissionTorrentsTable <- lift @Transaction getTransmissionTorrentsTable -- transmissionTorrentsTable <- lift @Transaction getTransmissionTorrentsTable
pure $ pure $
Html.docTypeHtml htmlPageChrome
[hsx| [hsx|
<form
hx-post="/snips/redacted/search"
hx-target="#redacted-search-results">
<label for="redacted-search">Redacted Search</label>
<input
id="redacted-search"
type="text"
name="redacted-search" />
<button type="submit" hx-disabled-elt="this">Search</button>
<div class="htmx-indicator">Search running!</div>
</form>
<div id="redacted-search-results">
{bestTorrentsTable}
</div>
<!-- refresh the page if the uniqueRunId is different -->
<input
hidden
type="text"
id="autorefresh"
name="hasItBeenRestarted"
value={uniqueRunId}
hx-get="/autorefresh"
hx-trigger="every 5s"
hx-swap="none"
/>
|]
htmlPageChrome :: (ToHtml a) => a -> Html
htmlPageChrome body =
Html.docTypeHtml $
[hsx|
<head> <head>
<!-- TODO: set nice page title for each page -->
<title>whatcd-resolver</title> <title>whatcd-resolver</title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
@ -277,31 +310,7 @@ htmlUi = do
</style> </style>
</head> </head>
<body> <body>
<form {body}
hx-post="/snips/redacted/search"
hx-target="#redacted-search-results">
<label for="redacted-search">Redacted Search</label>
<input
id="redacted-search"
type="text"
name="redacted-search" />
<button type="submit" hx-disabled-elt="this">Search</button>
<div class="htmx-indicator">Search running!</div>
</form>
<div id="redacted-search-results">
{bestTorrentsTable}
</div>
<!-- refresh the page if the uniqueRunId is different -->
<input
hidden
type="text"
id="autorefresh"
name="hasItBeenRestarted"
value={uniqueRunId}
hx-get="/autorefresh"
hx-trigger="every 5s"
hx-swap="none"
/>
</body> </body>
|] |]
@ -317,12 +326,13 @@ artistPage ::
m Html m Html
artistPage dat = runTransaction $ do artistPage dat = runTransaction $ do
torrents <- getBestTorrentsTable (Just $ label @"artistId" dat.dbId) torrents <- getBestTorrentsTable (Just $ label @"artistId" dat.dbId)
pure pure $
[hsx| htmlPageChrome
Artist ID: {dat.dbId} [hsx|
Artist ID: {dat.dbId}
{torrents} {torrents}
|] |]
type Handlers m = HandlerResponses m -> Map Text (m ResponseReceived) type Handlers m = HandlerResponses m -> Map Text (m ResponseReceived)