Sfoglia il codice sorgente

search for root on file drop

Martin Kunz 1 anno fa
parent
commit
006de33a38
2 ha cambiato i file con 6 aggiunte e 3 eliminazioni
  1. 1 3
      src/components/TheModels.vue
  2. 5 0
      src/util/store.ts

+ 1 - 3
src/components/TheModels.vue

@@ -9,8 +9,6 @@ import VDialog from './VDialog.vue'
 const store = useStore()
 const newDialogOpen = ref(false);
 const newDialogDisabled = ref(false);
-
-
 const projectType = ref("ua");
 
 async function exportProject() {
@@ -56,7 +54,7 @@ async function handleDrop(e:DragEvent) {
     return;
   for(let file of e.dataTransfer.files) {
       let xmlString= await file.text();
-      store.addressSpace?.addNodeset(await UANodeSet.parse(xmlString, file.name));
+      store.addNodeset(await UANodeSet.parse(xmlString, file.name));
   }
 }
 </script>

+ 5 - 0
src/util/store.ts

@@ -1,5 +1,6 @@
 import { AddressSpace } from '@/ua/AddressSpace'
 import { UABaseNode } from '@/ua/UABaseNode'
+import type { UANodeSet } from '@/ua/UANodeSet'
 import { defineStore } from 'pinia'
 
 export const useStore = defineStore('user', {
@@ -15,6 +16,10 @@ export const useStore = defineStore('user', {
       this.addressSpace=as;
       this.rootNode=as.findNode("ns=0;i=84")||null;
       this.selectedNode=null;
+    },
+    addNodeset(nodeset: UANodeSet) {
+      this.addressSpace?.addNodeset(nodeset);
+      this.rootNode=this.addressSpace?.findNode("ns=0;i=84")||null;
     }
   }
 })