Skip to content

Commit 9be7a3e

Browse files
authored
feat(gsoc): implement Import export of project as .cv file (#171)
* feat(gsoc): fix tabbar issue, project loading, updating, circuit delete, circuit name change, circuit switching, etc issues Signed-off-by: Arnabdaz <[email protected]> * fix(netlify-build): add / to check netlify build fixes Signed-off-by: Arnabdaz <[email protected]> * feat(netlify): add _redirects to fix routing issues with netlify deployment Signed-off-by: Arnabdaz <[email protected]> * fix(netlify): update netlify.toml to get _redirects to correct directory after build Signed-off-by: Arnabdaz <[email protected]> * fix(netlify): move redirects to neltify.toml Signed-off-by: Arnabdaz <[email protected]> * feat(gsoc): update types for store and naming error fixes Signed-off-by: Arnabdaz <[email protected]> * fix(gsoc): quit saving on clicking cancle while entering new proejct name from simualtor Signed-off-by: Arnabdaz <[email protected]> * feat(gsoc): update prompt component structure to make it a common helper component Signed-off-by: Arnabdaz <[email protected]> * feat(gsoc): fix cancle on save unify circuit creation and deletion with seperate helper vue components and remove watch and setInterval to improve performance Signed-off-by: Arnabdaz <[email protected]> * feat(gsoc): add new project creation, project details update on create from simulator, confirm component to replace confirm() and alert() Signed-off-by: Arnabdaz <[email protected]> * update(gsoc): convert alert() and confirm() to use vue component Signed-off-by: Arnabdaz <[email protected]> * feat(gsoc): add import & export as .cv file with independent vue components Signed-off-by: Arnabdaz <[email protected]> * feat(gsoc): update updateProjectDetails.vue to show tags as chips while entering in the update project form Signed-off-by: Arnabdaz <[email protected]> * feat(gsoc): update setup fucntion and fix linting issues, remove setTimeout of 1 second for testing Signed-off-by: Arnabdaz <[email protected]> * fix(gsoc): recover project not saving to localStorage due to generateSaveData being async function Signed-off-by: Arnabdaz <[email protected]> * fix(lint): fix linting issues in save.js & remove var from setup.js for const Signed-off-by: Arnabdaz <[email protected]> * feat(jwt): add jwt in Authorization header Signed-off-by: Arnabdaz <[email protected]> * fix(linting): data.spec.js remove unused parameter "text" from line 26 Signed-off-by: Arnabdaz <[email protected]> * fix(lint): fix codeclimate linting issues Signed-off-by: Arnabdaz <[email protected]> * fix(lint): fix linting issues Signed-off-by: Arnabdaz <[email protected]> * chore(gsoc): removed saveAs.js and Open.js files after testing Signed-off-by: Arnabdaz <[email protected]> --------- Signed-off-by: Arnabdaz <[email protected]>
1 parent d8d05ee commit 9be7a3e

File tree

11 files changed

+414
-142
lines changed

11 files changed

+414
-142
lines changed

src/assets/constants/Navbar/NAVBAR_DATA.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,36 @@
3030
},
3131
{
3232
"id": "5",
33+
"item": "export_as_file",
34+
"itemid": "ExportProject",
35+
"attributes": []
36+
},
37+
{
38+
"id": "6",
39+
"item": "import_project",
40+
"itemid": "ImportProject",
41+
"attributes": []
42+
},
43+
{
44+
"id": "7",
3345
"item": "clear_project",
3446
"itemid": "clearProject",
3547
"attributes": []
3648
},
3749
{
38-
"id": "6",
50+
"id": "8",
3951
"item": "recover_project",
4052
"itemid": "recoverProject",
4153
"attributes": []
4254
},
4355
{
44-
"id": "7",
56+
"id": "9",
4557
"item": "preview_circuit",
4658
"itemid": "fullViewOption",
4759
"attributes": []
4860
},
4961
{
50-
"id": "8",
62+
"id": "10",
5163
"item": "view_previous_ui",
5264
"itemid": "",
5365
"attributes": [
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<template>
2+
<v-dialog
3+
v-model="SimulatorState.dialogBox.export_project_dialog"
4+
:persistent="true"
5+
>
6+
<v-card class="exportProjectCard">
7+
<v-card-text>
8+
<p>Export as file</p>
9+
<v-btn
10+
size="x-small"
11+
icon
12+
class="dialogClose"
13+
@click="
14+
SimulatorState.dialogBox.export_project_dialog = false
15+
"
16+
>
17+
<v-icon>mdi-close</v-icon>
18+
</v-btn>
19+
<div class="fileNameInput">
20+
<p>File name:</p>
21+
<input
22+
v-model="fileNameInput"
23+
id="fileNameInputField"
24+
class="inputField"
25+
type="text"
26+
placeholder="untitled"
27+
required
28+
/>
29+
<p>.cv</p>
30+
</div>
31+
</v-card-text>
32+
<v-card-actions>
33+
<v-btn class="messageBtn" @click="exportAsFile"> Save </v-btn>
34+
</v-card-actions>
35+
</v-card>
36+
</v-dialog>
37+
</template>
38+
39+
<script lang="ts">
40+
import { ref } from 'vue'
41+
import { useState } from '#/store/SimulatorStore/state'
42+
import { useProjectStore } from '#/store/projectStore'
43+
import { generateSaveData } from '#/simulator/src/data/save'
44+
import { download } from '#/simulator/src/utils'
45+
import { escapeHtml } from '#/simulator/src/utils'
46+
47+
export function ExportProject() {
48+
const SimulatorState = useState()
49+
SimulatorState.dialogBox.export_project_dialog = true
50+
setTimeout(() => {
51+
const fileNameInputField = document.getElementById(
52+
'fileNameInputField'
53+
) as HTMLInputElement
54+
fileNameInputField?.select()
55+
}, 100)
56+
}
57+
</script>
58+
59+
<script lang="ts" setup>
60+
const SimulatorState = useState()
61+
const projectStore = useProjectStore()
62+
63+
const fileNameInput = ref(
64+
projectStore.getProjectName +
65+
'__' +
66+
new Date().toLocaleString().replace(/[: \/,-]/g, '_')
67+
)
68+
69+
const exportAsFile = async () => {
70+
let fileName = escapeHtml(fileNameInput.value) || 'untitled'
71+
const circuitData = await generateSaveData(
72+
projectStore.getProjectName,
73+
false
74+
)
75+
fileName = `${fileName.replace(/[^a-z0-9]/gi, '_')}.cv`
76+
download(fileName, circuitData)
77+
SimulatorState.dialogBox.export_project_dialog = false
78+
}
79+
</script>
80+
81+
<style scoped>
82+
.exportProjectCard {
83+
height: auto;
84+
width: 30rem;
85+
justify-content: center;
86+
margin: auto;
87+
backdrop-filter: blur(5px);
88+
border-radius: 5px;
89+
border: 0.5px solid var(--br-primary) !important;
90+
background: var(--bg-primary-moz) !important;
91+
background-color: var(--bg-primary-chr) !important;
92+
color: white;
93+
}
94+
95+
/* media query for .messageBoxContent */
96+
@media screen and (max-width: 991px) {
97+
.exportProjectCard {
98+
width: 100%;
99+
}
100+
}
101+
.fileNameInput {
102+
display: flex;
103+
align-items: baseline;
104+
justify-content: center;
105+
gap: 1rem;
106+
}
107+
108+
.fileNameInput p {
109+
white-space: nowrap;
110+
}
111+
112+
.fileNameInput input {
113+
text-align: center;
114+
}
115+
</style>
116+
117+
<!-- For any bugs refer to SaveAs.js file in main repo -->

0 commit comments

Comments
 (0)