ModuleContainer react component
Component
- ModuleContainer.default(options)
A container to render a form for an entire DASF backend module
This react component can be used to render an entire DASF backend module and its classes and functions. You can either provide the
connection, or the details (websocketUrlandtopic) how to create one. And you can either provide the api info for the module directly (viaschema), or pass the id of an HTMLscriptelement that holds the info (viaschemaElement). If none of this is specified, we will get the api info from the backend module and render the form upon response.For more information on the available options, see
ModuleContainerOptions.Example
<ModuleContainer connection={connection} onResponse={(responseData) => {console.log(responseData)}} />
- Arguments:
options (ModuleContainerOptions) – Options for the component, see
ModuleContainerOptionsfor documentation
- Returns:
Element
Options
- interface ModuleContainerOptions
Options for the
ModuleContainercomponentSee also
ContainerBaseOptionsfor further options.exported from
resources.ModuleContainerOptions- Extends:
ContainerBaseOptions
- ModuleContainerOptions.apiInfo?
type: ModuleApiInfo
The api to use to render the forms
Pass this argument when you want to prevent getting the api info from the backend module. Note that this argument is superseeded by apiInfoElement.
See also
ModuleApiInfoand pythonsdemessaging.backend.module.BackendModule.get_api_info().
- ModuleContainerOptions.apiInfoElement?
type: string
The id of a
<script>element with JSON-encoded API Info that is used to render the function forms.Pass this argument when you want to read the API info from the HTML document, rather then the
schemaargument or by connecting to the backend module. The content must be an encodedModuleApiInfoExample
The following JSON schema can be used by passing
apiInfoElement="module-info":<script id="module-info" type="application/json"> { "classes": [], "functions": [ { "name": "version_info", "rpc_schema": { "description": "Get the version of the test module.", "properties": { "func_name": { "const": "version_info", "description": "The name of the function. Must be 'version_info'", "title": "Func Name", "type": "string" } }, "required": [ "func_name" ], "title": "FuncVersionInfo", "type": "object" }, "return_schema": { "additionalProperties": { "type": "string" }, "default": null, "title": "FuncVersionInfo", "type": "object" } } ], "rpc_schema": { "$defs": { "FuncVersionInfo": { "description": "Get the version of extpar and extpar_client.", "properties": { "func_name": { "const": "version_info", "description": "The name of the function. Must be 'version_info'", "title": "Func Name", "type": "string" } }, "required": [ "func_name" ], "title": "FuncVersionInfo", "type": "object" } }, "$ref": "#/$defs/FuncVersionInfo", "description": "Backend module for test-backend.", "title": "mytesttopic" } } </script>
- ModuleContainerOptions.member?
type: string
The member in the DASF backend module to display
If this is set, we will display the given member on start. If this is not specified, we will render an overview.
- ModuleContainerOptions.uiSchema?
type: UiSchema
JSONSchema for rendering the user interface
see https://rjsf-team.github.io/react-jsonschema-form/docs/api-reference/uiSchema for details
- ModuleContainerOptions.updateUrl?
type: boolean
Update the URL when a function or class is expanded
This boolean triggers an update of the window history when a function or class is expanded. The name of the class/function is added to the URL in the browser. This is especially useful when you want to use this component in somewhat like a single-page web application without the necessity to create your own router.