{-|
Module: IHP.Job.Dashboard.Types
Description:  Types for Job dashboard
-}
{-# LANGUAGE AllowAmbiguousTypes #-}
module IHP.Job.Dashboard.Types (
    BaseJob(..),
    JobsDashboardController(..),
    TableViewable(..),
    IncludeWrapper(..),
) where

import IHP.Prelude
import IHP.ControllerPrelude
import qualified Database.PostgreSQL.Simple as PG
import qualified Database.PostgreSQL.Simple.Types as PG
import qualified Database.PostgreSQL.Simple.FromField as PG
import qualified Database.PostgreSQL.Simple.ToField as PG
import IHP.ViewPrelude (Html, View, hsx, html, timeAgo, columnNameToFieldLabel, JobStatus(..))
import IHP.RouterPrelude hiding (get, tshow, error, map, putStrLn, elem)
import Database.PostgreSQL.Simple.FromRow (FromRow(..), field)
import IHP.Job.Queue () -- get FromField definition for JobStatus

import IHP.Job.Dashboard.Auth

data BaseJob = BaseJob {
    BaseJob -> Text
table :: Text
  , BaseJob -> UUID
id :: UUID
  , BaseJob -> JobStatus
status :: JobStatus
  , BaseJob -> UTCTime
updatedAt :: UTCTime
  , BaseJob -> UTCTime
createdAt :: UTCTime
  , BaseJob -> Maybe Text
lastError :: Maybe Text
} deriving (Int -> BaseJob -> ShowS
[BaseJob] -> ShowS
BaseJob -> String
(Int -> BaseJob -> ShowS)
-> (BaseJob -> String) -> ([BaseJob] -> ShowS) -> Show BaseJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BaseJob] -> ShowS
$cshowList :: [BaseJob] -> ShowS
show :: BaseJob -> String
$cshow :: BaseJob -> String
showsPrec :: Int -> BaseJob -> ShowS
$cshowsPrec :: Int -> BaseJob -> ShowS
Show)

class TableViewable a where
    -- | Human readable title displayed on the table
    tableTitle :: Text

    -- | Database table backing the view
    modelTableName :: Text

    tableHeaders :: [Text]
    renderTableRow :: a -> Html

    -- | Link used in the table to send user to new job form
    newJobLink :: Html

    -- | Gets records for displaying in the dashboard index page
    getIndex :: (?context :: ControllerContext, ?modelContext :: ModelContext) => IO [a]

    -- | Gets paginated records for displaying in the list page
    getPage :: (?context :: ControllerContext, ?modelContext :: ModelContext) => Int -> Int -> IO [a]

instance FromRow BaseJob where
    fromRow :: RowParser BaseJob
fromRow = Text
-> UUID -> JobStatus -> UTCTime -> UTCTime -> Maybe Text -> BaseJob
BaseJob (Text
 -> UUID
 -> JobStatus
 -> UTCTime
 -> UTCTime
 -> Maybe Text
 -> BaseJob)
-> RowParser Text
-> RowParser
     (UUID -> JobStatus -> UTCTime -> UTCTime -> Maybe Text -> BaseJob)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RowParser Text
forall a. FromField a => RowParser a
field RowParser
  (UUID -> JobStatus -> UTCTime -> UTCTime -> Maybe Text -> BaseJob)
-> RowParser UUID
-> RowParser
     (JobStatus -> UTCTime -> UTCTime -> Maybe Text -> BaseJob)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RowParser UUID
forall a. FromField a => RowParser a
field RowParser
  (JobStatus -> UTCTime -> UTCTime -> Maybe Text -> BaseJob)
-> RowParser JobStatus
-> RowParser (UTCTime -> UTCTime -> Maybe Text -> BaseJob)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RowParser JobStatus
forall a. FromField a => RowParser a
field RowParser (UTCTime -> UTCTime -> Maybe Text -> BaseJob)
-> RowParser UTCTime
-> RowParser (UTCTime -> Maybe Text -> BaseJob)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RowParser UTCTime
forall a. FromField a => RowParser a
field RowParser (UTCTime -> Maybe Text -> BaseJob)
-> RowParser UTCTime -> RowParser (Maybe Text -> BaseJob)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RowParser UTCTime
forall a. FromField a => RowParser a
field RowParser (Maybe Text -> BaseJob)
-> RowParser (Maybe Text) -> RowParser BaseJob
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RowParser (Maybe Text)
forall a. FromField a => RowParser a
field

