mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 19:08:26 +00:00
Change job priority on queue page
This commit is contained in:
@ -10,6 +10,7 @@ import Api.Model.BasicResult exposing (BasicResult)
|
||||
import Api.Model.JobDetail exposing (JobDetail)
|
||||
import Api.Model.JobQueueState exposing (JobQueueState)
|
||||
import Comp.YesNoDimmer
|
||||
import Data.Priority exposing (Priority)
|
||||
import Http
|
||||
import Time
|
||||
import Util.Duration
|
||||
@ -53,6 +54,7 @@ type Msg
|
||||
| RequestCancelJob JobDetail
|
||||
| DimmerMsg JobDetail Comp.YesNoDimmer.Msg
|
||||
| CancelResp (Result Http.Error BasicResult)
|
||||
| ChangePrio String Priority
|
||||
|
||||
|
||||
getRunningTime : Model -> JobDetail -> Maybe String
|
||||
|
@ -86,6 +86,9 @@ update flags msg model =
|
||||
CancelResp (Err _) ->
|
||||
( model, Cmd.none )
|
||||
|
||||
ChangePrio id prio ->
|
||||
( model, Api.setJobPrio flags id prio CancelResp )
|
||||
|
||||
|
||||
getNewTime : Cmd Msg
|
||||
getNewTime =
|
||||
|
@ -143,6 +143,11 @@ dimmerSettings =
|
||||
|
||||
renderInfoCard : Model -> JobDetail -> Html Msg
|
||||
renderInfoCard model job =
|
||||
let
|
||||
prio =
|
||||
Data.Priority.fromString job.priority
|
||||
|> Maybe.withDefault Data.Priority.Low
|
||||
in
|
||||
div
|
||||
[ classList
|
||||
[ ( "ui fluid card", True )
|
||||
@ -194,23 +199,46 @@ renderInfoCard model job =
|
||||
|
||||
else
|
||||
span [ class "invisible" ] []
|
||||
, div [ class ("ui basic label " ++ jobStateColor job) ]
|
||||
[ text "Prio"
|
||||
, div [ class "detail" ]
|
||||
[ code []
|
||||
[ Data.Priority.fromString job.priority
|
||||
|> Maybe.map Data.Priority.toName
|
||||
|> Maybe.withDefault job.priority
|
||||
|> text
|
||||
]
|
||||
]
|
||||
]
|
||||
, div [ class ("ui basic label " ++ jobStateColor job) ]
|
||||
[ text "Retries"
|
||||
, div [ class "detail" ]
|
||||
[ job.retries |> String.fromInt |> text
|
||||
]
|
||||
]
|
||||
, case job.state of
|
||||
"waiting" ->
|
||||
a
|
||||
[ class ("ui basic label " ++ jobStateColor job)
|
||||
, onClick (ChangePrio job.id (Data.Priority.next prio))
|
||||
, href "#"
|
||||
, title "Change priority of this job"
|
||||
]
|
||||
[ i [ class "sort numeric up icon" ] []
|
||||
, text "Prio"
|
||||
, div [ class "detail" ]
|
||||
[ code []
|
||||
[ Data.Priority.fromString job.priority
|
||||
|> Maybe.map Data.Priority.toName
|
||||
|> Maybe.withDefault job.priority
|
||||
|> text
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
_ ->
|
||||
div
|
||||
[ class ("ui basic label " ++ jobStateColor job)
|
||||
]
|
||||
[ text "Prio"
|
||||
, div [ class "detail" ]
|
||||
[ code []
|
||||
[ Data.Priority.fromString job.priority
|
||||
|> Maybe.map Data.Priority.toName
|
||||
|> Maybe.withDefault job.priority
|
||||
|> text
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
, jobStateLabel job
|
||||
, div [ class "ui basic label" ]
|
||||
|
Reference in New Issue
Block a user