Safe Haskell | None |
---|
This module allows IHP applications to generate a dashboard for interacting with job types. To start, first define a type for the dashboard:
type MyDashboard = JobsDashboardController NoAuth '[]
And include the following in the controllers
list of a FrontController:
parseRoute @MyDashboard
This generates a dashboard with listings for all tables which have names ending with "_jobs".
All views are fully customizable. For more info, see the documentation for DisplayableJob
.
If you implement custom behavior for a job type, add it to the list in the Dashboard type:
type MyDashboard = JobsDashboardController NoAuth '[EmailUserJob, UpdateRecordJob]
Synopsis
- module IHP.Job.Dashboard.View
- module IHP.Job.Dashboard.Auth
- module IHP.Job.Dashboard.Types
- class JobsDashboard (jobs :: [Type]) where
- makeDashboard :: IO SomeView
- includedJobTables :: [Text]
- indexPage :: IO ()
- listJob :: Text -> IO ()
- listJob' :: Bool -> IO ()
- viewJob :: Text -> UUID -> IO ()
- viewJob' :: Bool -> IO ()
- newJob :: Text -> IO ()
- newJob' :: Bool -> IO ()
- deleteJob :: Text -> UUID -> IO ()
- deleteJob' :: Bool -> IO ()
- retryJob :: Text -> UUID -> IO ()
- retryJob' :: IO ()
- class (job ~ GetModelByTableName (GetTableName job), FilterPrimaryKey (GetTableName job), FromRow job, Show (PrimaryKey (GetTableName job)), FromField (PrimaryKey (GetTableName job)), ToField (PrimaryKey (GetTableName job)), KnownSymbol (GetTableName job), HasField "id" job (Id job), HasField "status" job JobStatus, HasField "updatedAt" job UTCTime, HasField "createdAt" job UTCTime, HasField "lastError" job (Maybe Text), CanUpdate job, CanCreate job, Record job, Show job, Eq job, Table job, Typeable job) => DisplayableJob job where
- makeDashboardSection :: IO SomeView
- makePageView :: Int -> Int -> IO SomeView
- makeDetailView :: job -> IO SomeView
- makeNewJobView :: IO SomeView
- createNewJob :: IO ()
- data JobsDashboardController (authType :: k) (jobs :: [Type])
- = ListJobsAction
- | ListJobAction {
- jobTableName :: Text
- page :: Int
- | ViewJobAction {
- jobTableName :: Text
- jobId :: UUID
- | CreateJobAction {
- jobTableName :: Text
- | DeleteJobAction {
- jobTableName :: Text
- jobId :: UUID
- | RetryJobAction {
- jobTableName :: Text
- jobId :: UUID
- | ListJobAction'
- | ViewJobAction'
- | CreateJobAction'
- | DeleteJobAction'
- | RetryJobAction'
- getTableName :: DisplayableJob job => job -> Text
Documentation
module IHP.Job.Dashboard.View
module IHP.Job.Dashboard.Auth
module IHP.Job.Dashboard.Types
class JobsDashboard (jobs :: [Type]) where Source #
Defines implementations for actions for acting on a dashboard made of some list of types. This is included to allow these actions to recurse on the types, isn't possible in an IHP Controller action implementation.
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.
makeDashboard :: IO SomeView Source #
Creates the entire dashboard by recursing on the type list and calling makeDashboardSection
on each type.
includedJobTables :: [Text] Source #
Renders the index page, which is the view returned from makeDashboard
.
listJob :: Text -> IO () Source #
listJob' :: Bool -> IO () Source #
viewJob :: Text -> UUID -> IO () Source #
Renders the detail view page. Rescurses on the type list to find a type with the same table name as the "tableName" query parameter.
viewJob' :: Bool -> IO () Source #
newJob :: Text -> IO () Source #
If performed in a POST request, creates a new job depending on the "tableName" query parameter. If performed in a GET request, renders the new job from depending on said parameter.
newJob' :: Bool -> IO () Source #
deleteJob :: Text -> UUID -> IO () Source #
Deletes a job from the database.
deleteJob' :: Bool -> IO () Source #
Instances
JobsDashboard ('[] :: [Type]) Source # | |
Defined in IHP.Job.Dashboard makeDashboard :: IO SomeView Source # includedJobTables :: [Text] Source # listJob :: Text -> IO () Source # listJob' :: Bool -> IO () Source # viewJob :: Text -> UUID -> IO () Source # viewJob' :: Bool -> IO () Source # newJob :: Text -> IO () Source # newJob' :: Bool -> IO () Source # deleteJob :: Text -> UUID -> IO () Source # deleteJob' :: Bool -> IO () Source # | |
(DisplayableJob job, JobsDashboard rest) => JobsDashboard (job ': rest) Source # | Defines the default implementation for a dashboard of a list of job types.
We know the current job is a |
Defined in IHP.Job.Dashboard makeDashboard :: IO SomeView Source # includedJobTables :: [Text] Source # listJob :: Text -> IO () Source # listJob' :: Bool -> IO () Source # viewJob :: Text -> UUID -> IO () Source # viewJob' :: Bool -> IO () Source # newJob :: Text -> IO () Source # newJob' :: Bool -> IO () Source # deleteJob :: Text -> UUID -> IO () Source # deleteJob' :: Bool -> IO () Source # |
class (job ~ GetModelByTableName (GetTableName job), FilterPrimaryKey (GetTableName job), FromRow job, Show (PrimaryKey (GetTableName job)), FromField (PrimaryKey (GetTableName job)), ToField (PrimaryKey (GetTableName job)), KnownSymbol (GetTableName job), HasField "id" job (Id job), HasField "status" job JobStatus, HasField "updatedAt" job UTCTime, HasField "createdAt" job UTCTime, HasField "lastError" job (Maybe Text), CanUpdate job, CanCreate job, Record job, Show job, Eq job, Table job, Typeable job) => DisplayableJob job where Source #
The crazy list of type constraints for this class defines everything needed for a generic Job.
All jobs created through the IHP dev IDE will automatically satisfy these constraints and thus be able to
be used as a DisplayableJob
.
To customize the dashboard behavior for each job, you should provide a custom implementation of DisplayableJob
for your job type. Your custom implementations will then be used instead of the defaults.
makeDashboardSection :: IO SomeView Source #
How this job's section should be displayed in the dashboard. By default it's displayed as a table, but this can be any arbitrary view! Make some cool graphs :)
makePageView :: Int -> Int -> IO SomeView Source #
makeDetailView :: job -> IO SomeView Source #
The content of the page that will be displayed for a detail view of this job. By default, the ID, Status, Created/Updated at times, and last error are displayed. Can be defined as any arbitrary view.
makeNewJobView :: IO SomeView Source #
The content of the page that will be displayed for the "new job" form of this job. By default, only the submit button is rendered. For additonal form data, define your own implementation. Can be defined as any arbitrary view, but it should be a form.
createNewJob :: IO () Source #
The action run to create and insert a new value of this job into the database. By default, create an empty record and insert it. To add more data, define your own implementation.
data JobsDashboardController (authType :: k) (jobs :: [Type]) Source #
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.
Instances
(Typeable authType, Typeable k, Typeable jobs) => Data (JobsDashboardController authType jobs) Source # | |
Defined in IHP.Job.Dashboard.Types gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> JobsDashboardController authType jobs -> c (JobsDashboardController authType jobs) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (JobsDashboardController authType jobs) # toConstr :: JobsDashboardController authType jobs -> Constr # dataTypeOf :: JobsDashboardController authType jobs -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (JobsDashboardController authType jobs)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (JobsDashboardController authType jobs)) # gmapT :: (forall b. Data b => b -> b) -> JobsDashboardController authType jobs -> JobsDashboardController authType jobs # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> JobsDashboardController authType jobs -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> JobsDashboardController authType jobs -> r # gmapQ :: (forall d. Data d => d -> u) -> JobsDashboardController authType jobs -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> JobsDashboardController authType jobs -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> JobsDashboardController authType jobs -> m (JobsDashboardController authType jobs) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> JobsDashboardController authType jobs -> m (JobsDashboardController authType jobs) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> JobsDashboardController authType jobs -> m (JobsDashboardController authType jobs) # | |
Show (JobsDashboardController authType jobs) Source # | |
Defined in IHP.Job.Dashboard.Types showsPrec :: Int -> JobsDashboardController authType jobs -> ShowS # show :: JobsDashboardController authType jobs -> String showList :: [JobsDashboardController authType jobs] -> ShowS # | |
Eq (JobsDashboardController authType jobs) Source # | |
Defined in IHP.Job.Dashboard.Types (==) :: JobsDashboardController authType jobs -> JobsDashboardController authType jobs -> Bool # (/=) :: JobsDashboardController authType jobs -> JobsDashboardController authType jobs -> Bool # | |
(JobsDashboard jobs, AuthenticationMethod authType) => Controller (JobsDashboardController authType jobs) Source # | |
Defined in IHP.Job.Dashboard beforeAction :: IO () Source # action :: JobsDashboardController authType jobs -> IO () Source # | |
CanRoute (JobsDashboardController authType jobs) Source # | |
Defined in IHP.Job.Dashboard.Types parseRoute' :: Parser (JobsDashboardController authType jobs) Source # | |
HasPath (JobsDashboardController authType jobs) Source # | |
Defined in IHP.Job.Dashboard.Types pathTo :: JobsDashboardController authType jobs -> Text Source # |
getTableName :: DisplayableJob job => job -> Text Source #
We can't always access the type of our job in order to use type application syntax for tableName
.
This is just a convinence function for those cases.
Orphan instances
(JobsDashboard jobs, AuthenticationMethod authType) => Controller (JobsDashboardController authType jobs) Source # | |
beforeAction :: IO () Source # action :: JobsDashboardController authType jobs -> IO () Source # |