-- | Often, jobs are related to some model type. These relations are modeled through the type system.
-- For example, the type 'Include "userId" UpdateUserJob' models an 'UpdateUserJob' type that can access
-- the 'User' it belongs to through the 'userId' field.
-- For some reason, GHC doesn't allow us to create implementations of type family applications, so the following doesn't work:
--
-- > instance DisplayableJob (Include "userId" UpdateUserJob) where
--
-- However, if we wrap this in a concrete type, it works fine. That's what this wrapper is for.
-- To get the same behavior as above, just define
--
-- > instance DisplayableJob (IncludeWrapper "userId" UpdateUserJob) where
--
-- and wrap the values as so:
--
-- > jobsWithUsers <- query @UpdateUserJob
-- >    |> fetch
-- >    >>= mapM (fetchRelated #userId)
-- >    >>= pure . map (IncludeWrapper @"userId" @UpdateUserJob)
newtype IncludeWrapper (id :: Symbol) job = IncludeWrapper (Include id job)

-- | Defines controller actions for acting on a dashboard made of some list of types.
-- Later functions and typeclasses introduce constraints on the types in this list,
-- so you'll get a compile error if you try and include a type that is not a job.
data JobsDashboardController authType (jobs :: [*])
    = ListJobsAction
    | ListJobAction { JobsDashboardController authType jobs -> Text
jobTableName :: Text, JobsDashboardController authType jobs -> Int
page :: Int }
    -- These actions are used for 'pathTo'. Need  to pass the parameters explicity to know how to build the path
    | ViewJobAction { jobTableName :: Text, JobsDashboardController authType jobs -> UUID
jobId :: UUID }
    | CreateJobAction { jobTableName :: Text }
    | DeleteJobAction { jobTableName :: Text, jobId :: UUID }

    -- These actions are used for interal routing. Parameters are extracted dynamically in the action based on types
    | ListJobAction'
    | ViewJobAction'
    | CreateJobAction'
    | DeleteJobAction'
    deriving (Int -> JobsDashboardController authType jobs -> ShowS
[JobsDashboardController authType jobs] -> ShowS
JobsDashboardController authType jobs -> String
(Int -> JobsDashboardController authType jobs -> ShowS)
-> (JobsDashboardController authType jobs -> String)
-> ([JobsDashboardController authType jobs] -> ShowS)
-> Show (JobsDashboardController authType jobs)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall authType (jobs :: [*]).
Int -> JobsDashboardController authType jobs -> ShowS
forall authType (jobs :: [*]).
[JobsDashboardController authType jobs] -> ShowS
forall authType (jobs :: [*]).
JobsDashboardController authType jobs -> String
showList :: [JobsDashboardController authType jobs] -> ShowS
$cshowList :: forall authType (jobs :: [*]).
[JobsDashboardController authType jobs] -> ShowS
show :: JobsDashboardController authType jobs -> String
$cshow :: forall authType (jobs :: [*]).
JobsDashboardController authType jobs -> String
showsPrec :: Int -> JobsDashboardController authType jobs -> ShowS
$cshowsPrec :: forall authType (jobs :: [*]).
Int -> JobsDashboardController authType jobs -> ShowS
Show, JobsDashboardController authType jobs
-> JobsDashboardController authType jobs -> Bool
(JobsDashboardController authType jobs
 -> JobsDashboardController authType jobs -> Bool)
-> (JobsDashboardController authType jobs
    -> JobsDashboardController authType jobs -> Bool)
-> Eq (JobsDashboardController authType jobs)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall authType (jobs :: [*]).
JobsDashboardController authType jobs
-> JobsDashboardController authType jobs -> Bool
/= :: JobsDashboardController authType jobs
-> JobsDashboardController authType jobs -> Bool
$c/= :: forall authType (jobs :: [*]).
JobsDashboardController authType jobs
-> JobsDashboardController authType jobs -> Bool
== :: JobsDashboardController authType jobs
-> JobsDashboardController authType jobs -> Bool
$c== :: forall authType (jobs :: [*]).
JobsDashboardController authType jobs
-> JobsDashboardController authType jobs -> Bool
Eq, Typeable (JobsDashboardController authType jobs)
Constr
DataType
Typeable (JobsDashboardController authType jobs)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> JobsDashboardController authType jobs
    -> c (JobsDashboardController authType jobs))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r)
    -> Constr
    -> c (JobsDashboardController authType jobs))
