Skip to main content

IAdminForthPlugin

Properties

activationOrder

activationOrder: number

Before activating all plugins are sorted by this number and then activated in order. If you want to make sure that your plugin is activated after some other plugin, set this number to higher value. (default is 0)


adminforth

adminforth: IAdminForth


className

className: string


customFolderName

customFolderName: string


customFolderPath

customFolderPath: string


pluginDir

pluginDir: string


pluginInstanceId

pluginInstanceId: string


pluginOptions

pluginOptions: any


resourceConfig

resourceConfig: AdminForthResource

Methods

componentPath()

componentPath(componentFile): string

Parameters

ParameterType
componentFilestring

Returns

string


instanceUniqueRepresentation()

instanceUniqueRepresentation(pluginOptions): string

If plugin should support multiple installations per one resource, this function that should return unique string for each instance of plugin. For example if plugin is installed for one column and this column defined as targetColumn in plugin options, then this method should return ${pluginOptions.targetColumn}.

If plugin should support only one installation per resource, option can return 'single'

Parameters

ParameterTypeDescription
pluginOptionsanyoptions of plugin

Returns

string


modifyResourceConfig()

modifyResourceConfig(adminforth, resourceConfig): void

AdminForth plugins concept is based on modification of full AdminForth configuration to add some custom functionality. For example plugin might simply add custom field to resource by reusing AdminForthResourceColumn.components object, then add some hook which will modify record before getting or saving it to database.

So this method is core of AdminForth plugins. It allows to modify full resource configuration.

Parameters

ParameterTypeDescription
adminforthIAdminForthInstance of IAdminForth
resourceConfigAdminForthResourceResource configuration object which will be modified by plugin

Returns

void


setupEndpoints()

setupEndpoints(server): void

Here you can register custom endpoints for your plugin.

Parameters

ParameterTypeDescription
serverIHttpServer

Returns

void


validateConfigAfterDiscover()?

optional validateConfigAfterDiscover(adminforth, resourceConfig): void

Optional method which will be called after AdminForth discovers all resources and their columns. Can be used to validate types of columns, check if some columns are missing, etc.

Parameters

ParameterType
adminforthIAdminForth
resourceConfigAdminForthResource

Returns

void