mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
ui: Reformat with new elm-format
This commit is contained in:
@@ -18,4 +18,4 @@ date =
|
|||||||
Err error ->
|
Err error ->
|
||||||
fail error
|
fail error
|
||||||
in
|
in
|
||||||
string |> andThen convert
|
string |> andThen convert
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
module Data.Session
|
module Data.Session
|
||||||
exposing
|
exposing
|
||||||
( Session
|
( Msg(..)
|
||||||
, Persistent
|
, Persistent
|
||||||
, Msg(..)
|
, Session
|
||||||
, decoder
|
|
||||||
, decodeValueWithDefault
|
, decodeValueWithDefault
|
||||||
|
, decoder
|
||||||
, init
|
, init
|
||||||
, none
|
, none
|
||||||
, update
|
, update
|
||||||
@@ -74,7 +74,7 @@ update msg session =
|
|||||||
persistent =
|
persistent =
|
||||||
session.persistent
|
session.persistent
|
||||||
in
|
in
|
||||||
{ session | persistent = { persistent | recentMailboxes = recent } }
|
{ session | persistent = { persistent | recentMailboxes = recent } }
|
||||||
|
|
||||||
|
|
||||||
none : Msg
|
none : Msg
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
module Main exposing (..)
|
module Main exposing (..)
|
||||||
|
|
||||||
import Data.Session as Session exposing (Session, decoder)
|
import Data.Session as Session exposing (Session, decoder)
|
||||||
import Json.Decode as Decode exposing (Value)
|
|
||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
|
import Json.Decode as Decode exposing (Value)
|
||||||
import Navigation exposing (Location)
|
import Navigation exposing (Location)
|
||||||
import Page.Home as Home
|
import Page.Home as Home
|
||||||
import Page.Mailbox as Mailbox
|
import Page.Mailbox as Mailbox
|
||||||
@@ -45,7 +45,7 @@ init sessionValue location =
|
|||||||
route =
|
route =
|
||||||
Route.fromLocation location
|
Route.fromLocation location
|
||||||
in
|
in
|
||||||
applySession (setRoute route model)
|
applySession (setRoute route model)
|
||||||
|
|
||||||
|
|
||||||
type Msg
|
type Msg
|
||||||
@@ -118,17 +118,17 @@ update msg model =
|
|||||||
session =
|
session =
|
||||||
model.session
|
model.session
|
||||||
in
|
in
|
||||||
( { model | session = { session | persistent = persistent } }
|
( { model | session = { session | persistent = persistent } }
|
||||||
, Cmd.none
|
, Cmd.none
|
||||||
, Session.none
|
, Session.none
|
||||||
)
|
)
|
||||||
|
|
||||||
UpdateSession (Err error) ->
|
UpdateSession (Err error) ->
|
||||||
let
|
let
|
||||||
_ =
|
_ =
|
||||||
Debug.log "Error decoding session" error
|
Debug.log "Error decoding session" error
|
||||||
in
|
in
|
||||||
( model, Cmd.none, Session.none )
|
( model, Cmd.none, Session.none )
|
||||||
|
|
||||||
MailboxNameInput name ->
|
MailboxNameInput name ->
|
||||||
( { model | mailboxName = name }, Cmd.none, Session.none )
|
( { model | mailboxName = name }, Cmd.none, Session.none )
|
||||||
@@ -155,24 +155,24 @@ updatePage msg model =
|
|||||||
( newModel, subCmd, sessionMsg ) =
|
( newModel, subCmd, sessionMsg ) =
|
||||||
subUpdate model.session subMsg subModel
|
subUpdate model.session subMsg subModel
|
||||||
in
|
in
|
||||||
( { model | page = toPage newModel }, Cmd.map toMsg subCmd, sessionMsg )
|
( { model | page = toPage newModel }, Cmd.map toMsg subCmd, sessionMsg )
|
||||||
in
|
in
|
||||||
case ( msg, model.page ) of
|
case ( msg, model.page ) of
|
||||||
( HomeMsg subMsg, Home subModel ) ->
|
( HomeMsg subMsg, Home subModel ) ->
|
||||||
modelUpdate Home HomeMsg Home.update subMsg subModel
|
modelUpdate Home HomeMsg Home.update subMsg subModel
|
||||||
|
|
||||||
( MailboxMsg subMsg, Mailbox subModel ) ->
|
( MailboxMsg subMsg, Mailbox subModel ) ->
|
||||||
modelUpdate Mailbox MailboxMsg Mailbox.update subMsg subModel
|
modelUpdate Mailbox MailboxMsg Mailbox.update subMsg subModel
|
||||||
|
|
||||||
( MonitorMsg subMsg, Monitor subModel ) ->
|
( MonitorMsg subMsg, Monitor subModel ) ->
|
||||||
modelUpdate Monitor MonitorMsg Monitor.update subMsg subModel
|
modelUpdate Monitor MonitorMsg Monitor.update subMsg subModel
|
||||||
|
|
||||||
( StatusMsg subMsg, Status subModel ) ->
|
( StatusMsg subMsg, Status subModel ) ->
|
||||||
modelUpdate Status StatusMsg Status.update subMsg subModel
|
modelUpdate Status StatusMsg Status.update subMsg subModel
|
||||||
|
|
||||||
( _, _ ) ->
|
( _, _ ) ->
|
||||||
-- Disregard messages destined for the wrong page.
|
-- Disregard messages destined for the wrong page.
|
||||||
( model, Cmd.none, Session.none )
|
( model, Cmd.none, Session.none )
|
||||||
|
|
||||||
|
|
||||||
setRoute : Route -> Model -> ( Model, Cmd Msg, Session.Msg )
|
setRoute : Route -> Model -> ( Model, Cmd Msg, Session.Msg )
|
||||||
@@ -192,20 +192,20 @@ setRoute route model =
|
|||||||
( subModel, subCmd ) =
|
( subModel, subCmd ) =
|
||||||
Mailbox.init name Nothing
|
Mailbox.init name Nothing
|
||||||
in
|
in
|
||||||
( { model | page = Mailbox subModel }
|
( { model | page = Mailbox subModel }
|
||||||
, Cmd.map MailboxMsg subCmd
|
, Cmd.map MailboxMsg subCmd
|
||||||
, Session.none
|
, Session.none
|
||||||
)
|
)
|
||||||
|
|
||||||
Route.Message mailbox id ->
|
Route.Message mailbox id ->
|
||||||
let
|
let
|
||||||
( subModel, subCmd ) =
|
( subModel, subCmd ) =
|
||||||
Mailbox.init mailbox (Just id)
|
Mailbox.init mailbox (Just id)
|
||||||
in
|
in
|
||||||
( { model | page = Mailbox subModel }
|
( { model | page = Mailbox subModel }
|
||||||
, Cmd.map MailboxMsg subCmd
|
, Cmd.map MailboxMsg subCmd
|
||||||
, Session.none
|
, Session.none
|
||||||
)
|
)
|
||||||
|
|
||||||
Route.Monitor ->
|
Route.Monitor ->
|
||||||
( { model | page = Monitor (Monitor.init model.session.host) }
|
( { model | page = Monitor (Monitor.init model.session.host) }
|
||||||
@@ -217,7 +217,7 @@ setRoute route model =
|
|||||||
( { model | page = Status Status.init }
|
( { model | page = Status Status.init }
|
||||||
, Cmd.batch
|
, Cmd.batch
|
||||||
[ Ports.windowTitle "Inbucket Status"
|
[ Ports.windowTitle "Inbucket Status"
|
||||||
, Cmd.map StatusMsg (Status.load)
|
, Cmd.map StatusMsg Status.load
|
||||||
]
|
]
|
||||||
, Session.none
|
, Session.none
|
||||||
)
|
)
|
||||||
@@ -232,13 +232,13 @@ applySession ( model, cmd, sessionMsg ) =
|
|||||||
newModel =
|
newModel =
|
||||||
{ model | session = session }
|
{ model | session = session }
|
||||||
in
|
in
|
||||||
if session.persistent == model.session.persistent then
|
if session.persistent == model.session.persistent then
|
||||||
-- No change
|
-- No change
|
||||||
( newModel, cmd )
|
( newModel, cmd )
|
||||||
else
|
else
|
||||||
( newModel
|
( newModel
|
||||||
, Cmd.batch [ cmd, Ports.storeSession session.persistent ]
|
, Cmd.batch [ cmd, Ports.storeSession session.persistent ]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -267,22 +267,22 @@ view model =
|
|||||||
frame =
|
frame =
|
||||||
Page.frame controls model.session
|
Page.frame controls model.session
|
||||||
in
|
in
|
||||||
case model.page of
|
case model.page of
|
||||||
Home subModel ->
|
Home subModel ->
|
||||||
Html.map HomeMsg (Home.view model.session subModel)
|
Html.map HomeMsg (Home.view model.session subModel)
|
||||||
|> frame Page.Other
|
|> frame Page.Other
|
||||||
|
|
||||||
Mailbox subModel ->
|
Mailbox subModel ->
|
||||||
Html.map MailboxMsg (Mailbox.view model.session subModel)
|
Html.map MailboxMsg (Mailbox.view model.session subModel)
|
||||||
|> frame Page.Mailbox
|
|> frame Page.Mailbox
|
||||||
|
|
||||||
Monitor subModel ->
|
Monitor subModel ->
|
||||||
Html.map MonitorMsg (Monitor.view model.session subModel)
|
Html.map MonitorMsg (Monitor.view model.session subModel)
|
||||||
|> frame Page.Monitor
|
|> frame Page.Monitor
|
||||||
|
|
||||||
Status subModel ->
|
Status subModel ->
|
||||||
Html.map StatusMsg (Status.view model.session subModel)
|
Html.map StatusMsg (Status.view model.session subModel)
|
||||||
|> frame Page.Status
|
|> frame Page.Status
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
module Page.Home exposing (Model, Msg, init, update, view)
|
module Page.Home exposing (Model, Msg, init, update, view)
|
||||||
|
|
||||||
|
import Data.Session as Session exposing (Session)
|
||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Data.Session as Session exposing (Session)
|
|
||||||
|
|
||||||
|
|
||||||
-- MODEL --
|
-- MODEL --
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ import Data.Message as Message exposing (Message)
|
|||||||
import Data.MessageHeader as MessageHeader exposing (MessageHeader)
|
import Data.MessageHeader as MessageHeader exposing (MessageHeader)
|
||||||
import Data.Session as Session exposing (Session)
|
import Data.Session as Session exposing (Session)
|
||||||
import Date exposing (Date)
|
import Date exposing (Date)
|
||||||
import DateFormat.Relative as Relative
|
|
||||||
import DateFormat
|
import DateFormat
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import DateFormat.Relative as Relative
|
||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
import Html.Attributes
|
import Html.Attributes
|
||||||
exposing
|
exposing
|
||||||
@@ -24,6 +23,7 @@ import Html.Attributes
|
|||||||
import Html.Events exposing (..)
|
import Html.Events exposing (..)
|
||||||
import Http exposing (Error)
|
import Http exposing (Error)
|
||||||
import HttpUtil
|
import HttpUtil
|
||||||
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
import Json.Encode as Encode
|
import Json.Encode as Encode
|
||||||
import Ports
|
import Ports
|
||||||
import Route
|
import Route
|
||||||
@@ -111,10 +111,10 @@ subscriptions model =
|
|||||||
_ ->
|
_ ->
|
||||||
Sub.none
|
Sub.none
|
||||||
in
|
in
|
||||||
Sub.batch
|
Sub.batch
|
||||||
[ Time.every (30 * Time.second) Tick
|
[ Time.every (30 * Time.second) Tick
|
||||||
, subSeen
|
, subSeen
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -175,13 +175,13 @@ update session msg model =
|
|||||||
| state = ShowingList (MessageList headers Nothing "") NoMessage
|
| state = ShowingList (MessageList headers Nothing "") NoMessage
|
||||||
}
|
}
|
||||||
in
|
in
|
||||||
case selection of
|
case selection of
|
||||||
Just id ->
|
Just id ->
|
||||||
-- Recurse to select message id.
|
-- Recurse to select message id.
|
||||||
update session (ViewMessage id) newModel
|
update session (ViewMessage id) newModel
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
( newModel, Cmd.none, Session.AddRecent model.mailboxName )
|
( newModel, Cmd.none, Session.AddRecent model.mailboxName )
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
( model, Cmd.none, Session.none )
|
( model, Cmd.none, Session.none )
|
||||||
@@ -270,21 +270,21 @@ updateMessageResult model message =
|
|||||||
else
|
else
|
||||||
model.bodyMode
|
model.bodyMode
|
||||||
in
|
in
|
||||||
case model.state of
|
case model.state of
|
||||||
LoadingList _ ->
|
LoadingList _ ->
|
||||||
( model, Cmd.none, Session.none )
|
( model, Cmd.none, Session.none )
|
||||||
|
|
||||||
ShowingList list _ ->
|
ShowingList list _ ->
|
||||||
( { model
|
( { model
|
||||||
| state =
|
| state =
|
||||||
ShowingList
|
ShowingList
|
||||||
{ list | selected = Just message.id }
|
{ list | selected = Just message.id }
|
||||||
(ShowingMessage (VisibleMessage message Nothing))
|
(ShowingMessage (VisibleMessage message Nothing))
|
||||||
, bodyMode = bodyMode
|
, bodyMode = bodyMode
|
||||||
}
|
}
|
||||||
, Task.perform OpenedTime Time.now
|
, Task.perform OpenedTime Time.now
|
||||||
, Session.none
|
, Session.none
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
updatePurge : Model -> ( Model, Cmd Msg, Session.Msg )
|
updatePurge : Model -> ( Model, Cmd Msg, Session.Msg )
|
||||||
@@ -296,15 +296,15 @@ updatePurge model =
|
|||||||
|> HttpUtil.delete
|
|> HttpUtil.delete
|
||||||
|> Http.send PurgeResult
|
|> Http.send PurgeResult
|
||||||
in
|
in
|
||||||
case model.state of
|
case model.state of
|
||||||
ShowingList list _ ->
|
ShowingList list _ ->
|
||||||
( { model | state = ShowingList (MessageList [] Nothing "") NoMessage }
|
( { model | state = ShowingList (MessageList [] Nothing "") NoMessage }
|
||||||
, cmd
|
, cmd
|
||||||
, Session.none
|
, Session.none
|
||||||
)
|
)
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
( model, cmd, Session.none )
|
( model, cmd, Session.none )
|
||||||
|
|
||||||
|
|
||||||
updateSearchInput : Model -> String -> ( Model, Cmd Msg, Session.Msg )
|
updateSearchInput : Model -> String -> ( Model, Cmd Msg, Session.Msg )
|
||||||
@@ -316,18 +316,18 @@ updateSearchInput model searchInput =
|
|||||||
else
|
else
|
||||||
""
|
""
|
||||||
in
|
in
|
||||||
case model.state of
|
case model.state of
|
||||||
LoadingList _ ->
|
LoadingList _ ->
|
||||||
( model, Cmd.none, Session.none )
|
( model, Cmd.none, Session.none )
|
||||||
|
|
||||||
ShowingList list messageState ->
|
ShowingList list messageState ->
|
||||||
( { model
|
( { model
|
||||||
| searchInput = searchInput
|
| searchInput = searchInput
|
||||||
, state = ShowingList { list | searchFilter = searchFilter } messageState
|
, state = ShowingList { list | searchFilter = searchFilter } messageState
|
||||||
}
|
}
|
||||||
, Cmd.none
|
, Cmd.none
|
||||||
, Session.none
|
, Session.none
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
{-| Set the selected message in our model.
|
{-| Set the selected message in our model.
|
||||||
@@ -343,19 +343,19 @@ updateSelected model id =
|
|||||||
newList =
|
newList =
|
||||||
{ list | selected = Just id }
|
{ list | selected = Just id }
|
||||||
in
|
in
|
||||||
case messageState of
|
case messageState of
|
||||||
NoMessage ->
|
NoMessage ->
|
||||||
{ model | state = ShowingList newList LoadingMessage }
|
{ model | state = ShowingList newList LoadingMessage }
|
||||||
|
|
||||||
LoadingMessage ->
|
LoadingMessage ->
|
||||||
{ model | state = ShowingList newList LoadingMessage }
|
{ model | state = ShowingList newList LoadingMessage }
|
||||||
|
|
||||||
ShowingMessage visible ->
|
ShowingMessage visible ->
|
||||||
-- Use Transitioning state to prevent blank message flicker.
|
-- Use Transitioning state to prevent blank message flicker.
|
||||||
{ model | state = ShowingList newList (Transitioning visible) }
|
{ model | state = ShowingList newList (Transitioning visible) }
|
||||||
|
|
||||||
Transitioning visible ->
|
Transitioning visible ->
|
||||||
{ model | state = ShowingList newList (Transitioning visible) }
|
{ model | state = ShowingList newList (Transitioning visible) }
|
||||||
|
|
||||||
|
|
||||||
updateDeleteMessage : Model -> Message -> ( Model, Cmd Msg, Session.Msg )
|
updateDeleteMessage : Model -> Message -> ( Model, Cmd Msg, Session.Msg )
|
||||||
@@ -371,18 +371,18 @@ updateDeleteMessage model message =
|
|||||||
filter f messageList =
|
filter f messageList =
|
||||||
{ messageList | headers = List.filter f messageList.headers }
|
{ messageList | headers = List.filter f messageList.headers }
|
||||||
in
|
in
|
||||||
case model.state of
|
case model.state of
|
||||||
ShowingList list _ ->
|
ShowingList list _ ->
|
||||||
( { model
|
( { model
|
||||||
| state =
|
| state =
|
||||||
ShowingList (filter (\x -> x.id /= message.id) list) NoMessage
|
ShowingList (filter (\x -> x.id /= message.id) list) NoMessage
|
||||||
}
|
}
|
||||||
, cmd
|
, cmd
|
||||||
, Session.none
|
, Session.none
|
||||||
)
|
)
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
( model, cmd, Session.none )
|
( model, cmd, Session.none )
|
||||||
|
|
||||||
|
|
||||||
updateMarkMessageSeen : Model -> Message -> ( Model, Cmd Msg, Session.Msg )
|
updateMarkMessageSeen : Model -> Message -> ( Model, Cmd Msg, Session.Msg )
|
||||||
@@ -410,19 +410,19 @@ updateMarkMessageSeen model message =
|
|||||||
map f messageList =
|
map f messageList =
|
||||||
{ messageList | headers = List.map f messageList.headers }
|
{ messageList | headers = List.map f messageList.headers }
|
||||||
in
|
in
|
||||||
( { model
|
( { model
|
||||||
| state =
|
| state =
|
||||||
ShowingList (map updateSeen list)
|
ShowingList (map updateSeen list)
|
||||||
(ShowingMessage
|
(ShowingMessage
|
||||||
{ visible
|
{ visible
|
||||||
| message = { message | seen = True }
|
| message = { message | seen = True }
|
||||||
, markSeenAt = Nothing
|
, markSeenAt = Nothing
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
, command
|
, command
|
||||||
, Session.None
|
, Session.None
|
||||||
)
|
)
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
( model, Cmd.none, Session.none )
|
( model, Cmd.none, Session.none )
|
||||||
@@ -434,8 +434,8 @@ getList mailboxName =
|
|||||||
url =
|
url =
|
||||||
"/api/v1/mailbox/" ++ mailboxName
|
"/api/v1/mailbox/" ++ mailboxName
|
||||||
in
|
in
|
||||||
Http.get url (Decode.list MessageHeader.decoder)
|
Http.get url (Decode.list MessageHeader.decoder)
|
||||||
|> Http.send ListResult
|
|> Http.send ListResult
|
||||||
|
|
||||||
|
|
||||||
getMessage : String -> MessageID -> Cmd Msg
|
getMessage : String -> MessageID -> Cmd Msg
|
||||||
@@ -444,8 +444,8 @@ getMessage mailboxName id =
|
|||||||
url =
|
url =
|
||||||
"/serve/m/" ++ mailboxName ++ "/" ++ id
|
"/serve/m/" ++ mailboxName ++ "/" ++ id
|
||||||
in
|
in
|
||||||
Http.get url Message.decoder
|
Http.get url Message.decoder
|
||||||
|> Http.send MessageResult
|
|> Http.send MessageResult
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -526,26 +526,26 @@ viewMessage message bodyMode =
|
|||||||
sourceUrl message =
|
sourceUrl message =
|
||||||
"/serve/m/" ++ message.mailbox ++ "/" ++ message.id ++ "/source"
|
"/serve/m/" ++ message.mailbox ++ "/" ++ message.id ++ "/source"
|
||||||
in
|
in
|
||||||
div []
|
div []
|
||||||
[ div [ class "button-bar" ]
|
[ div [ class "button-bar" ]
|
||||||
[ button [ class "danger", onClick (DeleteMessage message) ] [ text "Delete" ]
|
[ button [ class "danger", onClick (DeleteMessage message) ] [ text "Delete" ]
|
||||||
, a
|
, a
|
||||||
[ href (sourceUrl message), target "_blank" ]
|
[ href (sourceUrl message), target "_blank" ]
|
||||||
[ button [] [ text "Source" ] ]
|
[ button [] [ text "Source" ] ]
|
||||||
]
|
|
||||||
, dl [ id "message-header" ]
|
|
||||||
[ dt [] [ text "From:" ]
|
|
||||||
, dd [] [ text message.from ]
|
|
||||||
, dt [] [ text "To:" ]
|
|
||||||
, dd [] (List.map text message.to)
|
|
||||||
, dt [] [ text "Date:" ]
|
|
||||||
, dd [] [ verboseDate message.date ]
|
|
||||||
, dt [] [ text "Subject:" ]
|
|
||||||
, dd [] [ text message.subject ]
|
|
||||||
]
|
|
||||||
, messageBody message bodyMode
|
|
||||||
, attachments message
|
|
||||||
]
|
]
|
||||||
|
, dl [ id "message-header" ]
|
||||||
|
[ dt [] [ text "From:" ]
|
||||||
|
, dd [] [ text message.from ]
|
||||||
|
, dt [] [ text "To:" ]
|
||||||
|
, dd [] (List.map text message.to)
|
||||||
|
, dt [] [ text "Date:" ]
|
||||||
|
, dd [] [ verboseDate message.date ]
|
||||||
|
, dt [] [ text "Subject:" ]
|
||||||
|
, dd [] [ text message.subject ]
|
||||||
|
]
|
||||||
|
, messageBody message bodyMode
|
||||||
|
, attachments message
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
messageBody : Message -> Body -> Html Msg
|
messageBody : Message -> Body -> Html Msg
|
||||||
@@ -571,17 +571,17 @@ messageBody message bodyMode =
|
|||||||
else
|
else
|
||||||
[ safeHtml, plainText ]
|
[ safeHtml, plainText ]
|
||||||
in
|
in
|
||||||
div [ class "tab-panel" ]
|
div [ class "tab-panel" ]
|
||||||
[ nav [ class "tab-bar" ] tabs
|
[ nav [ class "tab-bar" ] tabs
|
||||||
, article [ class "message-body" ]
|
, article [ class "message-body" ]
|
||||||
[ case bodyMode of
|
[ case bodyMode of
|
||||||
SafeHtmlBody ->
|
SafeHtmlBody ->
|
||||||
div [ property "innerHTML" (Encode.string message.html) ] []
|
div [ property "innerHTML" (Encode.string message.html) ] []
|
||||||
|
|
||||||
TextBody ->
|
TextBody ->
|
||||||
div [ property "innerHTML" (Encode.string message.text) ] []
|
div [ property "innerHTML" (Encode.string message.text) ] []
|
||||||
]
|
|
||||||
]
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
attachments : Message -> Html Msg
|
attachments : Message -> Html Msg
|
||||||
@@ -590,10 +590,10 @@ attachments message =
|
|||||||
baseUrl =
|
baseUrl =
|
||||||
"/serve/m/attach/" ++ message.mailbox ++ "/" ++ message.id ++ "/"
|
"/serve/m/attach/" ++ message.mailbox ++ "/" ++ message.id ++ "/"
|
||||||
in
|
in
|
||||||
if List.isEmpty message.attachments then
|
if List.isEmpty message.attachments then
|
||||||
div [] []
|
div [] []
|
||||||
else
|
else
|
||||||
table [ class "attachments well" ] (List.map (attachmentRow baseUrl) message.attachments)
|
table [ class "attachments well" ] (List.map (attachmentRow baseUrl) message.attachments)
|
||||||
|
|
||||||
|
|
||||||
attachmentRow : String -> Message.Attachment -> Html Msg
|
attachmentRow : String -> Message.Attachment -> Html Msg
|
||||||
@@ -602,13 +602,13 @@ attachmentRow baseUrl attach =
|
|||||||
url =
|
url =
|
||||||
baseUrl ++ attach.id ++ "/" ++ attach.fileName
|
baseUrl ++ attach.id ++ "/" ++ attach.fileName
|
||||||
in
|
in
|
||||||
tr []
|
tr []
|
||||||
[ td []
|
[ td []
|
||||||
[ a [ href url, target "_blank" ] [ text attach.fileName ]
|
[ a [ href url, target "_blank" ] [ text attach.fileName ]
|
||||||
, text (" (" ++ attach.contentType ++ ") ")
|
, text (" (" ++ attach.contentType ++ ") ")
|
||||||
]
|
|
||||||
, td [] [ a [ href url, downloadAs attach.fileName, class "button" ] [ text "Download" ] ]
|
|
||||||
]
|
]
|
||||||
|
, td [] [ a [ href url, downloadAs attach.fileName, class "button" ] [ text "Download" ] ]
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
relativeDate : Model -> Date -> Html Msg
|
relativeDate : Model -> Date -> Html Msg
|
||||||
@@ -651,4 +651,4 @@ filterMessageList list =
|
|||||||
String.contains list.searchFilter (String.toLower header.subject)
|
String.contains list.searchFilter (String.toLower header.subject)
|
||||||
|| String.contains list.searchFilter (String.toLower header.from)
|
|| String.contains list.searchFilter (String.toLower header.from)
|
||||||
in
|
in
|
||||||
List.filter matches list.headers
|
List.filter matches list.headers
|
||||||
|
|||||||
@@ -5,17 +5,17 @@ import Data.Session as Session exposing (Session)
|
|||||||
import Date exposing (Date)
|
import Date exposing (Date)
|
||||||
import DateFormat
|
import DateFormat
|
||||||
exposing
|
exposing
|
||||||
( format
|
( amPmUppercase
|
||||||
, monthNameFirstThree
|
|
||||||
, dayOfMonthFixed
|
, dayOfMonthFixed
|
||||||
|
, format
|
||||||
, hourNumber
|
, hourNumber
|
||||||
, minuteFixed
|
, minuteFixed
|
||||||
, amPmUppercase
|
, monthNameFirstThree
|
||||||
)
|
)
|
||||||
import Json.Decode exposing (decodeString)
|
|
||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Html.Events as Events
|
import Html.Events as Events
|
||||||
|
import Json.Decode exposing (decodeString)
|
||||||
import Route
|
import Route
|
||||||
import WebSocket
|
import WebSocket
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import Html exposing (..)
|
|||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Http exposing (Error)
|
import Http exposing (Error)
|
||||||
import HttpUtil
|
import HttpUtil
|
||||||
import Sparkline exposing (sparkline, Point, DataSet, Size)
|
import Sparkline exposing (DataSet, Point, Size, sparkline)
|
||||||
import Svg.Attributes as SvgAttrib
|
import Svg.Attributes as SvgAttrib
|
||||||
import Time exposing (Time)
|
import Time exposing (Time)
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ init =
|
|||||||
initDataSet : DataSet
|
initDataSet : DataSet
|
||||||
initDataSet =
|
initDataSet =
|
||||||
List.range 0 59
|
List.range 0 59
|
||||||
|> List.map (\x -> ( toFloat (x), 0 ))
|
|> List.map (\x -> ( toFloat x, 0 ))
|
||||||
|
|
||||||
|
|
||||||
load : Cmd Msg
|
load : Cmd Msg
|
||||||
@@ -116,52 +116,52 @@ updateMetrics metrics model =
|
|||||||
x =
|
x =
|
||||||
model.xCounter
|
model.xCounter
|
||||||
in
|
in
|
||||||
{ model
|
{ model
|
||||||
| metrics = Just metrics
|
| metrics = Just metrics
|
||||||
, xCounter = x + 1
|
, xCounter = x + 1
|
||||||
, sysMem = updateLocalMetric model.sysMem x metrics.sysMem
|
, sysMem = updateLocalMetric model.sysMem x metrics.sysMem
|
||||||
, heapSize = updateLocalMetric model.heapSize x metrics.heapSize
|
, heapSize = updateLocalMetric model.heapSize x metrics.heapSize
|
||||||
, heapUsed = updateLocalMetric model.heapUsed x metrics.heapUsed
|
, heapUsed = updateLocalMetric model.heapUsed x metrics.heapUsed
|
||||||
, heapObjects = updateLocalMetric model.heapObjects x metrics.heapObjects
|
, heapObjects = updateLocalMetric model.heapObjects x metrics.heapObjects
|
||||||
, goRoutines = updateLocalMetric model.goRoutines x metrics.goRoutines
|
, goRoutines = updateLocalMetric model.goRoutines x metrics.goRoutines
|
||||||
, webSockets = updateLocalMetric model.webSockets x metrics.webSockets
|
, webSockets = updateLocalMetric model.webSockets x metrics.webSockets
|
||||||
, smtpConnOpen = updateLocalMetric model.smtpConnOpen x metrics.smtpConnOpen
|
, smtpConnOpen = updateLocalMetric model.smtpConnOpen x metrics.smtpConnOpen
|
||||||
, smtpConnTotal =
|
, smtpConnTotal =
|
||||||
updateRemoteTotal
|
updateRemoteTotal
|
||||||
model.smtpConnTotal
|
model.smtpConnTotal
|
||||||
metrics.smtpConnTotal
|
metrics.smtpConnTotal
|
||||||
metrics.smtpConnHist
|
metrics.smtpConnHist
|
||||||
, smtpReceivedTotal =
|
, smtpReceivedTotal =
|
||||||
updateRemoteTotal
|
updateRemoteTotal
|
||||||
model.smtpReceivedTotal
|
model.smtpReceivedTotal
|
||||||
metrics.smtpReceivedTotal
|
metrics.smtpReceivedTotal
|
||||||
metrics.smtpReceivedHist
|
metrics.smtpReceivedHist
|
||||||
, smtpErrorsTotal =
|
, smtpErrorsTotal =
|
||||||
updateRemoteTotal
|
updateRemoteTotal
|
||||||
model.smtpErrorsTotal
|
model.smtpErrorsTotal
|
||||||
metrics.smtpErrorsTotal
|
metrics.smtpErrorsTotal
|
||||||
metrics.smtpErrorsHist
|
metrics.smtpErrorsHist
|
||||||
, smtpWarnsTotal =
|
, smtpWarnsTotal =
|
||||||
updateRemoteTotal
|
updateRemoteTotal
|
||||||
model.smtpWarnsTotal
|
model.smtpWarnsTotal
|
||||||
metrics.smtpWarnsTotal
|
metrics.smtpWarnsTotal
|
||||||
metrics.smtpWarnsHist
|
metrics.smtpWarnsHist
|
||||||
, retentionDeletesTotal =
|
, retentionDeletesTotal =
|
||||||
updateRemoteTotal
|
updateRemoteTotal
|
||||||
model.retentionDeletesTotal
|
model.retentionDeletesTotal
|
||||||
metrics.retentionDeletesTotal
|
metrics.retentionDeletesTotal
|
||||||
metrics.retentionDeletesHist
|
metrics.retentionDeletesHist
|
||||||
, retainedCount =
|
, retainedCount =
|
||||||
updateRemoteMetric
|
updateRemoteMetric
|
||||||
model.retainedCount
|
model.retainedCount
|
||||||
metrics.retainedCount
|
metrics.retainedCount
|
||||||
metrics.retainedCountHist
|
metrics.retainedCountHist
|
||||||
, retainedSize =
|
, retainedSize =
|
||||||
updateRemoteMetric
|
updateRemoteMetric
|
||||||
model.retainedSize
|
model.retainedSize
|
||||||
metrics.retainedSize
|
metrics.retainedSize
|
||||||
metrics.retainedSizeHist
|
metrics.retainedSizeHist
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{-| Update a single Metric, with history tracked locally.
|
{-| Update a single Metric, with history tracked locally.
|
||||||
@@ -171,8 +171,8 @@ updateLocalMetric metric x value =
|
|||||||
{ metric
|
{ metric
|
||||||
| value = value
|
| value = value
|
||||||
, history =
|
, history =
|
||||||
(Maybe.withDefault [] (List.tail metric.history))
|
Maybe.withDefault [] (List.tail metric.history)
|
||||||
++ [ ( x, (toFloat value) ) ]
|
++ [ ( x, toFloat value ) ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -320,11 +320,11 @@ graphChange data =
|
|||||||
Just point ->
|
Just point ->
|
||||||
Tuple.first point
|
Tuple.first point
|
||||||
in
|
in
|
||||||
sparkline graphSize
|
sparkline graphSize
|
||||||
[ Sparkline.Bar 2.5 data |> barStyle
|
[ Sparkline.Bar 2.5 data |> barStyle
|
||||||
, Sparkline.ZeroLine |> zeroStyle
|
, Sparkline.ZeroLine |> zeroStyle
|
||||||
, Sparkline.Domain [ ( x, 0 ), ( x, 1 ) ]
|
, Sparkline.Domain [ ( x, 0 ), ( x, 1 ) ]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
{-| Zero based area graph, for charting absolute values relative to 0.
|
{-| Zero based area graph, for charting absolute values relative to 0.
|
||||||
@@ -341,11 +341,11 @@ graphZero data =
|
|||||||
Just point ->
|
Just point ->
|
||||||
Tuple.first point
|
Tuple.first point
|
||||||
in
|
in
|
||||||
sparkline graphSize
|
sparkline graphSize
|
||||||
[ Sparkline.Area data |> areaStyle
|
[ Sparkline.Area data |> areaStyle
|
||||||
, Sparkline.ZeroLine |> zeroStyle
|
, Sparkline.ZeroLine |> zeroStyle
|
||||||
, Sparkline.Domain [ ( x, 0 ), ( x, 1 ) ]
|
, Sparkline.Domain [ ( x, 0 ), ( x, 1 ) ]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
framePanel : String -> List (Html a) -> Html a
|
framePanel : String -> List (Html a) -> Html a
|
||||||
@@ -368,7 +368,7 @@ changeList numbers =
|
|||||||
tail =
|
tail =
|
||||||
List.tail numbers |> Maybe.withDefault []
|
List.tail numbers |> Maybe.withDefault []
|
||||||
in
|
in
|
||||||
List.map2 (-) tail numbers
|
List.map2 (-) tail numbers
|
||||||
|
|
||||||
|
|
||||||
{-| Pad the front of a list with 0s to make it at least 60 elements long.
|
{-| Pad the front of a list with 0s to make it at least 60 elements long.
|
||||||
@@ -379,10 +379,10 @@ zeroPadList numbers =
|
|||||||
needed =
|
needed =
|
||||||
60 - List.length numbers
|
60 - List.length numbers
|
||||||
in
|
in
|
||||||
if needed > 0 then
|
if needed > 0 then
|
||||||
(List.repeat needed 0) ++ numbers
|
List.repeat needed 0 ++ numbers
|
||||||
else
|
else
|
||||||
numbers
|
numbers
|
||||||
|
|
||||||
|
|
||||||
{-| Format an Int with thousands separators.
|
{-| Format an Int with thousands separators.
|
||||||
@@ -395,6 +395,6 @@ fmtInt n =
|
|||||||
if String.length str <= 3 then
|
if String.length str <= 3 then
|
||||||
str
|
str
|
||||||
else
|
else
|
||||||
(thousands (String.slice 0 -3 str)) ++ "," ++ (String.right 3 str)
|
thousands (String.slice 0 -3 str) ++ "," ++ String.right 3 str
|
||||||
in
|
in
|
||||||
thousands (toString n)
|
thousands (toString n)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ routeToString page =
|
|||||||
Status ->
|
Status ->
|
||||||
[ "status" ]
|
[ "status" ]
|
||||||
in
|
in
|
||||||
"/#/" ++ String.join "/" pieces
|
"/#/" ++ String.join "/" pieces
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import Html.Attributes
|
|||||||
, href
|
, href
|
||||||
, id
|
, id
|
||||||
, placeholder
|
, placeholder
|
||||||
, type_
|
|
||||||
, selected
|
, selected
|
||||||
|
, type_
|
||||||
, value
|
, value
|
||||||
)
|
)
|
||||||
import Html.Events as Events
|
import Html.Events as Events
|
||||||
@@ -101,13 +101,13 @@ navbarRecent page controls =
|
|||||||
else
|
else
|
||||||
controls.recentOptions
|
controls.recentOptions
|
||||||
in
|
in
|
||||||
li
|
li
|
||||||
[ id "navbar-recent"
|
[ id "navbar-recent"
|
||||||
, classList [ ( "navbar-dropdown", True ), ( "navbar-active", active ) ]
|
, classList [ ( "navbar-dropdown", True ), ( "navbar-active", active ) ]
|
||||||
]
|
]
|
||||||
[ span [] [ text title ]
|
[ span [] [ text title ]
|
||||||
, div [ class "navbar-dropdown-content" ] (List.map recentItemLink items)
|
, div [ class "navbar-dropdown-content" ] (List.map recentItemLink items)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
isActive : ActivePage -> Route -> Bool
|
isActive : ActivePage -> Route -> Bool
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
module Tests exposing (..)
|
module Tests exposing (..)
|
||||||
|
|
||||||
import Test exposing (..)
|
|
||||||
import Expect
|
import Expect
|
||||||
|
import Test exposing (..)
|
||||||
|
|
||||||
|
|
||||||
-- Check out http://package.elm-lang.org/packages/elm-community/elm-test/latest to learn more about testing in Elm!
|
-- Check out http://package.elm-lang.org/packages/elm-community/elm-test/latest to learn more about testing in Elm!
|
||||||
|
|||||||
Reference in New Issue
Block a user