-> (JobsDashboardController authType jobs -> Constr)
-> (JobsDashboardController authType jobs -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d))
    -> Maybe (c (JobsDashboardController authType jobs)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (JobsDashboardController authType jobs)))
-> ((forall b. Data b => b -> b)
    -> JobsDashboardController authType jobs
    -> JobsDashboardController authType jobs)
-> (forall r r'.
    (r -> r' -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> JobsDashboardController authType jobs
    -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> JobsDashboardController authType jobs
    -> r)
-> (forall u.
    (forall d. Data d => d -> u)
    -> JobsDashboardController authType jobs -> [u])
-> (forall u.
    Int
    -> (forall d. Data d => d -> u)
    -> JobsDashboardController authType jobs
    -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> JobsDashboardController authType jobs
    -> m (JobsDashboardController authType jobs))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> JobsDashboardController authType jobs
    -> m (JobsDashboardController authType jobs))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> JobsDashboardController authType jobs
    -> m (JobsDashboardController authType jobs))
-> Data (JobsDashboardController authType jobs)
JobsDashboardController authType jobs -> Constr
JobsDashboardController authType jobs -> DataType
(forall b. Data b => b -> b)
-> JobsDashboardController authType jobs
-> JobsDashboardController authType jobs
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> JobsDashboardController authType jobs
-> c (JobsDashboardController authType jobs)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c (JobsDashboardController authType jobs)
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int
-> (forall d. Data d => d -> u)
-> JobsDashboardController authType jobs
-> u
forall u.
(forall d. Data d => d -> u)
-> JobsDashboardController authType jobs -> [u]
forall authType (jobs :: [*]).
(Typeable authType, Typeable jobs) =>
Typeable (JobsDashboardController authType jobs)
forall authType (jobs :: [*]).
(Typeable authType, Typeable jobs) =>
JobsDashboardController authType jobs -> Constr
forall authType (jobs :: [*]).
(Typeable authType, Typeable jobs) =>
JobsDashboardController authType jobs -> DataType
forall authType (jobs :: [*]).
(Typeable authType, Typeable jobs) =>
(forall b. Data b => b -> b)
-> JobsDashboardController authType jobs
-> JobsDashboardController authType jobs
forall authType (jobs :: [*]) u.
(Typeable authType, Typeable jobs) =>
Int
-> (forall d. Data d => d -> u)
-> JobsDashboardController authType jobs
-> u
forall authType (jobs :: [*]) u.
(Typeable authType, Typeable jobs) =>
(forall d. Data d => d -> u)
-> JobsDashboardController authType jobs -> [u]
forall authType (jobs :: [*]) r r'.
(Typeable authType, Typeable jobs) =>
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> JobsDashboardController authType jobs
-> r
forall authType (jobs :: [*]) r r'.
(Typeable authType, Typeable jobs) =>
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> JobsDashboardController authType jobs
-> r
forall authType (jobs :: [*]) (m :: * -> *).
(Typeable authType, Typeable jobs, Monad m) =>
(forall d. Data d => d -> m d)
-> JobsDashboardController authType jobs
-> m (JobsDashboardController authType jobs)
forall authType (jobs :: [*]) (m :: * -> *).
(Typeable authType, Typeable jobs, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> JobsDashboardController authType jobs
-> m (JobsDashboardController authType jobs)
forall authType (jobs :: [*]) (c :: * -> *).
(Typeable authType, Typeable jobs) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c (JobsDashboardController authType jobs)
forall authType (jobs :: [*]) (c :: * -> *).
(Typeable authType, Typeable jobs) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> JobsDashboardController authType jobs
-> c (JobsDashboardController authType jobs)
forall authType (jobs :: [*]) (t :: * -> *) (c :: * -> *).
(Typeable authType, Typeable jobs, Typeable t) =>
(forall d. Data d => c (t d))
-> Maybe (c (JobsDashboardController authType jobs))
forall authType (jobs :: [*]) (t :: * -> * -> *) (c :: * -> *).
(Typeable authType, Typeable jobs, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (JobsDashboardController authType jobs))
forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> JobsDashboardController authType jobs
-> r
forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> JobsDashboardController authType jobs
-> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> JobsDashboardController authType jobs
-> m (JobsDashboardController authType jobs)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> JobsDashboardController authType jobs
-> m (JobsDashboardController authType jobs)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c (JobsDashboardController authType jobs)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> JobsDashboardController authType jobs
-> c (JobsDashboardController authType jobs)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c (JobsDashboardController authType jobs))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (JobsDashboardController authType jobs))
$cDeleteJobAction' :: Constr
$cCreateJobAction' :: Constr
$cViewJobAction' :: Constr
$cListJobAction' :: Constr
$cDeleteJobAction :: Constr
$cCreateJobAction :: Constr
$cViewJobAction :: Constr
$cListJobAction :: Constr
$cListJobsAction :: Constr
$tJobsDashboardController :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> JobsDashboardController authType jobs
-> m (JobsDashboardController authType jobs)
$cgmapMo :: forall authType (jobs :: [*]) (m :: * -> *).
(Typeable authType, Typeable jobs, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> JobsDashboardController authType jobs
-> m (JobsDashboardController authType jobs)
gmapMp :: (forall d. Data d => d -> m d)
-> JobsDashboardController authType jobs
-> m (JobsDashboardController authType jobs)
$cgmapMp :: forall authType (jobs :: [*]) (m :: * -> *).
(Typeable authType, Typeable jobs, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> JobsDashboardController authType jobs
-> m (JobsDashboardController authType jobs)
gmapM :: (forall d. Data d => d -> m d)
-> JobsDashboardController authType jobs
-> m (JobsDashboardController authType jobs)
$cgmapM :: forall authType (jobs :: [*]) (m :: * -> *).
(Typeable authType, Typeable jobs, Monad m) =>
(forall d. Data d => d -> m d)
-> JobsDashboardController authType jobs
-> m (JobsDashboardController authType jobs)
gmapQi :: Int
-> (forall d. Data d => d -> u)
-> JobsDashboardController authType jobs
-> u
$cgmapQi :: forall authType (jobs :: [*]) u.
(Typeable authType, Typeable jobs) =>
Int
-> (forall d. Data d => d -> u)
-> JobsDashboardController authType jobs
-> u
gmapQ :: (forall d. Data d => d -> u)
-> JobsDashboardController authType jobs -> [u]
$cgmapQ :: forall authType (jobs :: [*]) u.
(Typeable authType, Typeable jobs) =>
(forall d. Data d => d -> u)
-> JobsDashboardController authType jobs -> [u]
gmapQr :: (r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> JobsDashboardController authType jobs
-> r
$cgmapQr :: forall authType (jobs :: [*]) r r'.
(Typeable authType, Typeable jobs) =>
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> JobsDashboardController authType jobs
-> r
gmapQl :: (r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> JobsDashboardController authType jobs
-> r
$cgmapQl :: forall authType (jobs :: [*]) r r'.
(Typeable authType, Typeable jobs) =>
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> JobsDashboardController authType jobs
-> r
gmapT :: (forall b. Data b => b -> b)
-> JobsDashboardController authType jobs
-> JobsDashboardController authType jobs
$cgmapT :: forall authType (jobs :: [*]).
(Typeable authType, Typeable jobs) =>
(forall b. Data b => b -> b)
-> JobsDashboardController authType jobs
-> JobsDashboardController authType jobs
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (JobsDashboardController authType jobs))
$cdataCast2 :: forall authType (jobs :: [*]) (t :: * -> * -> *) (c :: * -> *).
(Typeable authType, Typeable jobs, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (JobsDashboardController authType jobs))
dataCast1 :: (forall d. Data d => c (t d))
-> Maybe (c (JobsDashboardController authType jobs))
$cdataCast1 :: forall authType (jobs :: [*]) (t :: * -> *) (c :: * -> *).
(Typeable authType, Typeable jobs, Typeable t) =>
(forall d. Data d => c (t d))
-> Maybe (c (JobsDashboardController authType jobs))
dataTypeOf :: JobsDashboardController authType jobs -> DataType
$cdataTypeOf :: forall authType (jobs :: [*]).
(Typeable authType, Typeable jobs) =>
JobsDashboardController authType jobs -> DataType
toConstr :: JobsDashboardController authType jobs -> Constr
$ctoConstr :: forall authType (jobs :: [*]).
(Typeable authType, Typeable jobs) =>
JobsDashboardController authType jobs -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c (JobsDashboardController authType jobs)
$cgunfold :: forall authType (jobs :: [*]) (c :: * -> *).
(Typeable authType, Typeable jobs) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c (JobsDashboardController authType jobs)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> JobsDashboardController authType jobs
-> c (JobsDashboardController authType jobs)
$cgfoldl :: forall authType (jobs :: [*]) (c :: * -> *).
(Typeable authType, Typeable jobs) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> JobsDashboardController authType jobs
-> c (JobsDashboardController authType jobs)
$cp1Data :: forall authType (jobs :: [*]).
(Typeable authType, Typeable jobs) =>
Typeable (JobsDashboardController authType jobs)
Data)


instance HasPath (JobsDashboardController authType jobs) where
    pathTo :: JobsDashboardController authType jobs -> Text
pathTo JobsDashboardController authType jobs
ListJobsAction = Text
"/jobs/ListJobs"
    pathTo ListJobAction   { Int
Text
page :: Int
jobTableName :: Text
$sel:page:ListJobsAction :: forall authType (jobs :: [*]).
JobsDashboardController authType jobs -> Int
$sel:jobTableName:ListJobsAction :: forall authType (jobs :: [*]).
JobsDashboardController authType jobs -> Text
.. } = Text
"/jobs/ListJob?tableName=" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
jobTableName Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"&page=" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
tshow Int
page
    pathTo ViewJobAction   { Text
UUID
jobId :: UUID
jobTableName :: Text
$sel:jobId:ListJobsAction :: forall authType (jobs :: [*]).
JobsDashboardController authType jobs -> UUID
$sel:jobTableName:ListJobsAction :: forall authType (jobs :: [*]).
JobsDashboardController authType jobs -> Text
.. } = Text
"/jobs/ViewJob?tableName=" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
jobTableName Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"&id=" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> UUID -> Text
forall a. Show a => a -> Text
tshow UUID
jobId
    pathTo CreateJobAction { Text
jobTableName :: Text
$sel:jobTableName:ListJobsAction :: forall authType (jobs :: [*]).
JobsDashboardController authType jobs -> Text
.. } = Text
"/jobs/CreateJob?tableName=" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
jobTableName
    pathTo DeleteJobAction { Text
UUID
jobId :: UUID
jobTableName :: Text
$sel:jobId:ListJobsAction :: forall authType (jobs :: [*]).
JobsDashboardController authType jobs -> UUID
$sel:jobTableName:ListJobsAction :: forall authType (jobs :: [*]).
JobsDashboardController authType jobs -> Text
.. } = Text
"/jobs/DeleteJob?tableName=" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
jobTableName Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"&id=" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> UUID -> Text
forall a. Show a => a -> Text
tshow UUID
jobId
    pathTo JobsDashboardController authType jobs
_ = Text -> Text
forall a. Text -> a
error Text
"pathTo for internal JobsDashboard functions not supported. Use non-backtick action and pass necessary parameters to use pathTo."

instance CanRoute (JobsDashboardController authType jobs) where
    parseRoute' :: Parser (JobsDashboardController authType jobs)
parseRoute' = do
        (ByteString -> Parser ByteString
string ByteString
"/jobs" Parser ByteString -> Parser ByteString () -> Parser ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Parser ByteString ()
forall t. Chunk t => Parser t ()
endOfInput Parser ByteString
-> Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> JobsDashboardController authType jobs
-> Parser (JobsDashboardController authType jobs)
forall (f :: * -> *) a. Applicative f => a -> f a
pure JobsDashboardController authType jobs
forall authType (jobs :: [*]).
JobsDashboardController authType jobs
ListJobsAction)
        Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (ByteString -> Parser ByteString
string ByteString
"/jobs/" Parser ByteString -> Parser ByteString () -> Parser ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Parser ByteString ()
forall t. Chunk t => Parser t ()
endOfInput Parser ByteString
-> Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> JobsDashboardController authType jobs
-> Parser (JobsDashboardController authType jobs)
forall (f :: * -> *) a. Applicative f => a -> f a
pure JobsDashboardController authType jobs
forall authType (jobs :: [*]).
JobsDashboardController authType jobs
ListJobsAction)
        Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (ByteString -> Parser ByteString
string ByteString
"/jobs/ListJobs" Parser ByteString -> Parser ByteString () -> Parser ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Parser ByteString ()
forall t. Chunk t => Parser t ()
endOfInput Parser ByteString
-> Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> JobsDashboardController authType jobs
-> Parser (JobsDashboardController authType jobs)
forall (f :: * -> *) a. Applicative f => a -> f a
pure JobsDashboardController authType jobs
forall authType (jobs :: [*]).
JobsDashboardController authType jobs
ListJobsAction)
        Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (ByteString -> Parser ByteString
string ByteString
"/jobs/ListJob" Parser ByteString -> Parser ByteString () -> Parser ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Parser ByteString ()
forall t. Chunk t => Parser t ()
endOfInput Parser ByteString
-> Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> JobsDashboardController authType jobs
-> Parser (JobsDashboardController authType jobs)
forall (f :: * -> *) a. Applicative f => a -> f a
pure JobsDashboardController authType jobs
forall authType (jobs :: [*]).
JobsDashboardController authType jobs
ListJobAction')
        Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (ByteString -> Parser ByteString
string ByteString
"/jobs/ViewJob" Parser ByteString -> Parser ByteString () -> Parser ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Parser ByteString ()
forall t. Chunk t => Parser t ()
endOfInput Parser ByteString
-> Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> JobsDashboardController authType jobs
-> Parser (JobsDashboardController authType jobs)
forall (f :: * -> *) a. Applicative f => a -> f a
pure JobsDashboardController authType jobs
forall authType (jobs :: [*]).
JobsDashboardController authType jobs
ViewJobAction')
        Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (ByteString -> Parser ByteString
string ByteString
"/jobs/CreateJob" Parser ByteString -> Parser ByteString () -> Parser ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Parser ByteString ()
forall t. Chunk t => Parser t ()
endOfInput Parser ByteString
-> Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> JobsDashboardController authType jobs
-> Parser (JobsDashboardController authType jobs)
forall (f :: * -> *) a. Applicative f => a -> f a
pure JobsDashboardController authType jobs
forall authType (jobs :: [*]).
JobsDashboardController authType jobs
CreateJobAction')
        Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (ByteString -> Parser ByteString
string ByteString
"/jobs/DeleteJob" Parser ByteString -> Parser ByteString () -> Parser ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Parser ByteString ()
forall t. Chunk t => Parser t ()
endOfInput Parser ByteString
-> Parser (JobsDashboardController authType jobs)
-> Parser (JobsDashboardController authType jobs)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> JobsDashboardController authType jobs
-> Parser (JobsDashboardController authType jobs)
forall (f :: * -> *) a. Applicative f => a -> f a
pure JobsDashboardController authType jobs
forall authType (jobs :: [*]).
JobsDashboardController authType jobs
DeleteJobAction')