mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Change job priority on queue page
This commit is contained in:
@ -86,6 +86,7 @@ module Api exposing
|
||||
, setItemDueDate
|
||||
, setItemName
|
||||
, setItemNotes
|
||||
, setJobPrio
|
||||
, setTags
|
||||
, setUnconfirmed
|
||||
, startClassifier
|
||||
@ -129,6 +130,7 @@ import Api.Model.ItemLightList exposing (ItemLightList)
|
||||
import Api.Model.ItemProposals exposing (ItemProposals)
|
||||
import Api.Model.ItemSearch exposing (ItemSearch)
|
||||
import Api.Model.ItemUploadMeta exposing (ItemUploadMeta)
|
||||
import Api.Model.JobPriority exposing (JobPriority)
|
||||
import Api.Model.JobQueueState exposing (JobQueueState)
|
||||
import Api.Model.MoveAttachment exposing (MoveAttachment)
|
||||
import Api.Model.NewFolder exposing (NewFolder)
|
||||
@ -160,6 +162,7 @@ import Api.Model.UserPass exposing (UserPass)
|
||||
import Api.Model.VersionInfo exposing (VersionInfo)
|
||||
import Data.ContactType exposing (ContactType)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.Priority exposing (Priority)
|
||||
import File exposing (File)
|
||||
import Http
|
||||
import Json.Encode as JsonEncode
|
||||
@ -1197,6 +1200,21 @@ deleteUser flags user receive =
|
||||
--- Job Queue
|
||||
|
||||
|
||||
setJobPrio : Flags -> String -> Priority -> (Result Http.Error BasicResult -> msg) -> Cmd msg
|
||||
setJobPrio flags jobid prio receive =
|
||||
Http2.authPost
|
||||
{ url = flags.config.baseUrl ++ "/api/v1/sec/queue/" ++ jobid ++ "/priority"
|
||||
, account = getAccount flags
|
||||
, body =
|
||||
Data.Priority.toName prio
|
||||
|> String.toLower
|
||||
|> JobPriority
|
||||
|> Api.Model.JobPriority.encode
|
||||
|> Http.jsonBody
|
||||
, expect = Http.expectJson receive Api.Model.BasicResult.decoder
|
||||
}
|
||||
|
||||
|
||||
cancelJob : Flags -> String -> (Result Http.Error BasicResult -> msg) -> Cmd msg
|
||||
cancelJob flags jobid receive =
|
||||
Http2.authPost
|
||||
|
@ -2,6 +2,7 @@ module Data.Priority exposing
|
||||
( Priority(..)
|
||||
, all
|
||||
, fromString
|
||||
, next
|
||||
, toName
|
||||
)
|
||||
|
||||
@ -38,6 +39,16 @@ toName lang =
|
||||
"High"
|
||||
|
||||
|
||||
next : Priority -> Priority
|
||||
next prio =
|
||||
case prio of
|
||||
High ->
|
||||
Low
|
||||
|
||||
Low ->
|
||||
High
|
||||
|
||||
|
||||
all : List Priority
|
||||
all =
|
||||
[ Low, High ]
|
||||
|
@ -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