Skip to content

Commit acdb5f2

Browse files
Merge pull request #63 from Geode-solutions/next
Next
2 parents 7d402fe + 15d2217 commit acdb5f2

19 files changed

+5102
-3265
lines changed

assets/schemas/CrsSelector.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$id": "/tools/geographic_coordinate_systems",
3+
"type": "object",
4+
"method": "POST",
5+
"properties": {
6+
"input_geode_object": {
7+
"type": "string"
8+
}
9+
},
10+
"required": ["input_geode_object"],
11+
"additionalProperties": false
12+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$id": "/tools/geode_objects_and_output_extensions",
3+
"type": "object",
4+
"method": "POST",
5+
"properties": {
6+
"input_geode_object": {
7+
"type": "string"
8+
},
9+
"filename": {
10+
"type": "string"
11+
}
12+
},
13+
"required": ["input_geode_object", "filename"],
14+
"additionalProperties": false
15+
}

assets/schemas/FileSelector.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$id": "/tools/allowed_files",
3+
"type": "object",
4+
"method": "POST",
5+
"properties": {
6+
"key": {
7+
"type": ["string", "null"]
8+
}
9+
},
10+
"required": ["key"],
11+
"additionalProperties": false
12+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$id": "/tools/missing_files",
3+
"type": "object",
4+
"method": "POST",
5+
"properties": {
6+
"input_geode_object": {
7+
"type": "string"
8+
},
9+
"filename": {
10+
"type": "string"
11+
}
12+
},
13+
"required": ["input_geode_object", "filename"],
14+
"additionalProperties": false
15+
}

assets/schemas/ObjectSelector.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$id": "/tools/allowed_objects",
3+
"type": "object",
4+
"method": "POST",
5+
"properties": {
6+
"filename": {
7+
"type": "string"
8+
},
9+
"key": {
10+
"type": ["string", "null"]
11+
}
12+
},
13+
"required": ["filename", "key"],
14+
"additionalProperties": false
15+
}

components/CrsSelector.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
</template>
2525

