diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index bfeabd1..13cfc91 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,10 +1,6 @@ import { useCallback, useEffect, useReducer, useState } from 'react'; import { Navbar, Form, Offcanvas, Container } from 'react-bootstrap'; import { hostname, port, socket } from './socket'; -import { - DataServiceComponent, - DataServiceJSON -} from './components/DataServiceComponent'; import './App.css'; import { Notifications, @@ -14,6 +10,7 @@ import { import { ConnectionToast } from './components/ConnectionToast'; import { SerializedValue, setNestedValueByPath, State } from './utils/stateUtils'; import { WebSettingsContext, WebSetting } from './WebSettings'; +import { Attribute, GenericComponent } from './components/GenericComponent'; type Action = | { type: 'SET_DATA'; data: State } @@ -35,7 +32,10 @@ const reducer = (state: State, action: Action): State => { case 'SET_DATA': return action.data; case 'UPDATE_ATTRIBUTE': { - return setNestedValueByPath(state, action.fullAccessPath, action.newValue); + return { + ...state, + value: setNestedValueByPath(state.value, action.fullAccessPath, action.newValue) + }; } default: throw new Error(); @@ -184,9 +184,10 @@ const App = () => {
- diff --git a/frontend/src/utils/stateUtils.ts b/frontend/src/utils/stateUtils.ts index 06e491d..474daea 100644 --- a/frontend/src/utils/stateUtils.ts +++ b/frontend/src/utils/stateUtils.ts @@ -6,7 +6,12 @@ export interface SerializedValue { async?: boolean; parameters?: unknown; } -export type State = Record | null; +export type State = { + type: string; + value: Record | null; + readonly: boolean; + doc: string | null; +}; export function setNestedValueByPath( serializationDict: Record, diff --git a/pyproject.toml b/pyproject.toml index b9a19d5..3498fac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pydase" -version = "0.5.2" +version = "0.6.0" description = "A flexible and robust Python library for creating, managing, and interacting with data services, with built-in support for web and RPC servers, and customizable features for diverse use cases." authors = ["Mose Mueller "] readme = "README.md" diff --git a/src/pydase/data_service/data_service.py b/src/pydase/data_service/data_service.py index e8183b8..8f1b092 100644 --- a/src/pydase/data_service/data_service.py +++ b/src/pydase/data_service/data_service.py @@ -196,7 +196,7 @@ class DataService(rpyc.Service, AbstractDataService): ) # Traverse the serialized representation and set the attributes of the class - serialized_class = self.serialize() + serialized_class = self.serialize()["value"] for path in generate_serialized_data_paths(json_dict): nested_json_dict = get_nested_dict_by_path(json_dict, path) value = nested_json_dict["value"] @@ -248,7 +248,7 @@ class DataService(rpyc.Service, AbstractDataService): Returns: dict: The serialized instance. """ - return Serializer.serialize_object(self)["value"] + return Serializer.serialize_object(self) def update_DataService_attribute( # noqa: N802 self, diff --git a/src/pydase/data_service/data_service_cache.py b/src/pydase/data_service/data_service_cache.py index c94f86c..d25f352 100644 --- a/src/pydase/data_service/data_service_cache.py +++ b/src/pydase/data_service/data_service_cache.py @@ -30,10 +30,10 @@ class DataServiceCache: self._cache = self.service.serialize() def update_cache(self, full_access_path: str, value: Any) -> None: - set_nested_value_by_path(self._cache, full_access_path, value) + set_nested_value_by_path(self._cache["value"], full_access_path, value) def get_value_dict_from_cache(self, full_access_path: str) -> dict[str, Any]: try: - return get_nested_dict_by_path(self._cache, full_access_path) + return get_nested_dict_by_path(self._cache["value"], full_access_path) except (SerializationPathError, SerializationValueError, KeyError): return {} diff --git a/src/pydase/data_service/state_manager.py b/src/pydase/data_service/state_manager.py index adc97c4..5ad2eac 100644 --- a/src/pydase/data_service/state_manager.py +++ b/src/pydase/data_service/state_manager.py @@ -126,7 +126,7 @@ class StateManager: if self.filename is not None: with open(self.filename, "w") as f: - json.dump(self.cache, f, indent=4) + json.dump(self.cache["value"], f, indent=4) else: logger.info( "State manager was not initialised with a filename. Skipping " @@ -191,7 +191,7 @@ class StateManager: value: The new value to set for the attribute. """ - current_value_dict = get_nested_dict_by_path(self.cache, path) + current_value_dict = get_nested_dict_by_path(self.cache["value"], path) # This will also filter out methods as they are 'read-only' if current_value_dict["readonly"]: @@ -234,7 +234,7 @@ class StateManager: # Update path to reflect the attribute without list indices path = ".".join([*parent_path_list, attr_name]) - attr_cache_type = get_nested_dict_by_path(self.cache, path)["type"] + attr_cache_type = get_nested_dict_by_path(self.cache["value"], path)["type"] # Traverse the object according to the path parts target_obj = get_object_attr_from_path_list(self.service, parent_path_list) @@ -273,7 +273,7 @@ class StateManager: return has_decorator cached_serialization_dict = get_nested_dict_by_path( - self.cache, full_access_path + self.cache["value"], full_access_path ) if cached_serialization_dict["value"] == "method": diff --git a/src/pydase/frontend/asset-manifest.json b/src/pydase/frontend/asset-manifest.json index eb1450b..6f78e30 100644 --- a/src/pydase/frontend/asset-manifest.json +++ b/src/pydase/frontend/asset-manifest.json @@ -1,13 +1,13 @@ { "files": { "main.css": "/static/css/main.2d8458eb.css", - "main.js": "/static/js/main.dba067e7.js", + "main.js": "/static/js/main.1b1d7066.js", "index.html": "/index.html", "main.2d8458eb.css.map": "/static/css/main.2d8458eb.css.map", - "main.dba067e7.js.map": "/static/js/main.dba067e7.js.map" + "main.1b1d7066.js.map": "/static/js/main.1b1d7066.js.map" }, "entrypoints": [ "static/css/main.2d8458eb.css", - "static/js/main.dba067e7.js" + "static/js/main.1b1d7066.js" ] } \ No newline at end of file diff --git a/src/pydase/frontend/index.html b/src/pydase/frontend/index.html index e6a8b49..65e26a4 100644 --- a/src/pydase/frontend/index.html +++ b/src/pydase/frontend/index.html @@ -1 +1 @@ -pydase App
\ No newline at end of file +pydase App
\ No newline at end of file diff --git a/src/pydase/frontend/static/js/main.dba067e7.js b/src/pydase/frontend/static/js/main.1b1d7066.js similarity index 61% rename from src/pydase/frontend/static/js/main.dba067e7.js rename to src/pydase/frontend/static/js/main.1b1d7066.js index cbe0330..5691412 100644 --- a/src/pydase/frontend/static/js/main.dba067e7.js +++ b/src/pydase/frontend/static/js/main.1b1d7066.js @@ -1,3 +1,3 @@ -/*! For license information please see main.dba067e7.js.LICENSE.txt */ -(()=>{var e={694:(e,t)=>{var n;!function(){"use strict";var r={}.hasOwnProperty;function o(){for(var e=[],t=0;t{"use strict";e.exports=function(e,t,n,r,o,a,i,s){if(!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,o,a,i,s],u=0;(l=new Error(t.replace(/%s/g,(function(){return c[u++]})))).name="Invariant Violation"}throw l.framesToPop=1,l}}},888:(e,t,n)=>{"use strict";var r=n(47);function o(){}function a(){}a.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,a,i){if(i!==r){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:o};return n.PropTypes=n,n}},7:(e,t,n)=>{e.exports=n(888)()},47:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},463:(e,t,n)=>{"use strict";var r=n(791),o=n(296);function a(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n