mi/sina/src/Page/SwitchInfo.elm

57 lines
1.6 KiB
Elm
Raw Normal View History

2020-11-16 17:35:33 +00:00
module Page.SwitchInfo exposing (view)
import Browser exposing (Document)
2020-11-16 21:00:55 +00:00
import Html exposing (br, img, p, span, text)
import Html.Attributes exposing (src)
2020-11-16 17:35:33 +00:00
import Layout exposing (template)
2020-11-16 21:00:55 +00:00
import Mi.Switch exposing (Switch)
2020-11-16 17:35:33 +00:00
import Page exposing (format)
2020-11-16 21:00:55 +00:00
import Time exposing (Month(..))
2020-11-16 17:35:33 +00:00
2020-11-16 21:00:55 +00:00
type alias Model a =
{ a | switchByID : Maybe Switch }
view : Model a -> Document msg
2020-11-16 17:35:33 +00:00
view { switchByID } =
case switchByID of
Nothing ->
template "Loading" [ text "Please wait..." ]
Just switch ->
let
title =
"Switch Details"
ended_at =
case switch.ended_at of
Nothing ->
span [] []
Just time ->
span []
[ text "Ended at: "
, format
time
, br [] []
]
in
template title
[ p
[]
[ img [ src switch.img_url ] []
, br [] []
, text "ID: "
, text switch.id
, br [] []
, text "Name: "
, text switch.who
, br [] []
, text "Started At: "
, format switch.started_at
, br [] []
, ended_at
]
]