mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-19 16:10:01 +02:00
frontend will can now display any serialization dict
This commit is contained in:
parent
a2518671da
commit
7279fed2aa
@ -1,10 +1,6 @@
|
|||||||
import { useCallback, useEffect, useReducer, useState } from 'react';
|
import { useCallback, useEffect, useReducer, useState } from 'react';
|
||||||
import { Navbar, Form, Offcanvas, Container } from 'react-bootstrap';
|
import { Navbar, Form, Offcanvas, Container } from 'react-bootstrap';
|
||||||
import { hostname, port, socket } from './socket';
|
import { hostname, port, socket } from './socket';
|
||||||
import {
|
|
||||||
DataServiceComponent,
|
|
||||||
DataServiceJSON
|
|
||||||
} from './components/DataServiceComponent';
|
|
||||||
import './App.css';
|
import './App.css';
|
||||||
import {
|
import {
|
||||||
Notifications,
|
Notifications,
|
||||||
@ -14,6 +10,7 @@ import {
|
|||||||
import { ConnectionToast } from './components/ConnectionToast';
|
import { ConnectionToast } from './components/ConnectionToast';
|
||||||
import { SerializedValue, setNestedValueByPath, State } from './utils/stateUtils';
|
import { SerializedValue, setNestedValueByPath, State } from './utils/stateUtils';
|
||||||
import { WebSettingsContext, WebSetting } from './WebSettings';
|
import { WebSettingsContext, WebSetting } from './WebSettings';
|
||||||
|
import { Attribute, GenericComponent } from './components/GenericComponent';
|
||||||
|
|
||||||
type Action =
|
type Action =
|
||||||
| { type: 'SET_DATA'; data: State }
|
| { type: 'SET_DATA'; data: State }
|
||||||
@ -35,7 +32,10 @@ const reducer = (state: State, action: Action): State => {
|
|||||||
case 'SET_DATA':
|
case 'SET_DATA':
|
||||||
return action.data;
|
return action.data;
|
||||||
case 'UPDATE_ATTRIBUTE': {
|
case 'UPDATE_ATTRIBUTE': {
|
||||||
return setNestedValueByPath(state, action.fullAccessPath, action.newValue);
|
return {
|
||||||
|
...state,
|
||||||
|
value: setNestedValueByPath(state.value, action.fullAccessPath, action.newValue)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
throw new Error();
|
throw new Error();
|
||||||
@ -184,9 +184,10 @@ const App = () => {
|
|||||||
|
|
||||||
<div className="App navbarOffset">
|
<div className="App navbarOffset">
|
||||||
<WebSettingsContext.Provider value={webSettings}>
|
<WebSettingsContext.Provider value={webSettings}>
|
||||||
<DataServiceComponent
|
<GenericComponent
|
||||||
name={''}
|
name=""
|
||||||
props={state as DataServiceJSON}
|
parentPath=""
|
||||||
|
attribute={state as Attribute}
|
||||||
isInstantUpdate={isInstantUpdate}
|
isInstantUpdate={isInstantUpdate}
|
||||||
addNotification={addNotification}
|
addNotification={addNotification}
|
||||||
/>
|
/>
|
||||||
|
@ -6,7 +6,12 @@ export interface SerializedValue {
|
|||||||
async?: boolean;
|
async?: boolean;
|
||||||
parameters?: unknown;
|
parameters?: unknown;
|
||||||
}
|
}
|
||||||
export type State = Record<string, SerializedValue> | null;
|
export type State = {
|
||||||
|
type: string;
|
||||||
|
value: Record<string, SerializedValue> | null;
|
||||||
|
readonly: boolean;
|
||||||
|
doc: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
export function setNestedValueByPath(
|
export function setNestedValueByPath(
|
||||||
serializationDict: Record<string, SerializedValue>,
|
serializationDict: Record<string, SerializedValue>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user