mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-12 15:57:12 +02:00
frontend: updating ButtonComponent id
This commit is contained in:
@ -17,7 +17,7 @@ export const ButtonComponent = React.memo((props: ButtonComponentProps) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
renderCount.current++;
|
renderCount.current++;
|
||||||
});
|
});
|
||||||
const { name, parent_path: fullname, value, readOnly, docString, mapping } = props;
|
const { name, parent_path, value, readOnly, docString, mapping } = props;
|
||||||
|
|
||||||
const buttonName = mapping ? (value ? mapping[0] : mapping[1]) : name;
|
const buttonName = mapping ? (value ? mapping[0] : mapping[1]) : name;
|
||||||
|
|
||||||
@ -26,20 +26,20 @@ export const ButtonComponent = React.memo((props: ButtonComponentProps) => {
|
|||||||
const setChecked = (checked: boolean) => {
|
const setChecked = (checked: boolean) => {
|
||||||
socket.emit('frontend_update', {
|
socket.emit('frontend_update', {
|
||||||
name: name,
|
name: name,
|
||||||
fullname: fullname,
|
parent_path: parent_path,
|
||||||
value: checked
|
value: checked
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={'component boolean'} id={fullname}>
|
<div className={'component boolean'} id={parent_path.concat('.' + name)}>
|
||||||
<p>Render count: {renderCount.current}</p>
|
<p>Render count: {renderCount.current}</p>
|
||||||
<ToggleButton
|
<ToggleButton
|
||||||
id="toggle-check"
|
id="toggle-check"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
variant={value ? 'success' : 'secondary'}
|
variant={value ? 'success' : 'secondary'}
|
||||||
checked={value}
|
checked={value}
|
||||||
value={fullname}
|
value={parent_path}
|
||||||
disabled={readOnly}
|
disabled={readOnly}
|
||||||
onChange={(e) => setChecked(e.currentTarget.checked)}>
|
onChange={(e) => setChecked(e.currentTarget.checked)}>
|
||||||
<p>{buttonName}</p>
|
<p>{buttonName}</p>
|
||||||
|
Reference in New Issue
Block a user