From 2b1a1888210caecbfc66b85b58ef9cd760a73800 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Sat, 3 Sep 2022 00:20:45 +0200 Subject: init onboard-unit --- lib/Server/ControlRoom.hs | 21 +++++++++++ messages/de.msg | 3 ++ messages/en.msg | 5 +++ site/obu.hamlet | 92 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 121 insertions(+) create mode 100644 site/obu.hamlet diff --git a/lib/Server/ControlRoom.hs b/lib/Server/ControlRoom.hs index 9b61828..86f8deb 100644 --- a/lib/Server/ControlRoom.hs +++ b/lib/Server/ControlRoom.hs @@ -75,6 +75,8 @@ mkYesod "ControlRoom" [parseRoutes| /token/block/#Token TokenBlock GET /trips TripsViewR GET /trip/#TripID TripViewR GET +/obu OnboardUnitMenuR GET +/obu/#TripID/#Day OnboardUnitR GET |] emptyMarkup :: MarkupM a -> Bool @@ -308,6 +310,25 @@ getTokenBlock token = do redirect (TrainViewR runningTrip runningDay) Nothing -> notFound +getOnboardUnitMenuR :: Handler Html +getOnboardUnitMenuR = do + day <- liftIO getCurrentTime <&> utctDay + gtfs <- getYesod <&> getGtfs + let trips = tripsOnDay gtfs day + defaultLayout $ do + [whamlet| +

_{MsgOBU} +
+ _{MsgChooseTrain} + $forall Trip{..} <- trips +
+ + #{tripTripID}: #{stationName (stopStation (V.head tripStops))} #{stopDeparture (V.head tripStops)} +|] + +getOnboardUnitR :: TripID -> Day -> Handler Html +getOnboardUnitR tripId day = + defaultLayout $(whamletFile "site/obu.hamlet") announceForm :: Day -> TripID -> Html -> MForm Handler (FormResult Announcement, Widget) announceForm day tripId = renderDivs $ Announcement diff --git a/messages/de.msg b/messages/de.msg index 213337d..2da81b8 100644 --- a/messages/de.msg +++ b/messages/de.msg @@ -19,3 +19,6 @@ NoTrainPing: keine empfangen raw: roh EstimatedDelay: Geschätzte Verspätung OnStationSequence idx: an Stationsindex #{idx} + +ChooseTrain: Fahrt auswählen +TokenFailed: konnte kein Token erhalten diff --git a/messages/en.msg b/messages/en.msg index 47bb66d..2a9c67a 100644 --- a/messages/en.msg +++ b/messages/en.msg @@ -24,3 +24,8 @@ NoTrainPing: none received raw: raw EstimatedDelay: Estimated Delay OnStationSequence idx@String: on station index #{idx} + +OBU: Onboard-Unit +ChooseTrain: Choose a Train +TokenFailed: Failed to acquire token +PermissionFailed: permission failed diff --git a/site/obu.hamlet b/site/obu.hamlet new file mode 100644 index 0000000..d96b96f --- /dev/null +++ b/site/obu.hamlet @@ -0,0 +1,92 @@ +

_{MsgOBU} + +
+

#{tripId} _{Msgon} #{day} + Token: + +
+

_{MsgLive} +

Position: , +

Accuracy: + +

+

Status +

_{MsgNone} + + +