Update every 30 seconds; adding a link to the station info page.

This commit is contained in:
Christian Lawson-Perfect 2025-05-11 09:09:38 +00:00
parent 3f68f9ae72
commit e6c92a3edf
3 changed files with 25 additions and 16 deletions

View file

@ -13,7 +13,8 @@ import Svg.Attributes as SA
import Svg.Events as SE
import Task
import Time
import Tuple exposing (pair, first, second)
import Tuple exposing (pair, first, second)
import Url.Builder as UB
port request_data : (String, Int) -> Cmd msg
@ -333,7 +334,7 @@ subscriptions model =
Sub.batch
[ receive_platform_data ReceivePlatformData
, receive_location ReceiveLocation
, Time.every (1000 * 60) (\_ -> UpdatePlatformData)
, Time.every (1000 * 30) (\_ -> UpdatePlatformData)
, Time.every 100 Tick
, Browser.Events.onVisibilityChange VisibilityChange
]
@ -342,7 +343,7 @@ view : Model -> Browser.Document Msg
view model =
let
current_station = model.current_station |> Maybe.map (station_with_key model)
next_trains =
current_station
|> Maybe.map (\s ->
@ -354,16 +355,24 @@ view model =
|> Maybe.withDefault ""
view_station open station =
H.article
[ HE.on "toggle" (
JD.succeed (TriggerTrainInfoRequest station)
)
, HA.class "station"
]
[ H.ol
[ HA.class "platforms"]
(List.map (view_platform station) station.platforms)
]
let
info_url = UB.crossOrigin
"https://www.nexus.org.uk"
[ "metro/timetables-and-stations", station.name |> String.toLower |> String.replace " " "-" ]
[]
in
H.article
[ HE.on "toggle" (
JD.succeed (TriggerTrainInfoRequest station)
)
, HA.class "station"
]
[ H.ol
[ HA.class "platforms"]
(List.map (view_platform station) station.platforms)
, H.p [] [ H.a [ HA.href info_url, HA.target "station-info" ] [H.text <| "Station information for "++station.name]]
]
format_time t =
let