Skip to content

Commit

Permalink
adding ability to import saved nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Juraci committed Jul 31, 2024
1 parent 3fe5a8d commit 96bc965
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/components/NodesArbor.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
<script setup>
import Card from 'primevue/card';
import ScrollPanel from 'primevue/scrollpanel';
import FileUpload from 'primevue/fileupload';
import { useNodeStore } from '@/stores/NodeStore';
import { storeToRefs } from 'pinia';
const store = useNodeStore();
const { nodesList } = storeToRefs(store);
const { nodesList, nodes, searchQuery } = storeToRefs(store);
const handleFileUpload = (input) => {
const reader = new FileReader();
reader.onload = (e) => {
try {
const json = JSON.parse(e.target.result);
nodes.value = json;
} catch (error) {
console.error('Error parsing JSON:', error);
}
};
reader.readAsText(input.files[0]);
};
</script>

<template>
Expand All @@ -30,6 +46,16 @@ const { nodesList } = storeToRefs(store);
</template>
</Card>
</router-link>
<FileUpload
v-show="searchQuery === ''"
mode="basic"
accept=".json"
:max-file-size="1000000"
:auto="true"
choose-label="Import existing nodes"
custom-upload
@uploader="handleFileUpload"
/>
</div>
</ScrollPanel>
</template>
Expand Down

0 comments on commit 96bc965

Please sign in to comment.