FunctionContainer react component
Component
- FunctionContainer.default(options)
A container to render a form for a function in a DASF backend module
This react component can be used to render a single function of a DASF backend module. You can either provide the
connection, or the details (websocketUrlandtopic) how to create one. And you can either provide the JSONschema for the function directly (viaschema), or pass the id of an HTMLscriptelement that holds the schema (viaschemaElement). If none of this is specified, we will get the JSONschema from the backend module and render the form upon response.For more information on the available options, see
FunctionContainerOptions.Example
<FunctionContainer connection={connection} functionName="test_function" onResponse={(responseData) => {console.log(responseData)}} />
- Arguments:
options (FunctionContainerOptions) – Options for the component, see
FunctionContainerOptionsfor documentation
- Returns:
Element
Options
- interface FunctionContainerOptions
Options for the
FunctionContainercomponentSee also
ContainerBaseOptionsfor further options.exported from
resources.FunctionContainerOptions- Extends:
ContainerBaseOptions
- FunctionContainerOptions.constructorData?
type: object
Constructor data for the backend class
If this function is not an independent function but rather a method of a class in the backend module, you have to pass the data for the constructor as
constructorData. See alsoClassContainer.
- FunctionContainerOptions.functionName?
type: string
The name of the function to render
This option can be used if no
schemaElementorschemais passed to the constructor. In this case, the JSONschema is loaded from the backend module. IffunctionNameis undefined, we will render the first function in the list.
- FunctionContainerOptions.outputDescription?
type: string
Description of the function output
This optional argument can be used, to label the output. Note that this does not have an effect if the
onResponsehandler handles the request.
- FunctionContainerOptions.schema?
type: any
The schema to use for the function form
Pass this argument when you want to prevent getting the JSONSchema from the backend module. Note that this argument is superseeded by schemaElement.
- FunctionContainerOptions.schemaElement?
type: string
The id of a
<script>element with JSON-encoded JSONSchema that is used to render the function form.Pass this argument when you want to read the JSONSchema from the HTML document, rather then the
schemaargument or by connecting to the backend module.Example
The following JSON schema can be used by passing
schemaElement="function-schema":<script id="function-schema" type="application/json"> { "description": "Get the version of the backend module.", "properties": { "func_name": { "const": "version_info", "description": "The name of the function. Must be 'version_info'", "title": "Func Name" } }, "required": [ "func_name" ], "title": "FuncVersionInfo", "type": "object" } </script>
- FunctionContainerOptions.uiSchema?
type: UiSchema
JSONSchema for rendering the user interface
see https://rjsf-team.github.io/react-jsonschema-form/docs/api-reference/uiSchema for details