diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 3f71287..248d15c 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -188,8 +188,6 @@ const App = () => {
{ const { - name, - parentPath, + fullAccessPath, docString, value: runningTask, addNotification, @@ -34,7 +32,8 @@ export const AsyncMethodComponent = React.memo((props: AsyncMethodProps) => { const renderCount = useRef(0); const formRef = useRef(null); - const fullAccessPath = [parentPath, name].filter((element) => element).join('.'); + const name = fullAccessPath.split('.').at(-1); + const parentPath = fullAccessPath.slice(0, -(name.length + 1)); useEffect(() => { renderCount.current++; diff --git a/frontend/src/components/ButtonComponent.tsx b/frontend/src/components/ButtonComponent.tsx index 00624c7..a796b73 100644 --- a/frontend/src/components/ButtonComponent.tsx +++ b/frontend/src/components/ButtonComponent.tsx @@ -4,8 +4,7 @@ import { DocStringComponent } from './DocStringComponent'; import { LevelName } from './NotificationsComponent'; type ButtonComponentProps = { - name: string; - parentPath?: string; + fullAccessPath: string; value: boolean; readOnly: boolean; docString: string; @@ -24,6 +23,7 @@ type ButtonComponentProps = { export const ButtonComponent = React.memo((props: ButtonComponentProps) => { const { value, + fullAccessPath, readOnly, docString, addNotification, @@ -32,9 +32,6 @@ export const ButtonComponent = React.memo((props: ButtonComponentProps) => { id } = props; // const buttonName = props.mapping ? (value ? props.mapping[0] : props.mapping[1]) : name; - const fullAccessPath = [props.parentPath, props.name] - .filter((element) => element) - .join('.'); const renderCount = useRef(0); diff --git a/frontend/src/components/DataServiceComponent.tsx b/frontend/src/components/DataServiceComponent.tsx index fe2a45f..71bf357 100644 --- a/frontend/src/components/DataServiceComponent.tsx +++ b/frontend/src/components/DataServiceComponent.tsx @@ -6,9 +6,7 @@ import { SerializedValue, GenericComponent } from './GenericComponent'; import { LevelName } from './NotificationsComponent'; type DataServiceProps = { - name: string; props: DataServiceJSON; - parentPath?: string; isInstantUpdate: boolean; addNotification: (message: string, levelname?: LevelName) => void; displayName: string; @@ -18,17 +16,8 @@ type DataServiceProps = { export type DataServiceJSON = Record; export const DataServiceComponent = React.memo( - ({ - name, - props, - parentPath = undefined, - isInstantUpdate, - addNotification, - displayName, - id - }: DataServiceProps) => { + ({ props, isInstantUpdate, addNotification, displayName, id }: DataServiceProps) => { const [open, setOpen] = useState(true); - const fullAccessPath = [parentPath, name].filter((element) => element).join('.'); if (displayName !== '') { return ( @@ -43,8 +32,6 @@ export const DataServiceComponent = React.memo( @@ -61,8 +48,6 @@ export const DataServiceComponent = React.memo( diff --git a/frontend/src/components/DeviceConnection.tsx b/frontend/src/components/DeviceConnection.tsx index 3b8cf81..4797d2f 100644 --- a/frontend/src/components/DeviceConnection.tsx +++ b/frontend/src/components/DeviceConnection.tsx @@ -4,9 +4,8 @@ import { DataServiceComponent, DataServiceJSON } from './DataServiceComponent'; import { MethodComponent } from './MethodComponent'; type DeviceConnectionProps = { - name: string; + fullAccessPath: string; props: DataServiceJSON; - parentPath: string; isInstantUpdate: boolean; addNotification: (message: string, levelname?: LevelName) => void; displayName: string; @@ -15,9 +14,8 @@ type DeviceConnectionProps = { export const DeviceConnectionComponent = React.memo( ({ - name, + fullAccessPath, props, - parentPath, isInstantUpdate, addNotification, displayName, @@ -26,8 +24,6 @@ export const DeviceConnectionComponent = React.memo( const { connected, connect, ...updatedProps } = props; const connectedVal = connected.value; - const fullAccessPath = [parentPath, name].filter((element) => element).join('.'); - return (
{!connectedVal && ( @@ -36,8 +32,7 @@ export const DeviceConnectionComponent = React.memo( {displayName != '' ? displayName : 'Device'} is currently not available!
)} void; }; export const GenericComponent = React.memo( - ({ - attribute, - name, - parentPath, - isInstantUpdate, - addNotification - }: GenericComponentProps) => { - const fullAccessPath = [parentPath, name].filter((element) => element).join('.'); + ({ attribute, isInstantUpdate, addNotification }: GenericComponentProps) => { + const { full_access_path: fullAccessPath } = attribute; const id = getIdFromFullAccessPath(fullAccessPath); const webSettings = useContext(WebSettingsContext); - let displayName = name; + let displayName = fullAccessPath.split('.').at(-1); if (webSettings[fullAccessPath]) { if (webSettings[fullAccessPath].display === false) { @@ -83,8 +75,7 @@ export const GenericComponent = React.memo( if (attribute.type === 'bool') { return ( } + value={attribute.value as 'RUNNING' | null} addNotification={addNotification} displayName={displayName} id={id} @@ -190,11 +175,10 @@ export const GenericComponent = React.memo( } else if (attribute.type === 'str') { return ( ); } else { - return
{name}
; + return
{fullAccessPath}
; } } ); diff --git a/frontend/src/components/ImageComponent.tsx b/frontend/src/components/ImageComponent.tsx index c3f2d02..50d984f 100644 --- a/frontend/src/components/ImageComponent.tsx +++ b/frontend/src/components/ImageComponent.tsx @@ -5,8 +5,7 @@ import { ChevronDown, ChevronRight } from 'react-bootstrap-icons'; import { LevelName } from './NotificationsComponent'; type ImageComponentProps = { - name: string; - parentPath: string; + fullAccessPath: string; value: string; docString: string; format: string; @@ -16,13 +15,11 @@ type ImageComponentProps = { }; export const ImageComponent = React.memo((props: ImageComponentProps) => { - const { value, docString, format, addNotification, displayName, id } = props; + const { fullAccessPath, value, docString, format, addNotification, displayName, id } = + props; const renderCount = useRef(0); const [open, setOpen] = useState(true); - const fullAccessPath = [props.parentPath, props.name] - .filter((element) => element) - .join('.'); useEffect(() => { renderCount.current++; diff --git a/frontend/src/components/ListComponent.tsx b/frontend/src/components/ListComponent.tsx index b2516fb..155dc84 100644 --- a/frontend/src/components/ListComponent.tsx +++ b/frontend/src/components/ListComponent.tsx @@ -4,8 +4,6 @@ import { SerializedValue, GenericComponent } from './GenericComponent'; import { LevelName } from './NotificationsComponent'; type ListComponentProps = { - name: string; - parentPath?: string; value: SerializedValue[]; docString: string; isInstantUpdate: boolean; @@ -14,8 +12,7 @@ type ListComponentProps = { }; export const ListComponent = React.memo((props: ListComponentProps) => { - const { name, parentPath, value, docString, isInstantUpdate, addNotification, id } = - props; + const { value, docString, isInstantUpdate, addNotification, id } = props; const renderCount = useRef(0); @@ -34,8 +31,6 @@ export const ListComponent = React.memo((props: ListComponentProps) => { diff --git a/frontend/src/components/MethodComponent.tsx b/frontend/src/components/MethodComponent.tsx index 5ff062c..7ec31ec 100644 --- a/frontend/src/components/MethodComponent.tsx +++ b/frontend/src/components/MethodComponent.tsx @@ -5,8 +5,7 @@ import { DocStringComponent } from './DocStringComponent'; import { LevelName } from './NotificationsComponent'; type MethodProps = { - name: string; - parentPath: string; + fullAccessPath: string; docString?: string; addNotification: (message: string, levelname?: LevelName) => void; displayName: string; @@ -15,7 +14,7 @@ type MethodProps = { }; export const MethodComponent = React.memo((props: MethodProps) => { - const { name, parentPath, docString, addNotification, displayName, id } = props; + const { fullAccessPath, docString, addNotification, displayName, id } = props; // Conditional rendering based on the 'render' prop. if (!props.render) { @@ -24,7 +23,6 @@ export const MethodComponent = React.memo((props: MethodProps) => { const renderCount = useRef(0); const formRef = useRef(null); - const fullAccessPath = [parentPath, name].filter((element) => element).join('.'); const triggerNotification = () => { const message = `Method ${fullAccessPath} was triggered.`; diff --git a/frontend/src/components/NumberComponent.tsx b/frontend/src/components/NumberComponent.tsx index b434851..6763ae1 100644 --- a/frontend/src/components/NumberComponent.tsx +++ b/frontend/src/components/NumberComponent.tsx @@ -30,9 +30,8 @@ export type FloatObject = { export type NumberObject = IntObject | FloatObject | QuantityObject; type NumberComponentProps = { - name: string; type: 'float' | 'int'; - parentPath?: string; + fullAccessPath: string; value: number; readOnly: boolean; docString: string; @@ -161,7 +160,7 @@ const handleNumericKey = ( export const NumberComponent = React.memo((props: NumberComponentProps) => { const { - name, + fullAccessPath, value, readOnly, type, @@ -179,9 +178,7 @@ export const NumberComponent = React.memo((props: NumberComponentProps) => { // Create a state for the input string const [inputString, setInputString] = useState(value.toString()); const renderCount = useRef(0); - const fullAccessPath = [props.parentPath, props.name] - .filter((element) => element) - .join('.'); + const name = fullAccessPath.split('.').at(-1); const handleKeyDown = (event) => { const { key, target } = event; diff --git a/frontend/src/components/SliderComponent.tsx b/frontend/src/components/SliderComponent.tsx index dc63ecd..9296cfc 100644 --- a/frontend/src/components/SliderComponent.tsx +++ b/frontend/src/components/SliderComponent.tsx @@ -6,10 +6,9 @@ import { NumberComponent, NumberObject } from './NumberComponent'; import { LevelName } from './NotificationsComponent'; type SliderComponentProps = { - name: string; + fullAccessPath: string; min: NumberObject; max: NumberObject; - parentPath?: string; value: NumberObject; readOnly: boolean; docString: string; @@ -30,8 +29,7 @@ export const SliderComponent = React.memo((props: SliderComponentProps) => { const renderCount = useRef(0); const [open, setOpen] = useState(false); const { - name, - parentPath, + fullAccessPath, value, min, max, @@ -43,7 +41,6 @@ export const SliderComponent = React.memo((props: SliderComponentProps) => { displayName, id } = props; - const fullAccessPath = [parentPath, name].filter((element) => element).join('.'); useEffect(() => { renderCount.current++; @@ -133,8 +130,7 @@ export const SliderComponent = React.memo((props: SliderComponentProps) => { { const { - name, + fullAccessPath, readOnly, docString, isInstantUpdate, @@ -38,9 +37,6 @@ export const StringComponent = React.memo((props: StringComponentProps) => { const renderCount = useRef(0); const [inputString, setInputString] = useState(props.value); - const fullAccessPath = [props.parentPath, props.name] - .filter((element) => element) - .join('.'); useEffect(() => { renderCount.current++; @@ -86,7 +82,7 @@ export const StringComponent = React.memo((props: StringComponentProps) => {