2626
<script setup>
27+
import schema from "@/assets/schemas/CrsSelector.json"
2728
const emit = defineEmits([
2829
"update_values",
2930
"increment_step",
@@ -33,10 +34,9 @@
3334
const props = defineProps({
3435
input_geode_object: { type: String, required: true },
3536
key_to_update: { type: String, required: true },
36-
schema: { type: Object, required: true },
3737
})
3838
39-
const { input_geode_object, key_to_update, schema } = props
39+
const { input_geode_object, key_to_update } = props
4040
4141
const search = ref("")
4242
const data_table_loading = ref(false)

components/ExtensionSelector.vue

Lines changed: 80 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,51 @@
11
<template>
22
<FetchingData v-if="loading" />
33
<v-row
4-
v-for="item in geode_objects_and_output_extensions"
5-
:key="item.geode_object"
4+
v-for="(
5+
output_extensions, output_geode_object
6+
) in geode_objects_and_output_extensions"
7+
:key="output_geode_object"
68
class="justify-left"
79
>
810
<v-card class="card ma-2 pa-2" width="100%">
9-
<v-tooltip :text="`Export as a ${item.geode_object}`" location="bottom">
11+
<v-tooltip :text="`Export as a ${output_geode_object}`" location="bottom">
1012
<template v-slot:activator="{ props }">
1113
<v-card-title v-bind="props">
12-
{{ item.geode_object }}
14+
{{ output_geode_object }}
1315
</v-card-title>
1416
</template>
1517
</v-tooltip>
1618
<v-card-text>
1719
<v-row>
1820
<v-col
19-
v-for="output_extension in item.output_extensions"
21+
v-for="(extension, output_extension) in output_extensions"
2022
:key="output_extension"
2123
cols="auto"
2224
class="pa-0"
2325
>
24-
<v-card
25-
class="card ma-2"
26-
color="primary"
27-
hover
28-
@click="set_variables(item.geode_object, output_extension)"
26+
<v-tooltip
27+
:disabled="extension.is_saveable"
28+
text="Data not saveable with this file extension"
29+
location="bottom"
2930
>
30-
<v-card-title align="center">
31-
{{ output_extension }}
32-
</v-card-title>
33-
</v-card>
31+
<template v-slot:activator="{ props }">
32+
<span v-bind="props">
33+
<v-card
34+
class="card ma-2"
35+
:color="extension.is_saveable ? 'primary' : 'grey'"
36+
hover
37+
@click="
38+
set_variables(output_geode_object, output_extension)
39+
"
40+
:disabled="!extension.is_saveable"
41+
>
42+
<v-card-title align="center">
43+
{{ output_extension }}
44+
</v-card-title>
45+
</v-card>
46+
</span>
47+
</template>
48+
</v-tooltip>
3449
</v-col>
3550
</v-row>
3651
</v-card-text>
@@ -39,6 +54,9 @@
3954
</template>
4055

4156
<script setup>
57+
import _ from "lodash"
58+
import schema from "@/assets/schemas/ExtensionSelector.json"
59+
4260
const emit = defineEmits([
4361
"update_values",
4462
"increment_step",
@@ -47,34 +65,65 @@
4765
4866
const props = defineProps({
4967
input_geode_object: { type: String, required: true },
50-
schema: { type: Object, required: true },
68+
filenames: { type: Array, required: true },
5169
})
52-
const { input_geode_object, schema } = props
53-
54-
const geode_objects_and_output_extensions = ref([])
70+
const { input_geode_object, filenames } = props
71+
const geode_objects_and_output_extensions = ref({})
5572
const loading = ref(false)
5673
5774
const toggle_loading = useToggle(loading)
5875
5976
async function get_output_file_extensions() {
6077
toggle_loading()
61-
const params = { input_geode_object }
62-
await api_fetch(
63-
{ schema, params },
64-
{
65-
response_function: (response) => {
66-
geode_objects_and_output_extensions.value =
67-
response._data.geode_objects_and_output_extensions
68-
},
69-
},
70-
)
78+
geode_objects_and_output_extensions.vaue = {}
79+
var promise_array = []
80+
for (const filename of filenames) {
81+
const params = { input_geode_object, filename }
82+
const promise = new Promise((resolve, reject) => {
83+
api_fetch(
84+
{ schema, params },
85+
{
86+
request_error_function: () => {
87+
reject()
88+
},
89+
response_function: (response) => {
90+
const data = response._data.geode_objects_and_output_extensions
91+
if (_.isEmpty(geode_objects_and_output_extensions.value)) {
92+
geode_objects_and_output_extensions.value = data
93+
} else {
94+
for (const [geode_object, geode_object_value] of Object.entries(
95+
data,
96+
)) {
97+
for (const [
98+
output_extension,
99+
output_extension_value,
100+
] of Object.entries(geode_object_value)) {
101+
if (!output_extension_value["is_saveable"]) {
102+
geode_objects_and_output_extensions.value[geode_object][
103+
output_extension
104+
]["is_saveable"] = false
105+
}
106+
}
107+
}
108+
}
109+
resolve()
110+
},
111+
response_error_function: () => {
112+
reject()
113+
},
114+
},
115+
)
116+
})
117+
promise_array.push(promise)
118+
}
119+
await Promise.all(promise_array)
71120
toggle_loading()
72121
}
73122
74-
function set_variables(geode_object, output_extension) {
75-
if (geode_object != "" && output_extension != "") {
123+
function set_variables(output_geode_object, output_extension) {
124+
if (output_geode_object != "" && output_extension != "") {
76125
const keys_values_object = {
77-
output_geode_object: geode_object,
126+
output_geode_object,
78127
output_extension,
79128
}
80129
emit("update_values", keys_values_object)

components/FileSelector.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
</template>
99

1010
<script setup>
11+
import schema from "@/assets/schemas/FileSelector.json"
12+
1113
const emit = defineEmits([
1214
"update_values",
1315
"increment_step",
@@ -18,10 +20,9 @@
1820
multiple: { type: Boolean, required: true },
1921
key: { type: String, required: false, default: "" },
2022
route: { type: String, required: false, default: "" },
21-
schema: { type: Object, required: true },
2223
})
2324
24-
const { multiple, key, route, schema } = props
25+
const { multiple, key, route } = props
2526
2627
const accept = ref("")
2728
const loading = ref(false)

components/FileUploader.vue

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,29 @@
4949
5050
async function upload_files() {
5151
toggle_loading()
52-
await upload_file(
53-
{ route, files: multiple ? files.value : [files.value[0]] },
54-
{
55-
response_function: () => {
56-
files_uploaded.value = true
57-
emit("files_uploaded", files.value)
58-
},
59-
},
60-
)
52+
var promise_array = []
53+
for (const file of files.value) {
54+
const promise = new Promise((resolve, reject) => {
55+
upload_file(
56+
{ route, file },
57+
{
58+
request_error_function: () => {
59+
reject()
60+
},
61+
response_function: () => {
62+
resolve()
63+
},
64+
response_error_function: () => {
65+
reject()
66+
},
67+
},
68+
)
69+
})
70+
promise_array.push(promise)
71+
}
72+
await Promise.all(promise_array)
73+
files_uploaded.value = true
74+
emit("files_uploaded", files.value)
6175
toggle_loading()
6276
}
6377

0 commit comments

Comments
 (0)