Externalize strings in queue page

This commit is contained in:
Eike Kettner 2021-04-01 22:00:48 +02:00
parent 968c8e02b7
commit b9c98c6578
4 changed files with 104 additions and 39 deletions

View File

@ -133,7 +133,7 @@ mainContent model =
viewUserSettings model
QueuePage ->
viewQueue model
viewQueue texts model
RegisterPage ->
viewRegister texts model
@ -449,12 +449,17 @@ viewUserSettings model =
]
viewQueue : Model -> List (Html Msg)
viewQueue model =
viewQueue : Messages -> Model -> List (Html Msg)
viewQueue texts model =
[ Html.map QueueMsg
(Queue.viewSidebar model.sidebarVisible model.flags model.uiSettings model.queueModel)
(Queue.viewSidebar texts.queue
model.sidebarVisible
model.flags
model.uiSettings
model.queueModel
)
, Html.map QueueMsg
(Queue.viewContent model.flags model.uiSettings model.queueModel)
(Queue.viewContent texts.queue model.flags model.uiSettings model.queueModel)
]

View File

@ -10,6 +10,7 @@ import Messages.CollectiveSettingsPage
import Messages.ItemDetailPage
import Messages.LoginPage
import Messages.NewInvitePage
import Messages.QueuePage
import Messages.RegisterPage
import Messages.UploadPage
import UiLanguage exposing (UiLanguage(..))
@ -29,6 +30,7 @@ type alias Messages =
, newInvite : Messages.NewInvitePage.Texts
, upload : Messages.UploadPage.Texts
, itemDetail : Messages.ItemDetailPage.Texts
, queue : Messages.QueuePage.Texts
}
@ -88,6 +90,7 @@ gb =
, newInvite = Messages.NewInvitePage.gb
, upload = Messages.UploadPage.gb
, itemDetail = Messages.ItemDetailPage.gb
, queue = Messages.QueuePage.gb
}
@ -104,4 +107,5 @@ de =
, newInvite = Messages.NewInvitePage.de
, upload = Messages.UploadPage.de
, itemDetail = Messages.ItemDetailPage.de
, queue = Messages.QueuePage.de
}

View File

@ -0,0 +1,51 @@
module Messages.QueuePage exposing (..)
import Messages.Basics
type alias Texts =
{ basics : Messages.Basics.Texts
, currentlyRunning : String
, queue : String
, waiting : String
, errored : String
, success : String
, noJobsRunning : String
, noJobsDisplay : String
, noJobsWaiting : String
, noJobsFailed : String
, noJobsSuccess : String
, deleteThisJob : String
, showLog : String
, remove : String
, retries : String
, changePriority : String
, prio : String
}
gb : Texts
gb =
{ basics = Messages.Basics.gb
, currentlyRunning = "Currently Running"
, queue = "Queue"
, waiting = "Waiting"
, errored = "Errored"
, success = "Success"
, noJobsRunning = "No jobs currently running."
, noJobsDisplay = "No jobs to display."
, noJobsWaiting = "No waiting jobs."
, noJobsFailed = "No failed jobs to display."
, noJobsSuccess = "No succesfull jobs to display."
, deleteThisJob = "Cancel/Delete this job?"
, showLog = "Show log"
, remove = "Remove"
, retries = "Retries"
, changePriority = "Change priority of this job"
, prio = "Prio"
}
de : Texts
de =
gb

View File

