ClassContainer react component
Component
- ClassContainer.default(options)
A container to render a forms for a class in a DASF backend module
This react component can be used to render a single class and its methods 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 api info for the class 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
ClassContainerOptions.Example
<ClassContainer connection={connection} className="SomeClass" onResponse={(responseData) => {console.log(responseData)}} />
- Arguments:
options (ClassContainerOptions) – Options for the component, see
ClassContainerOptionsfor documentation
- Returns:
Element
Options
- interface ClassContainerOptions
Options for the
ClassContainercomponentSee also
ContainerBaseOptionsfor further options.exported from
resources.ClassContainerOptions- Extends:
ContainerBaseOptions
- ClassContainerOptions.apiInfo?
type: ClassApiInfo
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
ClassApiInfoand pythonsdemessaging.backend.class_.BackendClass.get_api_info().
- ClassContainerOptions.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 encodedClassApiInfoExample
The following JSON schema can be used by passing
apiInfoElement="class-info":<script id="class-info" type="application/json"> { "name": "SomeTestClass", "rpc_schema": { "description": "Some test class for DASF", "properties": { "a": { "description": "A number to work with", "title": "A", "type": "integer" }, "class_name": { "const": "SomeTestClass", "description": "The name of the function. Must be 'SomeTestClass'", "title": "Class Name" } }, "required": [ "a", "class_name" ], "title": "ClassSomeTestClass", "type": "object" }, "methods": [ { "name": "add", "rpc_schema": { "description": "Add another number to ``a``", "properties": { "func_name": { "const": "add", "description": "The name of the function. Must be 'add'", "title": "Func Name" }, "b": { "description": "The number to add to", "title": "B", "type": "integer" } }, "required": [ "func_name", "b" ], "title": "MethClassSomeTestClassAdd", "type": "object" }, "return_schema": { "default": null, "description": "Sum of ``a`` and ``b``", "title": "MethClassSomeTestClassAdd", "type": "integer" } } ] } </script>
- ClassContainerOptions.className?
type: string
The name of the class to render
This option can be used if no
apiInfoElementorapiInfois passed to the constructor. In this case, the api info is loaded from the backend module. IfclassNameis undefined, we will render the first class in the list.
- ClassContainerOptions.uiSchema?
type: UiSchema
JSONSchema for rendering the user interface
see https://rjsf-team.github.io/react-jsonschema-form/docs/api-reference/uiSchema for details