Skip to content
Snippets Groups Projects
Verified Commit b2145246 authored by Philipp S. Sommer's avatar Philipp S. Sommer
Browse files

add member option to dasf-module

parent 883ffa4f
No related branches found
No related tags found
1 merge request!1Initial implementation
Pipeline #510196 passed
......@@ -47,7 +47,8 @@ SPDX-License-Identifier: Apache-2.0
<h2>Entire backend module</h2>
<dasf-module connection="getConnection"> </dasf-module>
<dasf-module connection="getConnection" member="version_info">
</dasf-module>
<script type="module" src="/src/main.tsx"></script>
</body>
......
......@@ -58,6 +58,7 @@ function ModuleContainer({
apiInfoElement,
apiInfo,
uiSchema,
member,
connection,
websocketUrl,
topic,
......@@ -80,7 +81,15 @@ function ModuleContainer({
topic,
});
if (typeof finalApiInfo === 'undefined') {
dasfConnection.getApiInfo().then(setFinalApiInfo);
dasfConnection.getApiInfo().then((apiInfo) => {
if (member) {
const names = apiInfo.functions
.map((info) => info.name)
.concat(apiInfo.classes.map((info) => info.name));
setSelectedCard(names.indexOf(member));
}
setFinalApiInfo(apiInfo);
});
}
return (
<>
......
......@@ -43,6 +43,7 @@ const WebModuleContainer = r2wc(ModuleContainer, {
props: {
apiInfoElement: 'string',
apiInfo: 'json',
member: 'string',
connection: 'function',
websocketUrl: 'string',
topic: 'string',
......
......@@ -105,6 +105,13 @@ export interface ModuleContainerOptions extends ConnectionOptions {
*/
uiSchema?: UiSchema;
/** 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.
*/
member?: string;
/** Response handler for requests from the backend module.
*
* This argument can be used to overwrite the default response handler (which
......
......@@ -29,7 +29,7 @@ describe('ModuleContainer', () => {
const container = render(
<ModuleContainer
connection={connection}
functionName="test_function"
member="test_function"
onResponse={handleResponse}
/>,
);
......
......@@ -10,8 +10,6 @@ from typing import Dict, Optional
from demessaging import configure, main, registry # noqa: F401
from deprogressapi import ProgressReport
# important: do not change the position of test_function here as the tests
# expect it to be at position 1!
__all__ = [
"version_info",
"test_function",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment