mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-07-04 16:48:26 +00:00
Add user setting page for totp
This commit is contained in:
@ -16,6 +16,7 @@ import Comp.ChangePasswordForm
|
||||
import Comp.EmailSettingsManage
|
||||
import Comp.ImapSettingsManage
|
||||
import Comp.NotificationManage
|
||||
import Comp.OtpSetup
|
||||
import Comp.ScanMailboxManage
|
||||
import Comp.UiSettingsManage
|
||||
import Data.Flags exposing (Flags)
|
||||
@ -30,6 +31,7 @@ type alias Model =
|
||||
, notificationModel : Comp.NotificationManage.Model
|
||||
, scanMailboxModel : Comp.ScanMailboxManage.Model
|
||||
, uiSettingsModel : Comp.UiSettingsManage.Model
|
||||
, otpSetupModel : Comp.OtpSetup.Model
|
||||
}
|
||||
|
||||
|
||||
@ -38,6 +40,9 @@ init flags settings =
|
||||
let
|
||||
( um, uc ) =
|
||||
Comp.UiSettingsManage.init flags settings
|
||||
|
||||
( otpm, otpc ) =
|
||||
Comp.OtpSetup.init flags
|
||||
in
|
||||
( { currentTab = Just UiSettingsTab
|
||||
, changePassModel = Comp.ChangePasswordForm.emptyModel
|
||||
@ -46,8 +51,12 @@ init flags settings =
|
||||
, notificationModel = Tuple.first (Comp.NotificationManage.init flags)
|
||||
, scanMailboxModel = Tuple.first (Comp.ScanMailboxManage.init flags)
|
||||
, uiSettingsModel = um
|
||||
, otpSetupModel = otpm
|
||||
}
|
||||
, Cmd.map UiSettingsMsg uc
|
||||
, Cmd.batch
|
||||
[ Cmd.map UiSettingsMsg uc
|
||||
, Cmd.map OtpSetupMsg otpc
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@ -58,6 +67,7 @@ type Tab
|
||||
| NotificationTab
|
||||
| ScanMailboxTab
|
||||
| UiSettingsTab
|
||||
| OtpTab
|
||||
|
||||
|
||||
type Msg
|
||||
@ -68,5 +78,6 @@ type Msg
|
||||
| ImapSettingsMsg Comp.ImapSettingsManage.Msg
|
||||
| ScanMailboxMsg Comp.ScanMailboxManage.Msg
|
||||
| UiSettingsMsg Comp.UiSettingsManage.Msg
|
||||
| OtpSetupMsg Comp.OtpSetup.Msg
|
||||
| UpdateSettings
|
||||
| ReceiveBrowserSettings StoredUiSettings
|
||||
|
@ -11,6 +11,7 @@ import Comp.ChangePasswordForm
|
||||
import Comp.EmailSettingsManage
|
||||
import Comp.ImapSettingsManage
|
||||
import Comp.NotificationManage
|
||||
import Comp.OtpSetup
|
||||
import Comp.ScanMailboxManage
|
||||
import Comp.UiSettingsManage
|
||||
import Data.Flags exposing (Flags)
|
||||
@ -79,6 +80,9 @@ update flags settings msg model =
|
||||
UiSettingsTab ->
|
||||
UpdateResult m Cmd.none Sub.none Nothing
|
||||
|
||||
OtpTab ->
|
||||
UpdateResult m Cmd.none Sub.none Nothing
|
||||
|
||||
ChangePassMsg m ->
|
||||
let
|
||||
( m2, c2 ) =
|
||||
@ -145,6 +149,17 @@ update flags settings msg model =
|
||||
, newSettings = res.newSettings
|
||||
}
|
||||
|
||||
OtpSetupMsg lm ->
|
||||
let
|
||||
( otpm, otpc ) =
|
||||
Comp.OtpSetup.update flags lm model.otpSetupModel
|
||||
in
|
||||
{ model = { model | otpSetupModel = otpm }
|
||||
, cmd = Cmd.map OtpSetupMsg otpc
|
||||
, sub = Sub.none
|
||||
, newSettings = Nothing
|
||||
}
|
||||
|
||||
UpdateSettings ->
|
||||
update flags
|
||||
settings
|
||||
|
@ -11,6 +11,7 @@ import Comp.ChangePasswordForm
|
||||
import Comp.EmailSettingsManage
|
||||
import Comp.ImapSettingsManage
|
||||
import Comp.NotificationManage
|
||||
import Comp.OtpSetup
|
||||
import Comp.ScanMailboxManage
|
||||
import Comp.UiSettingsManage
|
||||
import Data.Flags exposing (Flags)
|
||||
@ -104,6 +105,17 @@ viewSidebar texts visible _ _ model =
|
||||
[ class "ml-3" ]
|
||||
[ text texts.changePassword ]
|
||||
]
|
||||
, a
|
||||
[ href "#"
|
||||
, onClick (SetTab OtpTab)
|
||||
, menuEntryActive model OtpTab
|
||||
, class S.sidebarLink
|
||||
]
|
||||
[ i [ class "fa fa-key" ] []
|
||||
, span
|
||||
[ class "ml-3" ]
|
||||
[ text texts.otpMenu ]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
@ -133,6 +145,9 @@ viewContent texts flags settings model =
|
||||
Just UiSettingsTab ->
|
||||
viewUiSettings texts flags settings model
|
||||
|
||||
Just OtpTab ->
|
||||
viewOtpSetup texts settings model
|
||||
|
||||
Nothing ->
|
||||
[]
|
||||
)
|
||||
@ -151,6 +166,25 @@ menuEntryActive model tab =
|
||||
class ""
|
||||
|
||||
|
||||
viewOtpSetup : Texts -> UiSettings -> Model -> List (Html Msg)
|
||||
viewOtpSetup texts _ model =
|
||||
[ h2
|
||||
[ class S.header1
|
||||
, class "inline-flex items-center"
|
||||
]
|
||||
[ i [ class "fa fa-key" ] []
|
||||
, div [ class "ml-3" ]
|
||||
[ text texts.otpMenu
|
||||
]
|
||||
]
|
||||
, Html.map OtpSetupMsg
|
||||
(Comp.OtpSetup.view
|
||||
texts.otpSetup
|
||||
model.otpSetupModel
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
viewChangePassword : Texts -> Model -> List (Html Msg)
|
||||
viewChangePassword texts model =
|
||||
[ h2
|
||||
|
Reference in New Issue
Block a user