Skip to content

Commit

Permalink
Cleanup AASStore (eclipse-basyx#227)
Browse files Browse the repository at this point in the history
* Preserve query parameter for switching between AAS Viewer/Editor, Submodel Viewer, About page, ...
Fixes eclipse-basyx#166

* Using anchor tag `to` for declarative navigation

* Undo changes in AppNavigation/MainMenu

* Adds state for url query

* Adds route guard to preserver query parameter

* Implements fetchSme() and fetchAndDispatchSme() in SMRepositoryClient

* Usage of fetchAndDispathSme() in App.vue

* Usage of fetchAndDispatchSme() in route guard

* Adds env variable EDITOR_ID_PREFIX

* Fix type of <TextInput> for GlobalAssetId

* Extends generateIri()

* Adds tests for generateIri()

* Strip idShortPath of path URL query in case of switching to SubmodelViewer

* Updates router guard

* Updates IDUtils tests for generateIri()

* Udpates jsdoc of generateCustomId()

* Adds tests for generateCustomId()

* Get idPrefix from EnvStore --> pinia error

* Transfers IDUtils to composable

* Fixes usage of IDUtils composable in AAS.vue

* Avoids AASStore actions within Clients

* Removes updatedNode from AASStore

* Fix VTreeview
  • Loading branch information
seicke authored Jan 9, 2025
1 parent e616421 commit b8ee347
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 21 deletions.
8 changes: 4 additions & 4 deletions aas-web-ui/src/components/AASTreeview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
const loading = computed(() => aasStore.getLoadingState); // gets loading State from Store
const aasRegistryServerURL = computed(() => navigationStore.getAASRegistryURL); // get AAS Registry URL from Store
const submodelRegistryURL = computed(() => navigationStore.getSubmodelRegistryURL); // get Submodel Registry URL from Store
const updatedNode = computed(() => aasStore.getUpdatedNode); // get the updated Treeview Node from Store
const selectedNode = computed(() => aasStore.getSelectedNode); // get the updated Treeview Node from Store
const initTree = computed(() => aasStore.getInitTreeByReferenceElement); // get the init treeview flag from Store
// Watchers
Expand All @@ -108,8 +108,8 @@
});
// change the submodelData Object when the updated Node changes
watch(updatedNode, () => {
updateNode(updatedNode.value);
watch(selectedNode, () => {
updateNode(selectedNode.value);
});
// initialize Treeview when the initTree flag changes
Expand Down Expand Up @@ -324,7 +324,7 @@
if (!foundNode) {
foundNode = true;
element.isActive = true;
aasStore.dispatchNode(element);
aasStore.dispatchSelectedNode(element);
aasStore.dispatchRealTimeObject(element);
}
// if prop showChildren exists, set it to true
Expand Down
4 changes: 2 additions & 2 deletions aas-web-ui/src/components/SubmodelList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
fetchedSubmodelData.forEach((submodel: any) => {
if (submodel.path === initialNode.value.path) {
submodel.isActive = true;
aasStore.dispatchNode(submodel);
aasStore.dispatchSelectedNode(submodel);
aasStore.dispatchRealTimeObject(submodel);
}
});
Expand Down Expand Up @@ -269,7 +269,7 @@
router.push({ query: query });
}
// dispatch the selected Node to the store
aasStore.dispatchNode(localSubmodel);
aasStore.dispatchSelectedNode(localSubmodel);
// add Submodel to the store (as RealTimeDataObject)
aasStore.dispatchRealTimeObject(localSubmodel);
}
Expand Down
3 changes: 2 additions & 1 deletion aas-web-ui/src/components/UIComponents/VTreeview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,15 @@
},
});
}
this.aasStore.dispatchSelectedNode(localItem);
} else {
// remove the path query from the Route entirely
let query = { ...this.route.query };
delete query.path;
this.router.push({ query: query });
this.aasStore.dispatchSelectedNode({});
}
// dispatch the selected Node to the store
this.aasStore.dispatchNode(localItem);
},
// Function to copy the path of the current Node to the Clipboard
Expand Down
2 changes: 1 addition & 1 deletion aas-web-ui/src/composables/SMEHandling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function useSMEHandling(): any {
sme.path = submodelElementPath;
sme.isActive = true;

aasStore.dispatchNode(sme);
aasStore.dispatchSelectedNode(sme);
}

return { fetchAndDispatchSme };
Expand Down
2 changes: 1 addition & 1 deletion aas-web-ui/src/composables/SMHandling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function useSMHandling(): any {
sm.path = smEndpoint;
sm.isActive = true;

aasStore.dispatchNode(sm);
aasStore.dispatchSelectedNode(sm);
}

return { fetchAndDispatchSm };
Expand Down
4 changes: 2 additions & 2 deletions aas-web-ui/src/mixins/SubmodelElementHandling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ export default defineComponent({
node.timestamp = this.formatDate(new Date()); // add timestamp to the SubmodelElement Data
node.path = smRepoUrl; // add the path to the SubmodelElement Data
node.isActive = true; // add the isActive Property to the SubmodelElement Data
this.aasStore.dispatchNode(node); // set the updatedNode in the AASStore
this.aasStore.dispatchSelectedNode(node); // set the updatedNode in the AASStore
this.aasStore.dispatchInitTreeByReferenceElement(true); // set the initTreeByReferenceElement in the AASStore to true to init + expand the Treeview on the referenced Element
} else {
// execute if the Request failed
Expand All @@ -826,7 +826,7 @@ export default defineComponent({
}); // Show Error Snackbar
return;
}
this.aasStore.dispatchNode({});
this.aasStore.dispatchSelectedNode({});
}
});
})
Expand Down
10 changes: 0 additions & 10 deletions aas-web-ui/src/store/AASDataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ export const useAASStore = defineStore({
state: () => ({
aasObject: {} as any, // holds the AAS object for the currently selected AAS
loadingState: false, // loading state of the AAS Treeview Component
updatedNode: {} as any, // holds the most recently updated Node in the AAS Treeview Component
selectedNode: {} as any, // holds the currently selected Node in the AAS Treeview Component
realTimeObject: {} as any, // holds the newest synced SubmodelElement (for the ComponentViasualization)
initTreeByReferenceElement: false, // holds the state if the AAS Treeview Component should be initialized because the Jump-Button was clicked on a ReferenceElement
}),
getters: {
getSelectedAAS: (state) => state.aasObject,
getLoadingState: (state) => state.loadingState,
getUpdatedNode: (state) => state.updatedNode,
getSelectedNode: (state) => state.selectedNode,
getRealTimeObject: (state) => state.realTimeObject,
getInitTreeByReferenceElement: (state) => state.initTreeByReferenceElement,
Expand All @@ -26,14 +24,6 @@ export const useAASStore = defineStore({
dispatchLoadingState(loadingState: boolean) {
this.loadingState = loadingState;
},
dispatchNode(node: any) {
this.updatedNode = node;
if (!node.isActive) {
this.selectedNode = {};
} else {
this.selectedNode = node;
}
},
dispatchSelectedNode(node: any) {
this.selectedNode = node;
},
Expand Down

0 comments on commit b8ee347

Please sign in to comment.