Starting with mail settings

This commit is contained in:
Eike Kettner
2020-01-05 00:12:23 +01:00
parent 9020d9aa3b
commit 2e3454c7a1
12 changed files with 519 additions and 4 deletions

View File

@ -0,0 +1,68 @@
module Comp.EmailSettingsForm exposing
( Model
, Msg
, emptyModel
, update
, view
)
import Api.Model.EmailSettings exposing (EmailSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
type alias Model =
{ settings : EmailSettings
, name : String
}
emptyModel : Model
emptyModel =
{ settings = Api.Model.EmailSettings.empty
, name = ""
}
init : EmailSettings -> Model
init ems =
{ settings = ems
, name = ems.name
}
type Msg
= SetName String
isValid : Model -> Bool
isValid model =
True
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
( model, Cmd.none )
view : Model -> Html Msg
view model =
div
[ classList
[ ( "ui form", True )
, ( "error", not (isValid model) )
, ( "success", isValid model )
]
]
[ div [ class "required field" ]
[ label [] [ text "Name" ]
, input
[ type_ "text"
, value model.name
, onInput SetName
, placeholder "Connection name"
]
[]
]
]

View File

@ -0,0 +1,70 @@
module Comp.EmailSettingsManage exposing
( Model
, Msg
, emptyModel
, init
, update
, view
)
import Api
import Api.Model.BasicResult exposing (BasicResult)
import Api.Model.EmailSettings exposing (EmailSettings)
import Api.Model.EmailSettingsList exposing (EmailSettingsList)
import Comp.EmailSettingsForm
import Comp.EmailSettingsTable
import Comp.YesNoDimmer
import Data.Flags exposing (Flags)
import Html exposing (..)
import Html.Attributes exposing (..)
type alias Model =
{ tableModel : Comp.EmailSettingsTable.Model
, formModel : Comp.EmailSettingsForm.Model
, viewMode : ViewMode
, formError : Maybe String
, loading : Bool
, deleteConfirm : Comp.YesNoDimmer.Model
}
emptyModel : Model
emptyModel =
{ tableModel = Comp.EmailSettingsTable.emptyModel
, formModel = Comp.EmailSettingsForm.emptyModel
, viewMode = Table
, formError = Nothing
, loading = False
, deleteConfirm = Comp.YesNoDimmer.emptyModel
}
init : ( Model, Cmd Msg )
init =
( emptyModel, Cmd.none )
type ViewMode
= Table
| Form
type Msg
= TableMsg Comp.EmailSettingsTable.Msg
| FormMsg Comp.EmailSettingsForm.Msg
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
update flags msg model =
( model, Cmd.none )
view : Model -> Html Msg
view model =
case model.viewMode of
Table ->
Html.map TableMsg (Comp.EmailSettingsTable.view model.tableModel)
Form ->
Html.map FormMsg (Comp.EmailSettingsForm.view model.formModel)

View File

@ -0,0 +1,49 @@
module Comp.EmailSettingsTable exposing
( Model
, Msg
, emptyModel
, update
, view
)
import Api.Model.EmailSettings exposing (EmailSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
type alias Model =
{ emailSettings : List EmailSettings
}
emptyModel : Model
emptyModel =
init []
init : List EmailSettings -> Model
init ems =
{ emailSettings = ems
}
type Msg
= Select EmailSettings
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
( model, Cmd.none )
view : Model -> Html Msg
view model =
table [ class "ui table" ]
[ thead []
[ th [] [ text "Name" ]
, th [] [ text "Host/Port" ]
, th [] [ text "From" ]
]
, tbody []
[]
]

View File

@ -6,11 +6,13 @@ module Page.UserSettings.Data exposing
)
import Comp.ChangePasswordForm
import Comp.EmailSettingsManage
type alias Model =
{ currentTab : Maybe Tab
, changePassModel : Comp.ChangePasswordForm.Model
, emailSettingsModel : Comp.EmailSettingsManage.Model
}
@ -18,13 +20,16 @@ emptyModel : Model
emptyModel =
{ currentTab = Nothing
, changePassModel = Comp.ChangePasswordForm.emptyModel
, emailSettingsModel = Comp.EmailSettingsManage.emptyModel
}
type Tab
= ChangePassTab
| EmailSettingsTab
type Msg
= SetTab Tab
| ChangePassMsg Comp.ChangePasswordForm.Msg
| EmailSettingsMsg Comp.EmailSettingsManage.Msg

View File

@ -1,6 +1,7 @@
module Page.UserSettings.Update exposing (update)
import Comp.ChangePasswordForm
import Comp.EmailSettingsManage
import Data.Flags exposing (Flags)
import Page.UserSettings.Data exposing (..)
@ -21,3 +22,10 @@ update flags msg model =
Comp.ChangePasswordForm.update flags m model.changePassModel
in
( { model | changePassModel = m2 }, Cmd.map ChangePassMsg c2 )
EmailSettingsMsg m ->
let
( m2, c2 ) =
Comp.EmailSettingsManage.update flags m model.emailSettingsModel
in
( { model | emailSettingsModel = m2 }, Cmd.map EmailSettingsMsg c2 )

View File

@ -1,6 +1,7 @@
module Page.UserSettings.View exposing (view)
import Comp.ChangePasswordForm
import Comp.EmailSettingsManage
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
@ -17,13 +18,22 @@ view model =
]
, div [ class "ui attached fluid segment" ]
[ div [ class "ui fluid vertical secondary menu" ]
[ div
[ a
[ classActive (model.currentTab == Just ChangePassTab) "link icon item"
, onClick (SetTab ChangePassTab)
, href "#"
]
[ i [ class "user secret icon" ] []
, text "Change Password"
]
, a
[ classActive (model.currentTab == Just EmailSettingsTab) "link icon item"
, onClick (SetTab EmailSettingsTab)
, href "#"
]
[ i [ class "mail icon" ] []
, text "E-Mail Settings"
]
]
]
]
@ -33,6 +43,9 @@ view model =
Just ChangePassTab ->
viewChangePassword model
Just EmailSettingsTab ->
viewEmailSettings model
Nothing ->
[]
)
@ -40,6 +53,18 @@ view model =
]
viewEmailSettings : Model -> List (Html Msg)
viewEmailSettings model =
[ h2 [ class "ui header" ]
[ i [ class "mail icon" ] []
, div [ class "content" ]
[ text "E-Mail Settings"
]
]
, Html.map EmailSettingsMsg (Comp.EmailSettingsManage.view model.emailSettingsModel)
]
viewChangePassword : Model -> List (Html Msg)
viewChangePassword model =
[ h2 [ class "ui header" ]