chore(job): add filtering to job queue view
This commit is contained in:
parent
240c6f81f8
commit
a407094253
@ -79,4 +79,5 @@ TableCompanies: Firmen
|
|||||||
TableCompanyNos: Firmennummern
|
TableCompanyNos: Firmennummern
|
||||||
TableSupervisor: Ansprechpartner
|
TableSupervisor: Ansprechpartner
|
||||||
TableCreationTime: Erstellungszeit
|
TableCreationTime: Erstellungszeit
|
||||||
TableJobContent !ident-ok: Job
|
TableJob !ident-ok: Job
|
||||||
|
TableJobContent !ident-ok: Parameter
|
||||||
|
|||||||
@ -79,4 +79,5 @@ TableCompanies: Companies
|
|||||||
TableCompanyNos: Company numbers
|
TableCompanyNos: Company numbers
|
||||||
TableSupervisor: Supervisor
|
TableSupervisor: Supervisor
|
||||||
TableCreationTime: Creation
|
TableCreationTime: Creation
|
||||||
TableJobContent: Job
|
TableJob !ident-ok: Job
|
||||||
|
TableJobContent !ident-ok: Parameters
|
||||||
@ -14,8 +14,10 @@ import Import
|
|||||||
import Jobs
|
import Jobs
|
||||||
import Handler.Utils
|
import Handler.Utils
|
||||||
|
|
||||||
import qualified Data.Aeson.Encode.Pretty as Pretty
|
-- import Data.Aeson (fromJSON)
|
||||||
import Data.Aeson.Encode.Pretty (encodePrettyToTextBuilder')
|
-- import qualified Data.Aeson as Aeson
|
||||||
|
-- import qualified Data.Aeson.Types as Aeson
|
||||||
|
import qualified Data.Aeson.Encode.Pretty as Pretty
|
||||||
|
|
||||||
-- import qualified Data.CaseInsensitive as CI
|
-- import qualified Data.CaseInsensitive as CI
|
||||||
import qualified Data.Text as Text
|
import qualified Data.Text as Text
|
||||||
@ -28,7 +30,7 @@ import qualified Data.HashMap.Strict as HashMap
|
|||||||
import qualified Data.UUID as UUID
|
import qualified Data.UUID as UUID
|
||||||
|
|
||||||
import qualified Database.Esqueleto.Legacy as E
|
import qualified Database.Esqueleto.Legacy as E
|
||||||
-- import qualified Database.Esqueleto.Utils as E
|
import qualified Database.Esqueleto.Utils as E
|
||||||
-- import Database.Esqueleto.Utils.TH
|
-- import Database.Esqueleto.Utils.TH
|
||||||
|
|
||||||
|
|
||||||
@ -97,8 +99,8 @@ getAdminCrontabR = do
|
|||||||
provideJson mCrontab'
|
provideJson mCrontab'
|
||||||
provideRep . return . Text.Builder.toLazyText $ doEnc mCrontab'
|
provideRep . return . Text.Builder.toLazyText $ doEnc mCrontab'
|
||||||
where
|
where
|
||||||
doEnc :: _ => a -> _
|
doEnc :: ToJSON a => a -> _
|
||||||
doEnc = encodePrettyToTextBuilder' Pretty.defConfig
|
doEnc = Pretty.encodePrettyToTextBuilder' Pretty.defConfig
|
||||||
{ Pretty.confIndent = Pretty.Spaces 2
|
{ Pretty.confIndent = Pretty.Spaces 2
|
||||||
, Pretty.confCompare = comparing $ \t -> ( t `elem` ["instruction", "job", "notification"]
|
, Pretty.confCompare = comparing $ \t -> ( t `elem` ["instruction", "job", "notification"]
|
||||||
, Text.splitOn "-" t
|
, Text.splitOn "-" t
|
||||||
@ -119,16 +121,24 @@ postAdminJobsR = do
|
|||||||
dbtRowKey = (E.^. QueuedJobId)
|
dbtRowKey = (E.^. QueuedJobId)
|
||||||
dbtProj = dbtProjId
|
dbtProj = dbtProjId
|
||||||
dbtColonnade = dbColonnade $ mconcat -- remove call to dbColonnade if table actions are added
|
dbtColonnade = dbColonnade $ mconcat -- remove call to dbColonnade if table actions are added
|
||||||
[ sortable (Just "creation-time") (i18nCell MsgTableCreationTime) $ \(view $ resultJob . _entityVal -> QueuedJob{..}) -> dateTimeCell queuedJobCreationTime
|
[ sortable (Just "job") (i18nCell MsgTableJob) $ \(view $ resultJob . _entityVal -> QueuedJob{..}) -> cellMaybe textCell $ getJobName queuedJobContent
|
||||||
, sortable (Just "content") (i18nCell MsgTableCreationTime) $ \(view $ resultJob . _entityVal -> QueuedJob{..}) -> stringCell $ show queuedJobContent
|
, sortable (Just "creation-time") (i18nCell MsgTableCreationTime) $ \(view $ resultJob . _entityVal -> QueuedJob{..}) -> dateTimeCell queuedJobCreationTime
|
||||||
|
, sortable (Just "content") (i18nCell MsgTableJobContent) $ \(view $ resultJob . _entityVal -> QueuedJob{..}) -> cell [whamlet|#{doEnc queuedJobContent}|] & addCellClass ("json"::Text)
|
||||||
]
|
]
|
||||||
dbtSorting = Map.fromList
|
dbtSorting = Map.fromList
|
||||||
[ ("creation-time", SortColumnNullsInv (E.^. QueuedJobCreationTime))
|
[ ("creation-time", SortColumnNullsInv (E.^. QueuedJobCreationTime))
|
||||||
|
, ("job" , SortColumn (\v -> v E.^. QueuedJobContent E.->>. "job"))
|
||||||
, ("content" , SortColumn (E.^. QueuedJobContent))
|
, ("content" , SortColumn (E.^. QueuedJobContent))
|
||||||
]
|
]
|
||||||
dbtFilter = Map.empty
|
dbtFilter = Map.fromList
|
||||||
dbtFilterUI = const mempty
|
[
|
||||||
dbtStyle = def
|
("job", FilterColumn $ E.mkContainsFilter (\v -> v E.^. QueuedJobContent E.->>. "job"))
|
||||||
|
]
|
||||||
|
dbtFilterUI = \mPrev -> mconcat
|
||||||
|
[
|
||||||
|
prismAForm (singletonFilter "job" . maybePrism _PathPiece) mPrev $ aopt (hoistField lift textField) (fslI MsgTableJob)
|
||||||
|
]
|
||||||
|
dbtStyle = def { dbsFilterLayout = defaultDBSFilterLayout }
|
||||||
dbtParams = def
|
dbtParams = def
|
||||||
dbtIdent :: Text
|
dbtIdent :: Text
|
||||||
dbtIdent = "queued-jobs"
|
dbtIdent = "queued-jobs"
|
||||||
@ -143,4 +153,17 @@ postAdminJobsR = do
|
|||||||
setTitleI MsgMenuAdminJobs
|
setTitleI MsgMenuAdminJobs
|
||||||
[whamlet|
|
[whamlet|
|
||||||
^{jobsTable}
|
^{jobsTable}
|
||||||
|]
|
|]
|
||||||
|
where
|
||||||
|
doEnc :: ToJSON a => a -> _
|
||||||
|
doEnc = Pretty.encodePrettyToTextBuilder' Pretty.defConfig
|
||||||
|
{ Pretty.confIndent = Pretty.Spaces 2
|
||||||
|
, Pretty.confCompare = comparing $ \t -> ( t `elem` ["job", "notification"]
|
||||||
|
, Text.splitOn "-" t
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
getJobName :: Value -> Maybe Text
|
||||||
|
getJobName (Object o)
|
||||||
|
| Just (String s) <- HashMap.lookup "job" o = Just s -- $ kebabToCamel s
|
||||||
|
getJobName _ = Nothing
|
||||||
@ -9,6 +9,7 @@ module Utils.PathPiece
|
|||||||
, splitCamel, dropCamel
|
, splitCamel, dropCamel
|
||||||
, camelToPathPiece, camelToPathPiece', camelToPathPiece''
|
, camelToPathPiece, camelToPathPiece', camelToPathPiece''
|
||||||
, nameToPathPiece, nameToPathPiece'
|
, nameToPathPiece, nameToPathPiece'
|
||||||
|
, kebabToCamel
|
||||||
, tuplePathPiece
|
, tuplePathPiece
|
||||||
, pathPieceJSON, pathPieceJSONKey
|
, pathPieceJSON, pathPieceJSONKey
|
||||||
, pathPieceBinary
|
, pathPieceBinary
|
||||||
@ -237,6 +238,11 @@ nameToPathPiece' dropN = camelToPathPiece' dropN . repack . nameBase
|
|||||||
nameToPathPiece :: Textual t => Name -> t
|
nameToPathPiece :: Textual t => Name -> t
|
||||||
nameToPathPiece = nameToPathPiece' 0
|
nameToPathPiece = nameToPathPiece' 0
|
||||||
|
|
||||||
|
-- | convert kebab-case to CamelCase
|
||||||
|
kebabToCamel :: Text -> Text
|
||||||
|
-- kebabToCamel = Text.filter (not . Char.isSpace) . Text.toTitle . Text.replace "-" " " -- eliminates all space
|
||||||
|
kebabToCamel = mconcat . fmap Text.toTitle . Text.split ('-'==) -- preserves existing spaces
|
||||||
|
|
||||||
|
|
||||||
tuplePathPiece :: Int -> DecQ
|
tuplePathPiece :: Int -> DecQ
|
||||||
tuplePathPiece tupleDim = do
|
tuplePathPiece tupleDim = do
|
||||||
|
|||||||
Reference in New Issue
Block a user