@ -10,13 +10,14 @@ import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Messages.QueuePage exposing (Texts)
import Page.Queue.Data exposing (..)
import Styles as S
import Util.Time exposing (formatDateTime, formatIsoDateTime)
viewSidebar : Bool -> Flags -> UiSettings -> Model -> Html Msg
viewSidebar visible _ _ model =
viewSidebar : Texts -> Bool -> Flags -> UiSettings -> Model -> Html Msg
viewSidebar texts visible _ _ model =
let
count v =
case v of
@ -68,17 +69,17 @@ viewSidebar visible _ _ model =
]
]
, div [ class "flex flex-col my-2" ]
[ tabLink "" CurrentJobs "fa fa-play-circle" "Currently Running"
, tabLink "" QueueAll "fa fa-hourglass-half" "Queue"
, tabLink "ml-8" QueueWaiting "fa fa-clock" "Waiting"
, tabLink "ml-8" QueueError "fa fa-bolt" "Errored"
, tabLink "ml-8" QueueSuccess "fa fa-check" "Success"
[ tabLink "" CurrentJobs "fa fa-play-circle" texts.currentlyRunning
, tabLink "" QueueAll "fa fa-hourglass-half" texts.queue
, tabLink "ml-8" QueueWaiting "fa fa-clock" texts.waiting
, tabLink "ml-8" QueueError "fa fa-bolt" texts.errored
, tabLink "ml-8" QueueSuccess "fa fa-check" texts.success
]
]
viewContent : Flags -> UiSettings -> Model -> Html Msg
viewContent _ _ model =
viewContent : Texts -> Flags -> UiSettings -> Model -> Html Msg
viewContent texts _ _ model =
let
gridStyle =
"grid gap-4 grid-cols-1 md:grid-cols-2"
@ -103,29 +104,29 @@ viewContent _ _ model =
, case model.queueView of
CurrentJobs ->
if List.isEmpty model.state.progress then
message "No jobs currently running."
message texts.noJobsRunning
else
div [ class "flex flex-col space-y-2" ]
(List.map (renderProgressCard model) model.state.progress)
(List.map (renderProgressCard texts model) model.state.progress)
QueueAll ->
if List.isEmpty model.state.completed && List.isEmpty model.state.completed then
message "No jobs to display."
message texts.noJobsDisplay
else
div [ class gridStyle ]
(List.map (renderInfoCard model)
(List.map (renderInfoCard texts model)
(model.state.queued ++ model.state.completed)
)
QueueWaiting ->
if List.isEmpty model.state.queued then
message "No waiting jobs."
message texts.noJobsWaiting
else
div [ class gridStyle ]
(List.map (renderInfoCard model) model.state.queued)
(List.map (renderInfoCard texts model) model.state.queued)
QueueError ->
let
@ -133,11 +134,11 @@ viewContent _ _ model =
filterJobDetails model.state.completed "failed"
in
if List.isEmpty items then
message "No failed jobs to display."
message texts.noJobsFailed
else
div [ class gridStyle ]
(List.map (renderInfoCard model) items)
(List.map (renderInfoCard texts model) items)
QueueSuccess ->
let
@ -145,11 +146,11 @@ viewContent _ _ model =
filterJobDetails model.state.completed "success"
in
if List.isEmpty items then
message "No succesfull jobs to display."
message texts.noJobsSuccess
else
div [ class gridStyle ]
(List.map (renderInfoCard model) items)
(List.map (renderInfoCard texts model) items)
]
@ -189,14 +190,14 @@ renderJobLog job =
]
renderProgressCard : Model -> JobDetail -> Html Msg
renderProgressCard model job =
renderProgressCard : Texts -> Model -> JobDetail -> Html Msg
renderProgressCard texts model job =
div [ class (S.box ++ "px-2 flex flex-col") ]
[ Comp.Progress.topAttachedIndicating job.progress
, Html.map (DimmerMsg job)
(Comp.YesNoDimmer.viewN
(model.cancelJobRequest == Just job.id)
dimmerSettings
(dimmerSettings texts)
model.deleteConfirm
)
, div [ class "py-2 flex flex-row x-space-2 items-center" ]
@ -227,7 +228,7 @@ renderProgressCard model job =
]
, div [ class "py-2 flex flex-row justify-end" ]
[ button [ class S.secondaryButton, onClick (RequestCancelJob job) ]
[ text "Cancel"
[ text texts.basics.cancel
]
]
]
@ -282,8 +283,8 @@ isFinal job =
False
dimmerSettings : Comp.YesNoDimmer.Settings
dimmerSettings =
dimmerSettings : Texts -> Comp.YesNoDimmer.Settings
dimmerSettings texts =
let
defaults =
Comp.YesNoDimmer.defaultSettings
@ -292,12 +293,12 @@ dimmerSettings =
| headerClass = "text-lg text-white"
, headerIcon = ""
, extraClass = "rounded"
, message = "Cancel/Delete this job?"
, message = texts.deleteThisJob
}
renderInfoCard : Model -> JobDetail -> Html Msg
renderInfoCard model job =
renderInfoCard : Texts -> Model -> JobDetail -> Html Msg
renderInfoCard texts model job =
let
prio =
Data.Priority.fromString job.priority
@ -315,7 +316,7 @@ renderInfoCard model job =
[ Html.map (DimmerMsg job)
(Comp.YesNoDimmer.viewN
(model.cancelJobRequest == Just job.id)
dimmerSettings
(dimmerSettings texts)
model.deleteConfirm
)
, div [ class "flex flex-row" ]
@ -345,10 +346,14 @@ renderInfoCard model job =
, class S.link
, classList [ ( "hidden", not (isFinal job || job.state == "stuck") ) ]
]
[ i [ class "fa fa-file", title "Show log" ] []
[ i
[ class "fa fa-file"
, title texts.showLog
]
[]
]
, a
[ title "Remove"
[ title texts.remove
, href "#"
, class S.link
, onClick (RequestCancelJob job)
@ -391,7 +396,7 @@ renderInfoCard model job =
]
, div [ class (labelStyle False) ]
[ span [ class "mr-3" ]
[ text "Retries"
[ text texts.retries
]
, span []
[ job.retries |> String.fromInt |> text
@ -403,7 +408,7 @@ renderInfoCard model job =
[ class (labelStyle False)
, onClick (ChangePrio job.id (Data.Priority.next prio))
, href "#"
, title "Change priority of this job"
, title texts.changePriority
]
[ i [ class "sort numeric up icon" ] []
, text "Prio"
@ -422,7 +427,7 @@ renderInfoCard model job =
[ class (labelStyle False)
]
[ span [ class "mr-3" ]
[ text "Prio"
[ text texts.prio
]
, code [ class "font-mono" ]
[ Data.Priority.fromString job.priority