IHP Api Reference
Safe HaskellSafe-Inferred

IHP.Job.Dashboard

Description

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

Documentation

class JobsDashboard (jobs :: [*]) 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.

Methods

makeDashboard :: (?context :: ControllerContext, ?modelContext :: ModelContext) => IO SomeView Source #

Creates the entire dashboard by recursing on the type list and calling makeDashboardSection on each type.

includedJobTables :: [Text] Source #

indexPage :: (?context :: ControllerContext, ?modelContext :: ModelContext) => IO () Source #

Renders the index page, which is the view returned from makeDashboard.

listJob :: (?context :: ControllerContext, ?modelContext :: ModelContext) => Text -> IO () Source #

listJob' :: (?context :: ControllerContext, ?modelContext :: ModelContext) => Bool -> IO () Source #

viewJob :: (?context :: ControllerContext, ?modelContext :: ModelContext) => 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' :: (?context :: ControllerContext, ?modelContext :: ModelContext) => Bool -> IO () Source #

newJob :: (?context :: ControllerContext, ?modelContext :: ModelContext) => 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' :: (?context :: ControllerContext, ?modelContext :: ModelContext) => Bool -> IO () Source #

deleteJob :: (?context :: ControllerContext, ?modelContext :: ModelContext) => Text -> UUID -> IO () Source #

Deletes a job from the database.

deleteJob' :: (?context :: ControllerContext, ?modelContext :: ModelContext) => Bool -> IO () Source #

retryJob :: (?context :: ControllerContext, ?modelContext :: ModelContext) => Text -> UUID -> IO () Source #

retryJob' :: (?context :: ControllerContext, ?modelContext :: ModelContext) => IO () Source #

Instances

Instances details
JobsDashboard ('[] :: [Type]) Source # 
Instance details

Defined in IHP.Job.Dashboard

(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 DisplayableJob, and we can recurse on the rest of the list to build the rest of the dashboard. You probably don't want to provide custom implementations for these. Read the documentation for each of the functions if you'd like to know how to customize the behavior. They mostly rely on the functions from DisplayableJob.

Instance details

Defined in IHP.Job.Dashboard

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.

Minimal complete definition

makeDashboardSection, makePageView

Methods

makeDashboardSection :: (?context :: ControllerContext, ?modelContext :: ModelContext) => 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 :: (?context :: ControllerContext, ?modelContext :: ModelContext) => Int -> Int -> IO SomeView Source #

makeDetailView :: (?context :: ControllerContext, ?modelContext :: ModelContext) => 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 :: (?context :: ControllerContext, ?modelContext :: ModelContext) => 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 :: (?context :: ControllerContext, ?modelContext :: ModelContext) => 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 (jobs :: [*]) 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

Instances details
(Typeable authType, Typeable k, Typeable jobs) => Data (JobsDashboardController authType jobs) Source # 
Instance details

Defined in IHP.Job.Dashboard.Types

Methods

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 # 
Instance details

Defined in IHP.Job.Dashboard.Types

Methods

showsPrec :: Int -> JobsDashboardController authType jobs -> ShowS #

show :: JobsDashboardController authType jobs -> String

showList :: [JobsDashboardController authType jobs] -> ShowS #

Eq (JobsDashboardController authType jobs) Source # 
Instance details

Defined in IHP.Job.Dashboard.Types

Methods

(==) :: JobsDashboardController authType jobs -> JobsDashboardController authType jobs -> Bool #

(/=) :: JobsDashboardController authType jobs -> JobsDashboardController authType jobs -> Bool #

(JobsDashboard jobs, AuthenticationMethod authType) => Controller (JobsDashboardController authType jobs) Source # 
Instance details

Defined in IHP.Job.Dashboard

Methods

beforeAction :: IO () Source #

action :: JobsDashboardController authType jobs -> IO () Source #

CanRoute (JobsDashboardController authType jobs) Source # 
Instance details

Defined in IHP.Job.Dashboard.Types

Methods

parseRoute' :: Parser (JobsDashboardController authType jobs) Source #

HasPath (JobsDashboardController authType jobs) Source # 
Instance details

Defined in IHP.Job.Dashboard.Types

Methods

pathTo :: JobsDashboardController authType jobs -> Text Source #

getTableName :: forall job. 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 # 
Instance details

Methods

beforeAction :: IO () Source #

action :: JobsDashboardController authType jobs -> IO () Source #