mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-07 14:00:40 +02:00
updates frontend components to not have DataService in the fullAccessPath
This commit is contained in:
parent
32a1d14a40
commit
8e3a1694ce
@ -19,7 +19,8 @@ export const ButtonComponent = React.memo((props: ButtonComponentProps) => {
|
|||||||
const { name, parentPath, value, readOnly, docString, mapping, addNotification } =
|
const { name, parentPath, value, readOnly, docString, mapping, addNotification } =
|
||||||
props;
|
props;
|
||||||
const buttonName = mapping ? (value ? mapping[0] : mapping[1]) : name;
|
const buttonName = mapping ? (value ? mapping[0] : mapping[1]) : name;
|
||||||
const id = getIdFromFullAccessPath(parentPath.concat('.' + name));
|
const fullAccessPath = [parentPath, name].filter((element) => element).join('.');
|
||||||
|
const id = getIdFromFullAccessPath(fullAccessPath);
|
||||||
|
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRef(0);
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ export const ColouredEnumComponent = React.memo((props: ColouredEnumComponentPro
|
|||||||
addNotification
|
addNotification
|
||||||
} = props;
|
} = props;
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRef(0);
|
||||||
const id = getIdFromFullAccessPath(parentPath.concat('.' + name));
|
const fullAccessPath = [parentPath, name].filter((element) => element).join('.');
|
||||||
|
const id = getIdFromFullAccessPath(fullAccessPath);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
renderCount.current++;
|
renderCount.current++;
|
||||||
|
@ -20,14 +20,14 @@ export const DataServiceComponent = React.memo(
|
|||||||
({
|
({
|
||||||
name,
|
name,
|
||||||
props,
|
props,
|
||||||
parentPath = 'DataService',
|
parentPath = '',
|
||||||
isInstantUpdate,
|
isInstantUpdate,
|
||||||
addNotification
|
addNotification
|
||||||
}: DataServiceProps) => {
|
}: DataServiceProps) => {
|
||||||
const [open, setOpen] = useState(true);
|
const [open, setOpen] = useState(true);
|
||||||
let fullAccessPath = parentPath;
|
let fullAccessPath = parentPath;
|
||||||
if (name) {
|
if (name) {
|
||||||
fullAccessPath = parentPath.concat('.' + name);
|
fullAccessPath = [parentPath, name].filter((element) => element).join('.');
|
||||||
}
|
}
|
||||||
const id = getIdFromFullAccessPath(fullAccessPath);
|
const id = getIdFromFullAccessPath(fullAccessPath);
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import React, { useEffect, useRef } from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
import { InputGroup, Form, Row, Col } from 'react-bootstrap';
|
import { InputGroup, Form, Row, Col } from 'react-bootstrap';
|
||||||
import { setAttribute } from '../socket';
|
import { setAttribute } from '../socket';
|
||||||
|
import { getIdFromFullAccessPath } from '../utils/stringUtils';
|
||||||
import { DocStringComponent } from './DocStringComponent';
|
import { DocStringComponent } from './DocStringComponent';
|
||||||
import { LevelName } from './NotificationsComponent';
|
import { LevelName } from './NotificationsComponent';
|
||||||
|
|
||||||
@ -24,6 +25,8 @@ export const EnumComponent = React.memo((props: EnumComponentProps) => {
|
|||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRef(0);
|
||||||
|
const fullAccessPath = [parentPath, name].filter((element) => element).join('.');
|
||||||
|
const id = getIdFromFullAccessPath(fullAccessPath);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
renderCount.current++;
|
renderCount.current++;
|
||||||
@ -38,7 +41,7 @@ export const EnumComponent = React.memo((props: EnumComponentProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={'enumComponent'} id={parentPath.concat('.' + name)}>
|
<div className={'enumComponent'} id={id}>
|
||||||
{process.env.NODE_ENV === 'development' && (
|
{process.env.NODE_ENV === 'development' && (
|
||||||
<div>Render count: {renderCount.current}</div>
|
<div>Render count: {renderCount.current}</div>
|
||||||
)}
|
)}
|
||||||
|
@ -20,7 +20,8 @@ export const ImageComponent = React.memo((props: ImageComponentProps) => {
|
|||||||
|
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRef(0);
|
||||||
const [open, setOpen] = useState(true);
|
const [open, setOpen] = useState(true);
|
||||||
const id = getIdFromFullAccessPath(parentPath.concat('.' + name));
|
const fullAccessPath = [parentPath, name].filter((element) => element).join('.');
|
||||||
|
const id = getIdFromFullAccessPath(fullAccessPath);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
renderCount.current++;
|
renderCount.current++;
|
||||||
|
@ -18,7 +18,8 @@ export const ListComponent = React.memo((props: ListComponentProps) => {
|
|||||||
props;
|
props;
|
||||||
|
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRef(0);
|
||||||
const id = getIdFromFullAccessPath(parentPath.concat('.' + name));
|
const fullAccessPath = [parentPath, name].filter((element) => element).join('.');
|
||||||
|
const id = getIdFromFullAccessPath(fullAccessPath);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
renderCount.current++;
|
renderCount.current++;
|
||||||
|
@ -21,7 +21,8 @@ export const MethodComponent = React.memo((props: MethodProps) => {
|
|||||||
const [hideOutput, setHideOutput] = useState(false);
|
const [hideOutput, setHideOutput] = useState(false);
|
||||||
// Add a new state variable to hold the list of function calls
|
// Add a new state variable to hold the list of function calls
|
||||||
const [functionCalls, setFunctionCalls] = useState([]);
|
const [functionCalls, setFunctionCalls] = useState([]);
|
||||||
const id = getIdFromFullAccessPath(parentPath.concat('.' + name));
|
const fullAccessPath = [parentPath, name].filter((element) => element).join('.');
|
||||||
|
const id = getIdFromFullAccessPath(fullAccessPath);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
renderCount.current++;
|
renderCount.current++;
|
||||||
|
@ -146,7 +146,7 @@ export const NumberComponent = React.memo((props: NumberComponentProps) => {
|
|||||||
const [cursorPosition, setCursorPosition] = useState(null);
|
const [cursorPosition, setCursorPosition] = useState(null);
|
||||||
// Create a state for the input string
|
// Create a state for the input string
|
||||||
const [inputString, setInputString] = useState(props.value.toString());
|
const [inputString, setInputString] = useState(props.value.toString());
|
||||||
const fullAccessPath = parentPath.concat('.' + name);
|
const fullAccessPath = [parentPath, name].filter((element) => element).join('.');
|
||||||
const id = getIdFromFullAccessPath(fullAccessPath);
|
const id = getIdFromFullAccessPath(fullAccessPath);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -34,7 +34,7 @@ export const SliderComponent = React.memo((props: SliderComponentProps) => {
|
|||||||
isInstantUpdate,
|
isInstantUpdate,
|
||||||
addNotification
|
addNotification
|
||||||
} = props;
|
} = props;
|
||||||
const fullAccessPath = parentPath.concat('.' + name);
|
const fullAccessPath = [parentPath, name].filter((element) => element).join('.');
|
||||||
const id = getIdFromFullAccessPath(fullAccessPath);
|
const id = getIdFromFullAccessPath(fullAccessPath);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -24,7 +24,7 @@ export const StringComponent = React.memo((props: StringComponentProps) => {
|
|||||||
|
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRef(0);
|
||||||
const [inputString, setInputString] = useState(props.value);
|
const [inputString, setInputString] = useState(props.value);
|
||||||
const fullAccessPath = parentPath.concat('.' + name);
|
const fullAccessPath = [parentPath, name].filter((element) => element).join('.');
|
||||||
const id = getIdFromFullAccessPath(fullAccessPath);
|
const id = getIdFromFullAccessPath(fullAccessPath);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
export function getIdFromFullAccessPath(fullAccessPath: string) {
|
export function getIdFromFullAccessPath(fullAccessPath: string) {
|
||||||
// Replace '].' with a single dash
|
if (fullAccessPath) {
|
||||||
let id = fullAccessPath.replace(/\]\./g, '-');
|
// Replace '].' with a single dash
|
||||||
|
let id = fullAccessPath.replace(/\]\./g, '-');
|
||||||
|
|
||||||
// Replace any character that is not a word character or underscore with a dash
|
// Replace any character that is not a word character or underscore with a dash
|
||||||
id = id.replace(/[^\w_]+/g, '-');
|
id = id.replace(/[^\w_]+/g, '-');
|
||||||
|
|
||||||
// Remove any trailing dashes
|
// Remove any trailing dashes
|
||||||
id = id.replace(/-+$/, '');
|
id = id.replace(/-+$/, '');
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
|
} else {
|
||||||
|
return 'main';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user