mirror of
https://github.com/jhillyerd/inbucket.git
synced 2026-01-08 12:11:55 +00:00
ui: Refactor page view/framing to handle titles
This commit is contained in:
@@ -19,12 +19,7 @@ type alias Model =
|
||||
|
||||
init : ( Model, Cmd Msg )
|
||||
init =
|
||||
( Model ""
|
||||
, Cmd.batch
|
||||
[ Ports.windowTitle "Inbucket"
|
||||
, cmdGreeting
|
||||
]
|
||||
)
|
||||
( Model "", cmdGreeting )
|
||||
|
||||
|
||||
cmdGreeting : Cmd Msg
|
||||
@@ -57,12 +52,15 @@ update session msg model =
|
||||
-- VIEW --
|
||||
|
||||
|
||||
view : Session -> Model -> Html Msg
|
||||
view : Session -> Model -> { title : String, content : Html Msg }
|
||||
view session model =
|
||||
div [ id "page" ]
|
||||
[ Html.node "rendered-html"
|
||||
[ class "greeting"
|
||||
, property "content" (Encode.string model.greeting)
|
||||
{ title = "Inbucket"
|
||||
, content =
|
||||
div [ id "page" ]
|
||||
[ Html.node "rendered-html"
|
||||
[ class "greeting"
|
||||
, property "content" (Encode.string model.greeting)
|
||||
]
|
||||
[]
|
||||
]
|
||||
[]
|
||||
]
|
||||
}
|
||||
|
||||
@@ -87,8 +87,7 @@ init mailboxName selection =
|
||||
load : String -> Cmd Msg
|
||||
load mailboxName =
|
||||
Cmd.batch
|
||||
[ Ports.windowTitle (mailboxName ++ " - Inbucket")
|
||||
, Task.perform Tick Time.now
|
||||
[ Task.perform Tick Time.now
|
||||
, getList mailboxName
|
||||
]
|
||||
|
||||
@@ -463,29 +462,32 @@ getMessage mailboxName id =
|
||||
-- VIEW
|
||||
|
||||
|
||||
view : Session -> Model -> Html Msg
|
||||
view : Session -> Model -> { title : String, content : Html Msg }
|
||||
view session model =
|
||||
div [ id "page", class "mailbox" ]
|
||||
[ viewMessageList session model
|
||||
, main_
|
||||
[ id "message" ]
|
||||
[ case model.state of
|
||||
ShowingList _ NoMessage ->
|
||||
text
|
||||
("Select a message on the left,"
|
||||
++ " or enter a different username into the box on upper right."
|
||||
)
|
||||
{ title = model.mailboxName ++ " - Inbucket"
|
||||
, content =
|
||||
div [ id "page", class "mailbox" ]
|
||||
[ viewMessageList session model
|
||||
, main_
|
||||
[ id "message" ]
|
||||
[ case model.state of
|
||||
ShowingList _ NoMessage ->
|
||||
text
|
||||
("Select a message on the left,"
|
||||
++ " or enter a different username into the box on upper right."
|
||||
)
|
||||
|
||||
ShowingList _ (ShowingMessage { message }) ->
|
||||
viewMessage message model.bodyMode
|
||||
ShowingList _ (ShowingMessage { message }) ->
|
||||
viewMessage message model.bodyMode
|
||||
|
||||
ShowingList _ (Transitioning { message }) ->
|
||||
viewMessage message model.bodyMode
|
||||
ShowingList _ (Transitioning { message }) ->
|
||||
viewMessage message model.bodyMode
|
||||
|
||||
_ ->
|
||||
text ""
|
||||
_ ->
|
||||
text ""
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
viewMessageList : Session -> Model -> Html Msg
|
||||
|
||||
@@ -32,12 +32,7 @@ type alias Model =
|
||||
|
||||
init : ( Model, Cmd Msg )
|
||||
init =
|
||||
( Model False []
|
||||
, Cmd.batch
|
||||
[ Ports.windowTitle "Inbucket Monitor"
|
||||
, Ports.monitorCommand True
|
||||
]
|
||||
)
|
||||
( Model False [], Ports.monitorCommand True )
|
||||
|
||||
|
||||
|
||||
@@ -95,32 +90,35 @@ update session msg model =
|
||||
-- VIEW
|
||||
|
||||
|
||||
view : Session -> Model -> Html Msg
|
||||
view : Session -> Model -> { title : String, content : Html Msg }
|
||||
view session model =
|
||||
div [ id "page" ]
|
||||
[ h1 [] [ text "Monitor" ]
|
||||
, p []
|
||||
[ text "Messages will be listed here shortly after delivery. "
|
||||
, em []
|
||||
[ text
|
||||
(if model.connected then
|
||||
"Connected."
|
||||
{ title = "Inbucket Monitor"
|
||||
, content =
|
||||
div [ id "page" ]
|
||||
[ h1 [] [ text "Monitor" ]
|
||||
, p []
|
||||
[ text "Messages will be listed here shortly after delivery. "
|
||||
, em []
|
||||
[ text
|
||||
(if model.connected then
|
||||
"Connected."
|
||||
|
||||
else
|
||||
"Disconnected!"
|
||||
)
|
||||
else
|
||||
"Disconnected!"
|
||||
)
|
||||
]
|
||||
]
|
||||
, table [ id "monitor" ]
|
||||
[ thead []
|
||||
[ th [] [ text "Date" ]
|
||||
, th [ class "desktop" ] [ text "From" ]
|
||||
, th [] [ text "Mailbox" ]
|
||||
, th [] [ text "Subject" ]
|
||||
]
|
||||
, tbody [] (List.map viewMessage model.messages)
|
||||
]
|
||||
]
|
||||
, table [ id "monitor" ]
|
||||
[ thead []
|
||||
[ th [] [ text "Date" ]
|
||||
, th [ class "desktop" ] [ text "From" ]
|
||||
, th [] [ text "Mailbox" ]
|
||||
, th [] [ text "Subject" ]
|
||||
]
|
||||
, tbody [] (List.map viewMessage model.messages)
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
viewMessage : MessageHeader -> Html Msg
|
||||
|
||||
@@ -217,38 +217,41 @@ getMetrics =
|
||||
-- VIEW --
|
||||
|
||||
|
||||
view : Session -> Model -> Html Msg
|
||||
view : Session -> Model -> { title : String, content : Html Msg }
|
||||
view session model =
|
||||
div [ id "page" ]
|
||||
[ h1 [] [ text "Status" ]
|
||||
, case model.metrics of
|
||||
Nothing ->
|
||||
div [] [ text "Loading metrics..." ]
|
||||
{ title = "Inbucket Status"
|
||||
, content =
|
||||
div [ id "page" ]
|
||||
[ h1 [] [ text "Status" ]
|
||||
, case model.metrics of
|
||||
Nothing ->
|
||||
div [] [ text "Loading metrics..." ]
|
||||
|
||||
Just metrics ->
|
||||
div []
|
||||
[ framePanel "General Metrics"
|
||||
[ viewMetric model.sysMem
|
||||
, viewMetric model.heapSize
|
||||
, viewMetric model.heapUsed
|
||||
, viewMetric model.heapObjects
|
||||
, viewMetric model.goRoutines
|
||||
, viewMetric model.webSockets
|
||||
Just metrics ->
|
||||
div []
|
||||
[ framePanel "General Metrics"
|
||||
[ viewMetric model.sysMem
|
||||
, viewMetric model.heapSize
|
||||
, viewMetric model.heapUsed
|
||||
, viewMetric model.heapObjects
|
||||
, viewMetric model.goRoutines
|
||||
, viewMetric model.webSockets
|
||||
]
|
||||
, framePanel "SMTP Metrics"
|
||||
[ viewMetric model.smtpConnOpen
|
||||
, viewMetric model.smtpConnTotal
|
||||
, viewMetric model.smtpReceivedTotal
|
||||
, viewMetric model.smtpErrorsTotal
|
||||
, viewMetric model.smtpWarnsTotal
|
||||
]
|
||||
, framePanel "Storage Metrics"
|
||||
[ viewMetric model.retentionDeletesTotal
|
||||
, viewMetric model.retainedCount
|
||||
, viewMetric model.retainedSize
|
||||
]
|
||||
]
|
||||
, framePanel "SMTP Metrics"
|
||||
[ viewMetric model.smtpConnOpen
|
||||
, viewMetric model.smtpConnTotal
|
||||
, viewMetric model.smtpReceivedTotal
|
||||
, viewMetric model.smtpErrorsTotal
|
||||
, viewMetric model.smtpWarnsTotal
|
||||
]
|
||||
, framePanel "Storage Metrics"
|
||||
[ viewMetric model.retentionDeletesTotal
|
||||
, viewMetric model.retainedCount
|
||||
, viewMetric model.retainedSize
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
viewMetric : Metric -> Html Msg
|
||||
|
||||
Reference in New Issue
Block a user