Allow to manage passwords for a collective

This commit is contained in:
eikek
2021-09-30 10:35:38 +02:00
parent 3c93b63c8a
commit f74624485f
11 changed files with 190 additions and 9 deletions

View File

@ -22,6 +22,7 @@ import Comp.ClassifierSettingsForm
import Comp.Dropdown
import Comp.EmptyTrashForm
import Comp.MenuBar as MB
import Comp.StringListInput
import Data.DropdownStyle as DS
import Data.Flags exposing (Flags)
import Data.Language exposing (Language)
@ -30,6 +31,7 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onCheck, onClick, onInput)
import Http
import Markdown
import Messages.Comp.CollectiveSettingsForm exposing (Texts)
import Styles as S
@ -44,6 +46,8 @@ type alias Model =
, startClassifierResult : ClassifierResult
, emptyTrashModel : Comp.EmptyTrashForm.Model
, startEmptyTrashResult : EmptyTrashResult
, passwordModel : Comp.StringListInput.Model
, passwords : List String
}
@ -96,6 +100,8 @@ init flags settings =
, startClassifierResult = ClassifierResultInitial
, emptyTrashModel = em
, startEmptyTrashResult = EmptyTrashResultInitial
, passwordModel = Comp.StringListInput.init
, passwords = settings.passwords
}
, Cmd.batch [ Cmd.map ClassifierSettingMsg cc, Cmd.map EmptyTrashMsg ec ]
)
@ -114,6 +120,7 @@ getSettings model =
, integrationEnabled = model.intEnabled
, classifier = cls
, emptyTrash = trash
, passwords = model.passwords
}
)
(Comp.ClassifierSettingsForm.getSettings model.classifierModel)
@ -133,6 +140,7 @@ type Msg
| StartEmptyTrashTask
| StartClassifierResp (Result Http.Error BasicResult)
| StartEmptyTrashResp (Result Http.Error BasicResult)
| PasswordMsg Comp.StringListInput.Msg
update : Flags -> Msg -> Model -> ( Model, Cmd Msg, Maybe CollectiveSettings )
@ -285,6 +293,27 @@ update flags msg model =
, Nothing
)
PasswordMsg lm ->
let
( pm, action ) =
Comp.StringListInput.update lm model.passwordModel
pws =
case action of
Comp.StringListInput.AddAction pw ->
pw :: model.passwords
Comp.StringListInput.RemoveAction pw ->
List.filter (\e -> e /= pw) model.passwords
Comp.StringListInput.NoAction ->
model.passwords
in
( { model | passwordModel = pm, passwords = pws }
, Cmd.none
, Nothing
)
--- View2
@ -460,6 +489,18 @@ view2 flags texts settings model =
]
]
]
, div []
[ h2 [ class S.header2 ]
[ text texts.passwords
]
, div [ class "mb-4" ]
[ div [ class "opacity-50 text-sm" ]
[ Markdown.toHtml [] texts.passwordsInfo
]
, Html.map PasswordMsg
(Comp.StringListInput.view2 model.passwords model.passwordModel)
]
]
]

View File

@ -44,6 +44,8 @@ type alias Texts =
, fulltextReindexSubmitted : String
, fulltextReindexOkMissing : String
, emptyTrash : String
, passwords : String
, passwordsInfo : String
}
@ -77,6 +79,8 @@ gb =
, fulltextReindexOkMissing =
"Please type OK in the field if you really want to start re-indexing your data."
, emptyTrash = "Empty Trash"
, passwords = "Passwords"
, passwordsInfo = "These passwords are used when encrypted PDFs are being processed. Please note, that they are stored in the database as **plain text**!"
}
@ -110,4 +114,6 @@ de =
, fulltextReindexOkMissing =
"Bitte tippe OK in das Feld ein, wenn Du wirklich den Index neu erzeugen möchtest."
, emptyTrash = "Papierkorb löschen"
, passwords = "Passwörter"
, passwordsInfo = "Diese Passwörter werden zum Lesen von verschlüsselten PDFs verwendet. Diese Passwörter werden in der Datanbank **in Klartext** gespeichert!"
}