mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 02:48:26 +00:00
Externalized strings
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
module Comp.Basic exposing
|
||||
( editLinkLabel
|
||||
, editLinkTableCell
|
||||
, editLinkTableCell2
|
||||
, genericButton
|
||||
, horizontalDivider
|
||||
, inputRequired
|
||||
@ -17,6 +18,7 @@ module Comp.Basic exposing
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick)
|
||||
import Messages.Basics
|
||||
import Styles as S
|
||||
|
||||
|
||||
@ -192,9 +194,14 @@ loadingDimmer active =
|
||||
|
||||
|
||||
editLinkLabel : msg -> Html msg
|
||||
editLinkLabel click =
|
||||
editLinkLabel =
|
||||
editLinkLabel2 Messages.Basics.gb
|
||||
|
||||
|
||||
editLinkLabel2 : Messages.Basics.Texts -> msg -> Html msg
|
||||
editLinkLabel2 texts click =
|
||||
linkLabel
|
||||
{ label = "Edit"
|
||||
{ label = texts.edit
|
||||
, icon = "fa fa-edit"
|
||||
, handler = click
|
||||
, disabled = False
|
||||
@ -204,7 +211,14 @@ editLinkLabel click =
|
||||
editLinkTableCell : msg -> Html msg
|
||||
editLinkTableCell m =
|
||||
td [ class S.editLinkTableCellStyle ]
|
||||
[ editLinkLabel m
|
||||
[ editLinkLabel2 Messages.Basics.gb m
|
||||
]
|
||||
|
||||
|
||||
editLinkTableCell2 : Messages.Basics.Texts -> msg -> Html msg
|
||||
editLinkTableCell2 texts m =
|
||||
td [ class S.editLinkTableCellStyle ]
|
||||
[ editLinkLabel2 texts m
|
||||
]
|
||||
|
||||
|
||||
|
@ -24,6 +24,7 @@ import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Http
|
||||
import Markdown
|
||||
import Messages.ClassifierSettingsFormComp exposing (Texts)
|
||||
import Styles as S
|
||||
import Util.Tag
|
||||
|
||||
@ -59,7 +60,7 @@ init flags sett =
|
||||
in
|
||||
( { scheduleModel = cem
|
||||
, schedule = Data.Validated.Unknown newSchedule
|
||||
, itemCountModel = Comp.IntField.init (Just 0) Nothing True "Item Count"
|
||||
, itemCountModel = Comp.IntField.init (Just 0) Nothing True ""
|
||||
, itemCount = Just sett.itemCount
|
||||
, categoryListModel =
|
||||
let
|
||||
@ -183,8 +184,8 @@ update flags msg model =
|
||||
--- View2
|
||||
|
||||
|
||||
view2 : UiSettings -> Model -> Html Msg
|
||||
view2 settings model =
|
||||
view2 : Texts -> UiSettings -> Model -> Html Msg
|
||||
view2 texts settings model =
|
||||
let
|
||||
catListTypeItem =
|
||||
Comp.FixedDropdown.Item
|
||||
@ -194,20 +195,10 @@ view2 settings model =
|
||||
in
|
||||
div []
|
||||
[ Markdown.toHtml [ class "px-2 py-2 opacity-75" ]
|
||||
"""
|
||||
|
||||
Auto-tagging works by learning from existing documents. The more
|
||||
documents you have correctly tagged, the better. Learning is done
|
||||
periodically based on a schedule. You can specify tag-groups that
|
||||
should either be used (whitelist) or not used (blacklist) for
|
||||
learning.
|
||||
|
||||
Use an empty whitelist to disable auto tagging.
|
||||
|
||||
"""
|
||||
texts.autoTaggingText
|
||||
, div [ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text "Is the following a blacklist or whitelist?" ]
|
||||
[ text texts.blacklistOrWhitelist ]
|
||||
, Html.map CategoryListTypeMsg
|
||||
(Comp.FixedDropdown.view2 (Just catListTypeItem) model.categoryListTypeModel)
|
||||
]
|
||||
@ -215,10 +206,10 @@ Use an empty whitelist to disable auto tagging.
|
||||
[ label [ class S.inputLabel ]
|
||||
[ case model.categoryListType of
|
||||
Data.ListType.Whitelist ->
|
||||
text "Include tag categories for learning"
|
||||
text texts.whitelistLabel
|
||||
|
||||
Data.ListType.Blacklist ->
|
||||
text "Exclude tag categories from learning"
|
||||
text texts.blacklistLabel
|
||||
]
|
||||
, Html.map CategoryListMsg
|
||||
(Comp.Dropdown.view2
|
||||
@ -228,16 +219,22 @@ Use an empty whitelist to disable auto tagging.
|
||||
)
|
||||
]
|
||||
, Html.map ItemCountMsg
|
||||
(Comp.IntField.viewWithInfo2
|
||||
"The maximum number of items to learn from, order by date newest first. Use 0 to mean all."
|
||||
model.itemCount
|
||||
"mb-4"
|
||||
(Comp.IntField.view
|
||||
{ label = texts.itemCount
|
||||
, info = texts.itemCountHelp
|
||||
, classes = "mb-4"
|
||||
, number = model.itemCount
|
||||
}
|
||||
model.itemCountModel
|
||||
)
|
||||
, div [ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text "Schedule" ]
|
||||
[ text texts.schedule ]
|
||||
, Html.map ScheduleMsg
|
||||
(Comp.CalEventInput.view2 "" (Data.Validated.value model.schedule) model.scheduleModel)
|
||||
(Comp.CalEventInput.view2
|
||||
""
|
||||
(Data.Validated.value model.schedule)
|
||||
model.scheduleModel
|
||||
)
|
||||
]
|
||||
]
|
||||
|
@ -23,6 +23,7 @@ import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onCheck, onClick, onInput)
|
||||
import Http
|
||||
import Messages.CollectiveSettingsFormComp exposing (Texts)
|
||||
import Styles as S
|
||||
import Util.Http
|
||||
|
||||
@ -200,8 +201,8 @@ update flags msg model =
|
||||
--- View2
|
||||
|
||||
|
||||
view2 : Flags -> UiSettings -> Model -> Html Msg
|
||||
view2 flags settings model =
|
||||
view2 : Flags -> Texts -> UiSettings -> Model -> Html Msg
|
||||
view2 flags texts settings model =
|
||||
div
|
||||
[ classList
|
||||
[ ( "ui form error success", True )
|
||||
@ -215,10 +216,10 @@ view2 flags settings model =
|
||||
[ MB.CustomElement <|
|
||||
B.primaryButton
|
||||
{ handler = onClick SaveSettings
|
||||
, label = "Save"
|
||||
, label = texts.save
|
||||
, icon = "fa fa-save"
|
||||
, attrs =
|
||||
[ title "Save settings"
|
||||
[ title texts.saveSettings
|
||||
, href "#"
|
||||
]
|
||||
, disabled = getSettings model |> Data.Validated.isInvalid
|
||||
@ -228,11 +229,11 @@ view2 flags settings model =
|
||||
, rootClasses = "mb-4"
|
||||
}
|
||||
, h3 [ class S.header3 ]
|
||||
[ text "Document Language"
|
||||
[ text texts.documentLanguage
|
||||
]
|
||||
, div [ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text "Document Language"
|
||||
[ text texts.documentLanguage
|
||||
]
|
||||
, Html.map LangDropdownMsg
|
||||
(Comp.Dropdown.view2
|
||||
@ -241,7 +242,7 @@ view2 flags settings model =
|
||||
model.langModel
|
||||
)
|
||||
, span [ class "opacity-50 text-sm" ]
|
||||
[ text "The language of your documents. This helps text recognition (OCR) and text analysis."
|
||||
[ text texts.documentLanguageHelp
|
||||
]
|
||||
]
|
||||
, div
|
||||
@ -252,7 +253,7 @@ view2 flags settings model =
|
||||
[ h3
|
||||
[ class S.header3
|
||||
]
|
||||
[ text "Integration Endpoint"
|
||||
[ text texts.integrationEndpoint
|
||||
]
|
||||
, div [ class "mb-4" ]
|
||||
[ label
|
||||
@ -268,12 +269,11 @@ view2 flags settings model =
|
||||
]
|
||||
[]
|
||||
, span [ class "ml-2" ]
|
||||
[ text "Enable integration endpoint"
|
||||
[ text texts.integrationEndpointHelp
|
||||
]
|
||||
]
|
||||
, div [ class "opacity-50 text-sm" ]
|
||||
[ text "The integration endpoint allows (local) applications to submit files. "
|
||||
, text "You can choose to disable it for your collective."
|
||||
[ text texts.integrationEndpointHelp
|
||||
]
|
||||
]
|
||||
]
|
||||
@ -284,7 +284,7 @@ view2 flags settings model =
|
||||
]
|
||||
[ h3
|
||||
[ class S.header3 ]
|
||||
[ text "Full-Text Search" ]
|
||||
[ text texts.fulltextSearch ]
|
||||
, div
|
||||
[ class "mb-4" ]
|
||||
[ div [ class "flex flex-row" ]
|
||||
@ -304,13 +304,12 @@ view2 flags settings model =
|
||||
]
|
||||
[ i [ class "fa fa-sync-alt" ] []
|
||||
, span [ class "ml-2 hidden sm:inline" ]
|
||||
[ text "Re-Index All Data"
|
||||
[ text texts.reindexAllData
|
||||
]
|
||||
]
|
||||
]
|
||||
, div [ class "opacity-50 text-sm" ]
|
||||
[ text "This starts a task that clears the full-text index and re-indexes all your data again."
|
||||
, text "You must type OK before clicking the button to avoid accidental re-indexing."
|
||||
[ text texts.reindexAllDataHelp
|
||||
]
|
||||
, renderResultMessage2 model.fullTextReIndexResult
|
||||
]
|
||||
@ -322,17 +321,20 @@ view2 flags settings model =
|
||||
]
|
||||
[ h3
|
||||
[ class S.header3 ]
|
||||
[ text "Auto-Tagging"
|
||||
[ text texts.autoTagging
|
||||
]
|
||||
, div
|
||||
[ class "mb-4" ]
|
||||
[ Html.map ClassifierSettingMsg
|
||||
(Comp.ClassifierSettingsForm.view2 settings model.classifierModel)
|
||||
(Comp.ClassifierSettingsForm.view2 texts.classifierSettingsForm
|
||||
settings
|
||||
model.classifierModel
|
||||
)
|
||||
, div [ class "flex flex-row justify-end" ]
|
||||
[ B.secondaryBasicButton
|
||||
{ handler = onClick StartClassifierTask
|
||||
, icon = "fa fa-play"
|
||||
, label = "Start now"
|
||||
, label = texts.startNow
|
||||
, disabled = Data.Validated.isInvalid model.classifierModel.schedule
|
||||
, attrs = [ href "#" ]
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
module Comp.IntField exposing
|
||||
( Model
|
||||
, Msg
|
||||
, ViewSettings
|
||||
, init
|
||||
, update
|
||||
, view
|
||||
, viewWithInfo2
|
||||
)
|
||||
|
||||
@ -98,20 +100,28 @@ update msg model =
|
||||
--- View2
|
||||
|
||||
|
||||
viewWithInfo2 : String -> Maybe Int -> String -> Model -> Html Msg
|
||||
viewWithInfo2 info nval classes model =
|
||||
type alias ViewSettings =
|
||||
{ label : String
|
||||
, info : String
|
||||
, number : Maybe Int
|
||||
, classes : String
|
||||
}
|
||||
|
||||
|
||||
view : ViewSettings -> Model -> Html Msg
|
||||
view cfg model =
|
||||
div
|
||||
[ classList
|
||||
[ ( classes, True )
|
||||
[ ( cfg.classes, True )
|
||||
, ( "error", model.error /= Nothing )
|
||||
]
|
||||
]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text model.label
|
||||
[ text cfg.label
|
||||
]
|
||||
, input
|
||||
[ type_ "text"
|
||||
, Maybe.map String.fromInt nval
|
||||
, Maybe.map String.fromInt cfg.number
|
||||
|> Maybe.withDefault model.lastInput
|
||||
|> value
|
||||
, onInput SetValue
|
||||
@ -120,11 +130,11 @@ viewWithInfo2 info nval classes model =
|
||||
[]
|
||||
, span
|
||||
[ classList
|
||||
[ ( "hidden", info == "" )
|
||||
[ ( "hidden", cfg.info == "" )
|
||||
]
|
||||
, class "opacity-50 text-sm"
|
||||
]
|
||||
[ Markdown.toHtml [] info
|
||||
[ Markdown.toHtml [] cfg.info
|
||||
]
|
||||
, div
|
||||
[ classList
|
||||
@ -135,3 +145,16 @@ viewWithInfo2 info nval classes model =
|
||||
[ Maybe.withDefault "" model.error |> text
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
viewWithInfo2 : String -> Maybe Int -> String -> Model -> Html Msg
|
||||
viewWithInfo2 info nval classes model =
|
||||
let
|
||||
cfg =
|
||||
{ label = model.label
|
||||
, info = info
|
||||
, number = nval
|
||||
, classes = classes
|
||||
}
|
||||
in
|
||||
view cfg model
|
||||
|
@ -28,6 +28,7 @@ import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onCheck, onInput)
|
||||
import Http
|
||||
import Markdown
|
||||
import Messages.SourceFormComp exposing (Texts)
|
||||
import Styles as S
|
||||
import Util.Folder exposing (mkFolderOption)
|
||||
import Util.Maybe
|
||||
@ -329,8 +330,8 @@ update flags msg model =
|
||||
--- View2
|
||||
|
||||
|
||||
view2 : Flags -> UiSettings -> Model -> Html Msg
|
||||
view2 _ settings model =
|
||||
view2 : Flags -> Texts -> UiSettings -> Model -> Html Msg
|
||||
view2 _ texts settings model =
|
||||
let
|
||||
priorityItem =
|
||||
Comp.FixedDropdown.Item
|
||||
@ -344,14 +345,14 @@ view2 _ settings model =
|
||||
[ for "source-abbrev"
|
||||
, class S.inputLabel
|
||||
]
|
||||
[ text "Name"
|
||||
[ text texts.name
|
||||
, B.inputRequired
|
||||
]
|
||||
, input
|
||||
[ type_ "text"
|
||||
, id "source-abbrev"
|
||||
, onInput SetAbbrev
|
||||
, placeholder "Name"
|
||||
, placeholder texts.name
|
||||
, value model.abbrev
|
||||
, class S.textInput
|
||||
, classList [ ( S.inputErrorBorder, not (isValid model) ) ]
|
||||
@ -363,7 +364,7 @@ view2 _ settings model =
|
||||
[ for "source-descr"
|
||||
, class S.inputLabel
|
||||
]
|
||||
[ text "Description"
|
||||
[ text texts.description
|
||||
]
|
||||
, textarea
|
||||
[ onInput SetDescr
|
||||
@ -388,13 +389,13 @@ view2 _ settings model =
|
||||
]
|
||||
[]
|
||||
, span [ class "ml-2" ]
|
||||
[ text "Enabled"
|
||||
[ text texts.enabled
|
||||
]
|
||||
]
|
||||
]
|
||||
, div [ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text "Priority"
|
||||
[ text texts.priority
|
||||
]
|
||||
, Html.map PrioDropdownMsg
|
||||
(Comp.FixedDropdown.view2
|
||||
@ -402,26 +403,24 @@ view2 _ settings model =
|
||||
model.priorityModel
|
||||
)
|
||||
, div [ class "opacity-50 text-sm" ]
|
||||
[ text "The priority used by the scheduler when processing uploaded files."
|
||||
[ text texts.priorityInfo
|
||||
]
|
||||
]
|
||||
, div
|
||||
[ class S.header2
|
||||
, class "mt-6"
|
||||
]
|
||||
[ text "Metadata"
|
||||
[ text texts.metadata
|
||||
]
|
||||
, div
|
||||
[ class S.message
|
||||
, class "mb-4"
|
||||
]
|
||||
[ text "Metadata specified here is automatically attached to each item uploaded "
|
||||
, text "through this source, unless it is overriden in the upload request meta data. "
|
||||
, text "Tags from the request are added to those defined here."
|
||||
[ text texts.metadataInfoText
|
||||
]
|
||||
, div [ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text "Folder"
|
||||
[ text texts.folder
|
||||
]
|
||||
, Html.map FolderDropdownMsg
|
||||
(Comp.Dropdown.view2
|
||||
@ -430,7 +429,7 @@ view2 _ settings model =
|
||||
model.folderModel
|
||||
)
|
||||
, div [ class "opacity-50 text-sm" ]
|
||||
[ text "Choose a folder to automatically put items into."
|
||||
[ text texts.folderInfo
|
||||
]
|
||||
, div
|
||||
[ classList
|
||||
@ -438,17 +437,13 @@ view2 _ settings model =
|
||||
]
|
||||
, class S.message
|
||||
]
|
||||
[ Markdown.toHtml [] """
|
||||
You are **not a member** of this folder. Items created through this
|
||||
link will be **hidden** from any search results. Use a folder where
|
||||
you are a member of to make items visible. This message will
|
||||
disappear then.
|
||||
"""
|
||||
[ Markdown.toHtml [] texts.folderForbiddenText
|
||||
]
|
||||
]
|
||||
, div [ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text "Tags" ]
|
||||
[ text texts.basics.tags
|
||||
]
|
||||
, Html.map TagDropdownMsg
|
||||
(Comp.Dropdown.view2
|
||||
DS.mainStyle
|
||||
@ -456,18 +451,18 @@ disappear then.
|
||||
model.tagModel
|
||||
)
|
||||
, div [ class "opacity-50 text-sm" ]
|
||||
[ text "Choose tags that should be applied to items."
|
||||
[ text texts.tagsInfo
|
||||
]
|
||||
]
|
||||
, div
|
||||
[ class "mb-4"
|
||||
]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text "File Filter" ]
|
||||
[ text texts.fileFilter ]
|
||||
, input
|
||||
[ type_ "text"
|
||||
, onInput SetFileFilter
|
||||
, placeholder "File Filter"
|
||||
, placeholder texts.fileFilter
|
||||
, model.fileFilter
|
||||
|> Maybe.withDefault ""
|
||||
|> value
|
||||
@ -475,20 +470,12 @@ disappear then.
|
||||
]
|
||||
[]
|
||||
, div [ class "opacity-50 text-sm" ]
|
||||
[ text "Specify a file glob to filter files when uploading archives "
|
||||
, text "(e.g. for email and zip). For example, to only extract pdf files: "
|
||||
, code [ class "font-mono" ]
|
||||
[ text "*.pdf"
|
||||
]
|
||||
, text ". Globs can be combined via OR, like this: "
|
||||
, code [ class "font-mono" ]
|
||||
[ text "*.pdf|mail.html"
|
||||
]
|
||||
[ Markdown.toHtml [] texts.fileFilterInfo
|
||||
]
|
||||
]
|
||||
, div [ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text "Language:"
|
||||
[ text (texts.language ++ ":")
|
||||
]
|
||||
, Html.map LanguageMsg
|
||||
(Comp.Dropdown.view2
|
||||
@ -496,9 +483,8 @@ disappear then.
|
||||
settings
|
||||
model.languageModel
|
||||
)
|
||||
, div [ class "text-gray-400 text-xs" ]
|
||||
[ text "Used for text extraction and analysis. The collective's "
|
||||
, text "default language is used if not specified here."
|
||||
, div [ class "opacity-50 text-sm" ]
|
||||
[ text texts.languageInfo
|
||||
]
|
||||
]
|
||||
]
|
||||
|
@ -21,6 +21,7 @@ import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onSubmit)
|
||||
import Http
|
||||
import Messages.SourceManageComp exposing (Texts)
|
||||
import Ports
|
||||
import QRCode
|
||||
import Styles as S
|
||||
@ -211,49 +212,49 @@ update flags msg model =
|
||||
--- View2
|
||||
|
||||
|
||||
qrCodeView : String -> Html msg
|
||||
qrCodeView message =
|
||||
qrCodeView : Texts -> String -> Html msg
|
||||
qrCodeView texts message =
|
||||
QRCode.encode message
|
||||
|> Result.map QRCode.toSvg
|
||||
|> Result.withDefault
|
||||
(Html.text "Error generating QR-Code")
|
||||
(Html.text texts.errorGeneratingQR)
|
||||
|
||||
|
||||
view2 : Flags -> UiSettings -> Model -> Html Msg
|
||||
view2 flags settings model =
|
||||
view2 : Texts -> Flags -> UiSettings -> Model -> Html Msg
|
||||
view2 texts flags settings model =
|
||||
case model.viewMode of
|
||||
None ->
|
||||
viewTable2 model
|
||||
viewTable2 texts model
|
||||
|
||||
Edit _ ->
|
||||
div [] (viewForm2 flags settings model)
|
||||
div [] (viewForm2 texts flags settings model)
|
||||
|
||||
Display source ->
|
||||
viewLinks2 flags settings source
|
||||
viewLinks2 texts flags settings source
|
||||
|
||||
|
||||
viewTable2 : Model -> Html Msg
|
||||
viewTable2 model =
|
||||
viewTable2 : Texts -> Model -> Html Msg
|
||||
viewTable2 texts model =
|
||||
div [ class "relative flex flex-col" ]
|
||||
[ MB.view
|
||||
{ start = []
|
||||
, end =
|
||||
[ MB.PrimaryButton
|
||||
{ tagger = InitNewSource
|
||||
, title = "Add a source url"
|
||||
, title = texts.addSourceUrl
|
||||
, icon = Just "fa fa-plus"
|
||||
, label = "New source"
|
||||
, label = texts.newSource
|
||||
}
|
||||
]
|
||||
, rootClasses = "mb-4"
|
||||
}
|
||||
, Html.map TableMsg (Comp.SourceTable.view2 model.sources)
|
||||
, Html.map TableMsg (Comp.SourceTable.view2 texts.sourceTable model.sources)
|
||||
, B.loadingDimmer model.loading
|
||||
]
|
||||
|
||||
|
||||
viewLinks2 : Flags -> UiSettings -> SourceAndTags -> Html Msg
|
||||
viewLinks2 flags _ source =
|
||||
viewLinks2 : Texts -> Flags -> UiSettings -> SourceAndTags -> Html Msg
|
||||
viewLinks2 texts flags _ source =
|
||||
let
|
||||
appUrl =
|
||||
flags.config.baseUrl ++ "/app/upload/" ++ source.source.id
|
||||
@ -270,7 +271,7 @@ viewLinks2 flags _ source =
|
||||
div
|
||||
[]
|
||||
[ h2 [ class S.header2 ]
|
||||
[ text "Public Uploads: "
|
||||
[ text (texts.publicUploads ++ ": ")
|
||||
, text source.source.abbrev
|
||||
, div [ class "opacity-50 text-sm" ]
|
||||
[ text source.source.id
|
||||
@ -279,37 +280,33 @@ viewLinks2 flags _ source =
|
||||
, MB.view
|
||||
{ start =
|
||||
[ MB.SecondaryButton
|
||||
{ label = "Back"
|
||||
{ label = texts.basics.back
|
||||
, icon = Just "fa fa-arrow-left"
|
||||
, tagger = SetTableView
|
||||
, title = "Back to list"
|
||||
, title = texts.basics.backToList
|
||||
}
|
||||
]
|
||||
, end = []
|
||||
, rootClasses = "mb-4"
|
||||
}
|
||||
, p [ class "text-lg pt-2 opacity-75" ]
|
||||
[ text "This source defines URLs that can be used by anyone to send files to "
|
||||
, text "you. There is a web page that you can share or the API url can be used "
|
||||
, text "with other clients."
|
||||
[ text texts.sourceInfoText
|
||||
]
|
||||
, p [ class "text-lg py-2 opacity-75" ]
|
||||
[ text "There have been "
|
||||
, String.fromInt source.source.counter |> text
|
||||
, text " items created through this source."
|
||||
[ text (texts.itemsCreatedInfo source.source.counter)
|
||||
]
|
||||
, h3
|
||||
[ class S.header3
|
||||
, class "mt-2"
|
||||
]
|
||||
[ text "Public Upload Page"
|
||||
[ text texts.publicUploadPage
|
||||
]
|
||||
, div [ class "" ]
|
||||
[ div [ class "flex flex-row" ]
|
||||
[ a
|
||||
[ class S.secondaryBasicButtonPlain
|
||||
, class "rounded-l border text-sm px-4 py-2"
|
||||
, title "Copy to clipboard"
|
||||
, title texts.copyToClipboard
|
||||
, href "#"
|
||||
, Tuple.second appClipboardData
|
||||
|> String.dropLeft 1
|
||||
@ -323,7 +320,7 @@ viewLinks2 flags _ source =
|
||||
, class "px-4 py-2 border-0 border-t border-b border-r text-sm"
|
||||
, href appUrl
|
||||
, target "_blank"
|
||||
, title "Open in new tab/window"
|
||||
, title texts.openInNewTab
|
||||
]
|
||||
[ i [ class "fa fa-external-link-alt" ] []
|
||||
]
|
||||
@ -340,21 +337,21 @@ viewLinks2 flags _ source =
|
||||
[ class S.border
|
||||
, class styleQr
|
||||
]
|
||||
[ qrCodeView appUrl
|
||||
[ qrCodeView texts appUrl
|
||||
]
|
||||
]
|
||||
, h3
|
||||
[ class S.header3
|
||||
, class "mt-4"
|
||||
]
|
||||
[ text "Public API Upload URL"
|
||||
[ text texts.publicUploadUrl
|
||||
]
|
||||
, div [ class "" ]
|
||||
[ div [ class "flex flex-row" ]
|
||||
[ a
|
||||
[ class S.secondaryBasicButtonPlain
|
||||
, class "px-4 py-2 rounded-l border text-sm"
|
||||
, title "Copy to clipboard"
|
||||
, title texts.copyToClipboard
|
||||
, href "#"
|
||||
, Tuple.second apiClipboardData
|
||||
|> String.dropLeft 1
|
||||
@ -376,24 +373,24 @@ viewLinks2 flags _ source =
|
||||
[ class S.border
|
||||
, class styleQr
|
||||
]
|
||||
[ qrCodeView apiUrl
|
||||
[ qrCodeView texts apiUrl
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
viewForm2 : Flags -> UiSettings -> Model -> List (Html Msg)
|
||||
viewForm2 flags settings model =
|
||||
viewForm2 : Texts -> Flags -> UiSettings -> Model -> List (Html Msg)
|
||||
viewForm2 texts flags settings model =
|
||||
let
|
||||
newSource =
|
||||
model.formModel.source.source.id == ""
|
||||
|
||||
dimmerSettings =
|
||||
Comp.YesNoDimmer.defaultSettings2 "Really delete this source?"
|
||||
Comp.YesNoDimmer.defaultSettings2 texts.reallyDeleteSource
|
||||
in
|
||||
[ if newSource then
|
||||
h3 [ class S.header2 ]
|
||||
[ text "Create new source"
|
||||
[ text texts.createNewSource
|
||||
]
|
||||
|
||||
else
|
||||
@ -412,24 +409,24 @@ viewForm2 flags settings model =
|
||||
{ start =
|
||||
[ MB.PrimaryButton
|
||||
{ tagger = Submit
|
||||
, title = "Submit this form"
|
||||
, title = texts.basics.submitThisForm
|
||||
, icon = Just "fa fa-save"
|
||||
, label = "Submit"
|
||||
, label = texts.basics.submit
|
||||
}
|
||||
, MB.SecondaryButton
|
||||
{ tagger = SetTableView
|
||||
, title = "Back to list"
|
||||
, title = texts.basics.backToList
|
||||
, icon = Just "fa fa-arrow-left"
|
||||
, label = "Cancel"
|
||||
, label = texts.basics.cancel
|
||||
}
|
||||
]
|
||||
, end =
|
||||
if not newSource then
|
||||
[ MB.DeleteButton
|
||||
{ tagger = RequestDelete
|
||||
, title = "Delete this settings entry"
|
||||
, title = texts.deleteThisSource
|
||||
, icon = Just "fa fa-trash"
|
||||
, label = "Delete"
|
||||
, label = texts.basics.delete
|
||||
}
|
||||
]
|
||||
|
||||
@ -438,7 +435,7 @@ viewForm2 flags settings model =
|
||||
, rootClasses = "mb-4"
|
||||
}
|
||||
, Html.map FormMsg
|
||||
(Comp.SourceForm.view2 flags settings model.formModel)
|
||||
(Comp.SourceForm.view2 flags texts.sourceForm settings model.formModel)
|
||||
, div
|
||||
[ classList
|
||||
[ ( S.errorMessage, True )
|
||||
|
@ -12,6 +12,7 @@ import Data.Flags exposing (Flags)
|
||||
import Data.Priority
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Messages.SourceTableComp exposing (Texts)
|
||||
import Styles as S
|
||||
import Util.Html
|
||||
|
||||
@ -54,26 +55,26 @@ update _ msg =
|
||||
--- View2
|
||||
|
||||
|
||||
view2 : List SourceAndTags -> Html Msg
|
||||
view2 sources =
|
||||
view2 : Texts -> List SourceAndTags -> Html Msg
|
||||
view2 texts sources =
|
||||
table [ class S.tableMain ]
|
||||
[ thead []
|
||||
[ tr []
|
||||
[ th [ class "" ] []
|
||||
, th [ class "text-left" ] [ text "Abbrev" ]
|
||||
, th [ class "px-2 text-center" ] [ text "Enabled" ]
|
||||
, th [ class "hidden md:table-cell" ] [ text "Counter" ]
|
||||
, th [ class "hidden md:table-cell" ] [ text "Priority" ]
|
||||
, th [ class "hidden sm:table-cell" ] [ text "Id" ]
|
||||
, th [ class "text-left" ] [ text texts.abbrev ]
|
||||
, th [ class "px-2 text-center" ] [ text texts.enabled ]
|
||||
, th [ class "hidden md:table-cell" ] [ text texts.counter ]
|
||||
, th [ class "hidden md:table-cell" ] [ text texts.priority ]
|
||||
, th [ class "hidden sm:table-cell" ] [ text texts.id ]
|
||||
]
|
||||
]
|
||||
, tbody []
|
||||
(List.map renderSourceLine2 sources)
|
||||
(List.map (renderSourceLine2 texts) sources)
|
||||
]
|
||||
|
||||
|
||||
renderSourceLine2 : SourceAndTags -> Html Msg
|
||||
renderSourceLine2 source =
|
||||
renderSourceLine2 : Texts -> SourceAndTags -> Html Msg
|
||||
renderSourceLine2 texts source =
|
||||
tr
|
||||
[ class S.tableRow ]
|
||||
[ td [ class S.editLinkTableCellStyle ]
|
||||
@ -82,7 +83,7 @@ renderSourceLine2 source =
|
||||
]
|
||||
[ B.editLinkLabel (Select source)
|
||||
, B.linkLabel
|
||||
{ label = "Show"
|
||||
{ label = texts.show
|
||||
, icon = "fa fa-eye"
|
||||
, handler = Show source
|
||||
, disabled = not source.source.enabled
|
||||
|
@ -19,6 +19,7 @@ import Data.UserState exposing (UserState)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onInput)
|
||||
import Messages.UserFormComp exposing (Texts)
|
||||
import Styles as S
|
||||
import Util.Maybe
|
||||
|
||||
@ -166,19 +167,19 @@ update _ msg model =
|
||||
--- View2
|
||||
|
||||
|
||||
view2 : UiSettings -> Model -> Html Msg
|
||||
view2 settings model =
|
||||
view2 : Texts -> UiSettings -> Model -> Html Msg
|
||||
view2 texts settings model =
|
||||
div [ class "flex flex-col" ]
|
||||
[ div
|
||||
[ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text "Login"
|
||||
[ text texts.login
|
||||
, B.inputRequired
|
||||
]
|
||||
, input
|
||||
[ type_ "text"
|
||||
, onInput SetLogin
|
||||
, placeholder "Login"
|
||||
, placeholder texts.login
|
||||
, value model.login
|
||||
, class S.textInput
|
||||
, classList [ ( S.inputErrorBorder, model.login == "" ) ]
|
||||
@ -187,20 +188,20 @@ view2 settings model =
|
||||
]
|
||||
, div [ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text "E-Mail"
|
||||
[ text texts.email
|
||||
]
|
||||
, input
|
||||
[ onInput SetEmail
|
||||
, type_ "text"
|
||||
, model.email |> Maybe.withDefault "" |> value
|
||||
, placeholder "E-Mail"
|
||||
, placeholder texts.email
|
||||
, class S.textInput
|
||||
]
|
||||
[]
|
||||
]
|
||||
, div [ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text "State"
|
||||
[ text texts.state
|
||||
]
|
||||
, Html.map StateMsg
|
||||
(Comp.Dropdown.view2
|
||||
@ -214,13 +215,13 @@ view2 settings model =
|
||||
, classList [ ( "hidden", model.user.login /= "" ) ]
|
||||
]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text "Password"
|
||||
[ text texts.password
|
||||
, B.inputRequired
|
||||
]
|
||||
, input
|
||||
[ type_ "text"
|
||||
, onInput SetPassword
|
||||
, placeholder "Password"
|
||||
, placeholder texts.password
|
||||
, Maybe.withDefault "" model.password |> value
|
||||
, class S.textInput
|
||||
, classList [ ( S.inputErrorBorder, Util.Maybe.isEmpty model.password ) ]
|
||||
|
@ -21,6 +21,7 @@ import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onSubmit)
|
||||
import Http
|
||||
import Messages.UserManageComp exposing (Texts)
|
||||
import Styles as S
|
||||
import Util.Http
|
||||
import Util.Maybe
|
||||
@ -30,7 +31,7 @@ type alias Model =
|
||||
{ tableModel : Comp.UserTable.Model
|
||||
, formModel : Comp.UserForm.Model
|
||||
, viewMode : ViewMode
|
||||
, formError : Maybe String
|
||||
, formError : FormError
|
||||
, loading : Bool
|
||||
, deleteConfirm : Comp.YesNoDimmer.Model
|
||||
}
|
||||
@ -41,12 +42,18 @@ type ViewMode
|
||||
| Form
|
||||
|
||||
|
||||
type FormError
|
||||
= FormErrorNone
|
||||
| FormErrorSubmit String
|
||||
| FormErrorInvalid
|
||||
|
||||
|
||||
emptyModel : Model
|
||||
emptyModel =
|
||||
{ tableModel = Comp.UserTable.emptyModel
|
||||
, formModel = Comp.UserForm.emptyModel
|
||||
, viewMode = Table
|
||||
, formError = Nothing
|
||||
, formError = FormErrorNone
|
||||
, loading = False
|
||||
, deleteConfirm = Comp.YesNoDimmer.emptyModel
|
||||
}
|
||||
@ -79,7 +86,7 @@ update flags msg model =
|
||||
, viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table
|
||||
, formError =
|
||||
if Util.Maybe.nonEmpty tm.selected then
|
||||
Nothing
|
||||
FormErrorNone
|
||||
|
||||
else
|
||||
model.formError
|
||||
@ -132,7 +139,7 @@ update flags msg model =
|
||||
InitNewUser ->
|
||||
let
|
||||
nm =
|
||||
{ model | viewMode = Form, formError = Nothing }
|
||||
{ model | viewMode = Form, formError = FormErrorNone }
|
||||
|
||||
user =
|
||||
Api.Model.User.empty
|
||||
@ -158,7 +165,7 @@ update flags msg model =
|
||||
( { model | loading = True }, cmd )
|
||||
|
||||
else
|
||||
( { model | formError = Just "Please correct the errors in the form." }, Cmd.none )
|
||||
( { model | formError = FormErrorInvalid }, Cmd.none )
|
||||
|
||||
SubmitResp (Ok res) ->
|
||||
if res.success then
|
||||
@ -172,10 +179,15 @@ update flags msg model =
|
||||
( { m3 | loading = False }, Cmd.batch [ c2, c3 ] )
|
||||
|
||||
else
|
||||
( { model | formError = Just res.message, loading = False }, Cmd.none )
|
||||
( { model | formError = FormErrorSubmit res.message, loading = False }, Cmd.none )
|
||||
|
||||
SubmitResp (Err err) ->
|
||||
( { model | formError = Just (Util.Http.errorToString err), loading = False }, Cmd.none )
|
||||
( { model
|
||||
| formError = FormErrorSubmit (Util.Http.errorToString err)
|
||||
, loading = False
|
||||
}
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
RequestDelete ->
|
||||
update flags (YesNoMsg Comp.YesNoDimmer.activate) model
|
||||
@ -202,44 +214,44 @@ update flags msg model =
|
||||
--- View2
|
||||
|
||||
|
||||
view2 : UiSettings -> Model -> Html Msg
|
||||
view2 settings model =
|
||||
view2 : Texts -> UiSettings -> Model -> Html Msg
|
||||
view2 texts settings model =
|
||||
if model.viewMode == Table then
|
||||
viewTable2 model
|
||||
viewTable2 texts model
|
||||
|
||||
else
|
||||
viewForm2 settings model
|
||||
viewForm2 texts settings model
|
||||
|
||||
|
||||
viewTable2 : Model -> Html Msg
|
||||
viewTable2 model =
|
||||
viewTable2 : Texts -> Model -> Html Msg
|
||||
viewTable2 texts model =
|
||||
div [ class "flex flex-col" ]
|
||||
[ MB.view
|
||||
{ start = []
|
||||
, end =
|
||||
[ MB.PrimaryButton
|
||||
{ tagger = InitNewUser
|
||||
, title = "Add a new user"
|
||||
, title = texts.addNewUser
|
||||
, icon = Just "fa fa-plus"
|
||||
, label = "New user"
|
||||
, label = texts.newUser
|
||||
}
|
||||
]
|
||||
, rootClasses = "mb-4"
|
||||
}
|
||||
, Html.map TableMsg (Comp.UserTable.view2 model.tableModel)
|
||||
, Html.map TableMsg (Comp.UserTable.view2 texts.userTable model.tableModel)
|
||||
, B.loadingDimmer model.loading
|
||||
]
|
||||
|
||||
|
||||
viewForm2 : UiSettings -> Model -> Html Msg
|
||||
viewForm2 settings model =
|
||||
viewForm2 : Texts -> UiSettings -> Model -> Html Msg
|
||||
viewForm2 texts settings model =
|
||||
let
|
||||
newUser =
|
||||
Comp.UserForm.isNewUser model.formModel
|
||||
|
||||
dimmerSettings : Comp.YesNoDimmer.Settings
|
||||
dimmerSettings =
|
||||
Comp.YesNoDimmer.defaultSettings2 "Really delete this user?"
|
||||
Comp.YesNoDimmer.defaultSettings2 texts.reallyDeleteUser
|
||||
in
|
||||
Html.form
|
||||
[ class "flex flex-col md:relative"
|
||||
@ -252,7 +264,7 @@ viewForm2 settings model =
|
||||
)
|
||||
, if newUser then
|
||||
h3 [ class S.header2 ]
|
||||
[ text "Create new user"
|
||||
[ text texts.createNewUser
|
||||
]
|
||||
|
||||
else
|
||||
@ -263,24 +275,24 @@ viewForm2 settings model =
|
||||
{ start =
|
||||
[ MB.PrimaryButton
|
||||
{ tagger = Submit
|
||||
, title = "Submit this form"
|
||||
, title = texts.basics.submitThisForm
|
||||
, icon = Just "fa fa-save"
|
||||
, label = "Submit"
|
||||
, label = texts.basics.submit
|
||||
}
|
||||
, MB.SecondaryButton
|
||||
{ tagger = SetViewMode Table
|
||||
, title = "Back to list"
|
||||
, title = texts.basics.backToList
|
||||
, icon = Just "fa fa-arrow-left"
|
||||
, label = "Cancel"
|
||||
, label = texts.basics.cancel
|
||||
}
|
||||
]
|
||||
, end =
|
||||
if not newUser then
|
||||
[ MB.DeleteButton
|
||||
{ tagger = RequestDelete
|
||||
, title = "Delete this user"
|
||||
, title = texts.deleteThisUser
|
||||
, icon = Just "fa fa-trash"
|
||||
, label = "Delete"
|
||||
, label = texts.basics.delete
|
||||
}
|
||||
]
|
||||
|
||||
@ -288,14 +300,22 @@ viewForm2 settings model =
|
||||
[]
|
||||
, rootClasses = "mb-4"
|
||||
}
|
||||
, Html.map FormMsg (Comp.UserForm.view2 settings model.formModel)
|
||||
, Html.map FormMsg (Comp.UserForm.view2 texts.userForm settings model.formModel)
|
||||
, div
|
||||
[ classList
|
||||
[ ( "hidden", Util.Maybe.isEmpty model.formError )
|
||||
[ ( "hidden", model.formError == FormErrorNone )
|
||||
]
|
||||
, class S.errorMessage
|
||||
]
|
||||
[ Maybe.withDefault "" model.formError |> text
|
||||
[ case model.formError of
|
||||
FormErrorNone ->
|
||||
text ""
|
||||
|
||||
FormErrorSubmit err ->
|
||||
text err
|
||||
|
||||
FormErrorInvalid ->
|
||||
text texts.pleaseCorrectErrors
|
||||
]
|
||||
, B.loadingDimmer model.loading
|
||||
]
|
||||
|
@ -11,6 +11,7 @@ import Comp.Basic as B
|
||||
import Data.Flags exposing (Flags)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Messages.UserTableComp exposing (Texts)
|
||||
import Styles as S
|
||||
import Util.Time exposing (formatDateTime)
|
||||
|
||||
@ -51,32 +52,34 @@ update _ msg model =
|
||||
--- View2
|
||||
|
||||
|
||||
view2 : Model -> Html Msg
|
||||
view2 model =
|
||||
view2 : Texts -> Model -> Html Msg
|
||||
view2 texts model =
|
||||
table [ class S.tableMain ]
|
||||
[ thead []
|
||||
[ tr []
|
||||
[ th [ class "w-px whitespace-nowrap" ] []
|
||||
, th [ class "text-left" ] [ text "Login" ]
|
||||
, th [ class "text-center" ] [ text "State" ]
|
||||
, th [ class "hidden md:table-cell text-left" ] [ text "Email" ]
|
||||
, th [ class "hidden md:table-cell text-center" ] [ text "Logins" ]
|
||||
, th [ class "hidden sm:table-cell text-center" ] [ text "Last Login" ]
|
||||
, th [ class "hidden md:table-cell text-center" ] [ text "Created" ]
|
||||
, th [ class "text-left" ] [ text texts.login ]
|
||||
, th [ class "text-center" ] [ text texts.state ]
|
||||
, th [ class "hidden md:table-cell text-left" ] [ text texts.email ]
|
||||
, th [ class "hidden md:table-cell text-center" ] [ text texts.login ]
|
||||
, th [ class "hidden sm:table-cell text-center" ] [ text texts.lastLogin ]
|
||||
, th [ class "hidden md:table-cell text-center" ]
|
||||
[ text texts.basics.created
|
||||
]
|
||||
]
|
||||
]
|
||||
, tbody []
|
||||
(List.map (renderUserLine2 model) model.users)
|
||||
(List.map (renderUserLine2 texts model) model.users)
|
||||
]
|
||||
|
||||
|
||||
renderUserLine2 : Model -> User -> Html Msg
|
||||
renderUserLine2 model user =
|
||||
renderUserLine2 : Texts -> Model -> User -> Html Msg
|
||||
renderUserLine2 texts model user =
|
||||
tr
|
||||
[ classList [ ( "active", model.selected == Just user ) ]
|
||||
, class S.tableRow
|
||||
]
|
||||
[ B.editLinkTableCell (Select user)
|
||||
[ B.editLinkTableCell2 texts.basics (Select user)
|
||||
, td [ class "text-left" ]
|
||||
[ text user.login
|
||||
]
|
||||
|
Reference in New Issue
Block a user