frontend: adding EnumComponent

This commit is contained in:
Mose Müller
2023-08-02 12:06:20 +02:00
parent bae1752e48
commit f30cd15d3f
2 changed files with 75 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import { ButtonComponent } from './components/ButtonComponent';
import { socket } from './socket';
import { NumberComponent } from './components/NumberComponent';
import { SliderComponent } from './components/SliderComponent';
import { EnumComponent } from './components/EnumComponent';
type AttributeType =
| 'str'
@ -11,7 +12,8 @@ type AttributeType =
| 'float'
| 'int'
| 'method'
| 'Subclass'
| 'DataService'
| 'Enum'
| 'NumberSlider';
type ValueType = boolean | string | number | object;
@ -22,6 +24,7 @@ interface Attribute {
doc?: string | null;
parameters?: Record<string, string>;
async?: boolean;
enum?: Record<string, string>;
}
type MyData = Record<string, Attribute>;
@ -168,6 +171,18 @@ const App = () => {
/>
</div>
);
} else if (value.type === 'Enum') {
return (
<div key={key}>
<EnumComponent
name={key}
parent_path="DataService"
docString={value.doc}
value={String(value.value)}
enumDict={value.enum}
/>
</div>
);
} else if (!value.async) {
return (
<div key={key}>