mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-21 00:40:01 +02:00
adds WebSettings context
This commit is contained in:
parent
393bde3280
commit
8940a61d4e
@ -13,6 +13,7 @@ import {
|
|||||||
} from './components/NotificationsComponent';
|
} from './components/NotificationsComponent';
|
||||||
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';
|
||||||
|
|
||||||
type Action =
|
type Action =
|
||||||
| { type: 'SET_DATA'; data: State }
|
| { type: 'SET_DATA'; data: State }
|
||||||
@ -42,6 +43,7 @@ const reducer = (state: State, action: Action): State => {
|
|||||||
};
|
};
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [state, dispatch] = useReducer(reducer, null);
|
const [state, dispatch] = useReducer(reducer, null);
|
||||||
|
const [webSettings, setWebSettings] = useState<Record<string, WebSetting>>({});
|
||||||
const [isInstantUpdate, setIsInstantUpdate] = useState(false);
|
const [isInstantUpdate, setIsInstantUpdate] = useState(false);
|
||||||
const [showSettings, setShowSettings] = useState(false);
|
const [showSettings, setShowSettings] = useState(false);
|
||||||
const [showNotification, setShowNotification] = useState(false);
|
const [showNotification, setShowNotification] = useState(false);
|
||||||
@ -68,10 +70,9 @@ const App = () => {
|
|||||||
fetch(`http://${hostname}:${port}/service-properties`)
|
fetch(`http://${hostname}:${port}/service-properties`)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data: State) => dispatch({ type: 'SET_DATA', data }));
|
.then((data: State) => dispatch({ type: 'SET_DATA', data }));
|
||||||
fetch(`http://${hostname}:${port}/web-settings`).then((response) =>
|
fetch(`http://${hostname}:${port}/web-settings`)
|
||||||
response.json()
|
.then((response) => response.json())
|
||||||
);
|
.then((data: Record<string, WebSetting>) => setWebSettings(data));
|
||||||
// .then((data: State) => dispatch({ type: 'SET_DATA', data }));
|
|
||||||
setConnectionStatus('connected');
|
setConnectionStatus('connected');
|
||||||
});
|
});
|
||||||
socket.on('disconnect', () => {
|
socket.on('disconnect', () => {
|
||||||
@ -182,12 +183,14 @@ const App = () => {
|
|||||||
</Offcanvas>
|
</Offcanvas>
|
||||||
|
|
||||||
<div className="App navbarOffset">
|
<div className="App navbarOffset">
|
||||||
<DataServiceComponent
|
<WebSettingsContext.Provider value={webSettings}>
|
||||||
name={''}
|
<DataServiceComponent
|
||||||
props={state as DataServiceJSON}
|
name={''}
|
||||||
isInstantUpdate={isInstantUpdate}
|
props={state as DataServiceJSON}
|
||||||
addNotification={addNotification}
|
isInstantUpdate={isInstantUpdate}
|
||||||
/>
|
addNotification={addNotification}
|
||||||
|
/>
|
||||||
|
</WebSettingsContext.Provider>
|
||||||
</div>
|
</div>
|
||||||
<ConnectionToast connectionStatus={connectionStatus} />
|
<ConnectionToast connectionStatus={connectionStatus} />
|
||||||
</>
|
</>
|
||||||
|
8
frontend/src/WebSettings.tsx
Normal file
8
frontend/src/WebSettings.tsx
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { createContext } from 'react';
|
||||||
|
|
||||||
|
export const WebSettingsContext = createContext({});
|
||||||
|
|
||||||
|
export type WebSetting = {
|
||||||
|
displayName: string;
|
||||||
|
index: number;
|
||||||
|
}[];
|
Loading…
x
Reference in New Issue
Block a user