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 (websocketUrl and topic) how to create one. And you can either provide the api info for the module directly (via schema), or pass the id of an HTML script element that holds the info (via schemaElement). 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 ModuleContainerOptions for documentation

Returns:

Element

Options

interface ModuleContainerOptions

Options for the ModuleContainer component

See also ContainerBaseOptions for 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 ModuleApiInfo and pythons demessaging.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 schema argument or by connecting to the backend module. The content must be an encoded ModuleApiInfo

Example

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.