Finish mail settings

This commit is contained in:
Eike Kettner
2020-01-07 00:20:28 +01:00
parent f235f3a030
commit 32050a9faf
11 changed files with 391 additions and 57 deletions

View File

@ -2,6 +2,7 @@ module Comp.EmailSettingsTable exposing
( Model
, Msg
, emptyModel
, init
, update
, view
)
@ -9,10 +10,12 @@ module Comp.EmailSettingsTable exposing
import Api.Model.EmailSettings exposing (EmailSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
type alias Model =
{ emailSettings : List EmailSettings
, selected : Maybe EmailSettings
}
@ -24,6 +27,7 @@ emptyModel =
init : List EmailSettings -> Model
init ems =
{ emailSettings = ems
, selected = Nothing
}
@ -33,17 +37,40 @@ type Msg
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
( model, Cmd.none )
case msg of
Select ems ->
( { model | selected = Just ems }, Cmd.none )
view : Model -> Html Msg
view model =
table [ class "ui table" ]
table [ class "ui selectable pointer table" ]
[ thead []
[ th [] [ text "Name" ]
[ th [ class "collapsible" ] [ text "Name" ]
, th [] [ text "Host/Port" ]
, th [] [ text "From" ]
]
, tbody []
[]
(List.map (renderLine model) model.emailSettings)
]
renderLine : Model -> EmailSettings -> Html Msg
renderLine model ems =
let
hostport =
case ems.smtpPort of
Just p ->
ems.smtpHost ++ ":" ++ String.fromInt p
Nothing ->
ems.smtpHost
in
tr
[ classList [ ( "active", model.selected == Just ems ) ]
, onClick (Select ems)
]
[ td [ class "collapsible" ] [ text ems.name ]
, td [] [ text hostport ]
, td [] [ text ems.from ]
]