mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-21 00:40:01 +02:00
frontend: upating general component (removing boolean and numbers)
This commit is contained in:
parent
b99f6365ac
commit
b8fffb5e8b
@ -2,6 +2,7 @@ import React, { useEffect, useRef } from 'react';
|
|||||||
|
|
||||||
interface ComponentProps {
|
interface ComponentProps {
|
||||||
name: string;
|
name: string;
|
||||||
|
parent_path: string;
|
||||||
value: any;
|
value: any;
|
||||||
readOnly: boolean;
|
readOnly: boolean;
|
||||||
type: string;
|
type: string;
|
||||||
@ -19,27 +20,13 @@ export const ComponentLabel = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const Component = React.memo(
|
export const Component = React.memo(
|
||||||
({ name, value, readOnly, type, docString }: ComponentProps) => {
|
({ name, parent_path, value, readOnly, type, docString }: ComponentProps) => {
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRef(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
renderCount.current++;
|
renderCount.current++;
|
||||||
});
|
});
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'int':
|
|
||||||
case 'float':
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<p>Render count: {renderCount.current}</p>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
name={name}
|
|
||||||
value={value}
|
|
||||||
readOnly={readOnly}
|
|
||||||
title={docString}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
case 'str':
|
case 'str':
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -50,19 +37,10 @@ export const Component = React.memo(
|
|||||||
value={value}
|
value={value}
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
title={docString}
|
title={docString}
|
||||||
|
id={parent_path}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
case 'bool':
|
|
||||||
return (
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
name={name}
|
|
||||||
checked={value}
|
|
||||||
disabled={readOnly}
|
|
||||||
title={docString}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
case 'method':
|
case 'method':
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user