Skip to content

Commit

Permalink
Merge pull request #1 from Juraci/save-nodes
Browse files Browse the repository at this point in the history
Adds a simple download of node data
  • Loading branch information
Juraci authored Jul 12, 2024
2 parents fcd27bd + c260b77 commit 538a813
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/views/HomeIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import ConfirmDialog from 'primevue/confirmdialog';
import { useRouter, useRoute } from 'vue-router';
import { useNodeStore } from '@/stores/NodeStore';
import { useConfirm } from 'primevue/useconfirm';
import { storeToRefs } from 'pinia';
const router = useRouter();
const route = useRoute();
const isSidePanelVisible = ref(true);
const { addNode, deleteNode } = useNodeStore();
const confirm = useConfirm();
const { nodes } = storeToRefs(useNodeStore());
const handleAddNode = () => {
const uuid = addNode();
Expand Down Expand Up @@ -41,12 +43,27 @@ const gridTemplateColumns = computed(() => {
const handleNodeNotFound = () => {
router.push({ name: 'node.not-found' });
};
const downloadNodesLink = computed(() => {
const jsonNodes = JSON.stringify(nodes.value);
const blob = new Blob([jsonNodes], { type: 'application/json' });
return URL.createObjectURL(blob);
});
</script>

<template>
<div class="container" :style="{ 'grid-template-columns': gridTemplateColumns }">
<div v-show="isSidePanelVisible" class="side-panel">
<div class="side-panel-header">
<Button
icon="pi pi-save"
aria-label="Save"
severity="secondary"
as="a"
:href="downloadNodesLink"
:download="`solution-navigator-${new Date().toISOString()}.json`"
/>
<Button
data-test-create-node
icon="pi pi-pen-to-square"
Expand Down Expand Up @@ -83,6 +100,7 @@ const handleNodeNotFound = () => {
.side-panel-header {
display: flex;
justify-content: flex-end;
gap: 5px;
}
.side-panel-content {
display: flex;
Expand Down

0 comments on commit 538a813

Please sign in to comment.