Repository navigation
Expand file tree
/
Copy pathmain.js
More file actions
220 lines (186 loc) · 6.85 KB
/
Copy pathmain.js
File metadata and controls
220 lines (186 loc) · 6.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
// Text input elements
const project_name = document.getElementById("project-name");
const project_description = document.getElementById("project-description");
// ??????? To many variables check latter if there is a better way to do this
// Parent checkboxes
const cb_application = document.getElementById("application");
const cb_db = document.getElementById("db");
const cb_domain = document.getElementById("domain");
const cb_entity = document.getElementById("entity");
const cb_extension = document.getElementById("extension");
const cb_graph = document.getElementById("graph");
const cb_infrastructure = document.getElementById("infrastructure");
const cb_persistence = document.getElementById("persistence");
const cb_schema = document.getElementById("schema");
const cb_server = document.getElementById("server");
const cb_templates = document.getElementById("templates");
const cb_test = document.getElementById("test");
// Child checkboxes
const childs_application = document.getElementById("childs-application");
const childs_db = document.getElementById("childs-db");
const childs_domain = document.getElementById("childs-domain");
const childs_entity = document.getElementById("childs-entity");
const childs_extension = document.getElementById("childs-extension");
const childs_graph = document.getElementById("childs-graph");
const childs_infrastructure = document.getElementById("childs-infrastructure");
const childs_persistence = document.getElementById("childs-persistence");
const childs_schema = document.getElementById("childs-schema");
const childs_server = document.getElementById("childs-server");
const childs_templates = document.getElementById("childs-templates");
const childs_test = document.getElementById("childs-test");
const family = {
"application": [cb_application, childs_application],
"db": [cb_db, childs_db],
"domain": [cb_domain, childs_domain],
"entity": [cb_entity, childs_entity],
"extension": [cb_extension, childs_extension],
"graph": [cb_graph, childs_graph],
"infrastructure": [cb_infrastructure, childs_infrastructure],
"persistence": [cb_persistence, childs_persistence],
"schema": [cb_schema, childs_schema],
"server": [cb_server, childs_server],
"templates": [cb_templates, childs_templates],
"test": [cb_test, childs_test]
}
// Starting Page Logic
document.getElementById("start-button").onclick = () => {
const project_type = document.querySelector("#Project-Type-Selector").value;
document.querySelector(".starting-page").style.display = "none";
display_section(project_type);
}
function display_section(new_section) {
const section = document.querySelector(`.${new_section}`)
section.style.display = "block"
}
const checkStatus = ( id ) => {
if (family[id][0].checked !== true) {
family[id][1].style.display = 'none';
} else {
family[id][1].style.display = 'block';
}
}
// Project generation logic
const generate_project_button = document.getElementById("generate-project-button")
generate_project_button.onclick = () => {
const data_json = generate_json ()
const GEN_URL = "/genproject";
// this can let to errors and is provicional
const DOWNLOAD_URL = `/download/${project_name.value}`;
fetch(GEN_URL, {
method: "POST",
body: JSON.stringify(data_json)
})
.then(response => {
// here render the page preview
if (response.ok) {
console.log(response);
// estandarizar esto dentro de una funcion de
// forma que funcione para cualquier tipo de proyecto
document.querySelector(".DDD-Arch").style.display = "none"
display_section("download-preview");
document.getElementById("download-project-button").onclick = () => {
fetch(DOWNLOAD_URL)
.then(res => res.blob())
.then(res => {
// this needs refactoring and error cath
var url = window.URL.createObjectURL(res);
var a = document.createElement('a');
a.href = url;
a.download = "1";
document.body.appendChild(a);
a.click();
a.remove();
})
}
}
})
// aqui va un catch en caso de error despues se hace
.catch(error => console.log(error))
}
function generate_json() {
// idealmente limpiar los datos del usuario antes de hacer un request
const ProjectName = project_name.value;
// no se sacar esto pa otro archivo y modificarlo aca o en un utils.js pero seria lo ideal
return {
"ProjectName": `${ProjectName}`,
"Applications": {
"FileName": "miarchivo",
"RepositoryName": "miarchivo",
"DomainName": "miarchivo",
"ModelName": "miarchivo",
"FilterInputName": "miarchivo",
"InputName": "miarchivo",
"NodeConnectionName": "sas",
"SaveInputName": "sas",
"UpdateInputName": "sas",
"BlockName": "MiTest",
"Properties": [
{
"Name": "Perimeter",
"TypeName": "float64"
},
{
"Name": "Area",
"TypeName": "float64"
}
]
},
"Persistence": [
{
"Repository": "UserRepository",
"Entity": "User"
},
{
"Repository": "ProductRepository",
"Entity": "Product"
},
{
"Repository": "Product2Repository",
"Entity": "Product2"
}
],
"Infrastructures": null,
"Extension": null,
"Domains": {
"FileName": "miarchivo",
"BlockName": "MiTest",
"Properties": [
{
"Name": "Perimeter",
"TypeName": "float64"
},
{
"Name": "Area",
"TypeName": "float64"
}
]
},
"Tests": {
"BlockName": "MiTest",
"Properties": [
{
"Name": "Perimeter",
"TypeName": "float64"
},
{
"Name": "Area",
"TypeName": "float64"
}
]
},
"Graphs": {
"GraphFileName": "migraph",
"BlockName": "MiBloque",
"Properties": [
{
"Name": "Perimeter",
"TypeName": "float64"
},
{
"Name": "Area",
"TypeName": "float64"
}
]
}
}
}