|
1 | 1 | <template> |
2 | 2 | <FetchingData v-if="loading" /> |
3 | 3 | <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" |
6 | 8 | class="justify-left" |
7 | 9 | > |
8 | 10 | <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"> |
10 | 12 | <template v-slot:activator="{ props }"> |
11 | 13 | <v-card-title v-bind="props"> |
12 | | - {{ item.geode_object }} |
| 14 | + {{ output_geode_object }} |
13 | 15 | </v-card-title> |
14 | 16 | </template> |
15 | 17 | </v-tooltip> |
16 | 18 | <v-card-text> |
17 | 19 | <v-row> |
18 | 20 | <v-col |
19 | | - v-for="output in item.outputs" |
20 | | - :key="output.extension" |
| 21 | + v-for="(extension, output_extension) in output_extensions" |
| 22 | + :key="output_extension" |
21 | 23 | cols="auto" |
22 | 24 | class="pa-0" |
23 | 25 | > |
24 | 26 | <v-tooltip |
25 | | - :disabled="output.is_saveable" |
| 27 | + :disabled="extension.is_saveable" |
26 | 28 | text="Data not saveable with this file extension" |
27 | 29 | location="bottom" |
28 | 30 | > |
29 | 31 | <template v-slot:activator="{ props }"> |
30 | 32 | <span v-bind="props"> |
31 | 33 | <v-card |
32 | 34 | class="card ma-2" |
33 | | - :color="output.is_saveable ? 'primary' : 'grey'" |
| 35 | + :color="extension.is_saveable ? 'primary' : 'grey'" |
34 | 36 | hover |
35 | | - @click="set_variables(item.geode_object, output.extension)" |
36 | | - :disabled="!output.is_saveable" |
| 37 | + @click=" |
| 38 | + set_variables(output_geode_object, output_extension) |
| 39 | + " |
| 40 | + :disabled="!extension.is_saveable" |
37 | 41 | > |
38 | 42 | <v-card-title align="center"> |
39 | | - {{ output.extension }} |
| 43 | + {{ output_extension }} |
40 | 44 | </v-card-title> |
41 | 45 | </v-card> |
42 | 46 | </span> |
|
50 | 54 | </template> |
51 | 55 |
|
52 | 56 | <script setup> |
| 57 | + import _ from "lodash" |
53 | 58 | import schema from "@/assets/schemas/ExtensionSelector.json" |
54 | 59 |
|
55 | 60 | const emit = defineEmits([ |
|
60 | 65 |
|
61 | 66 | const props = defineProps({ |
62 | 67 | input_geode_object: { type: String, required: true }, |
| 68 | + filenames: { type: Array, required: true }, |
63 | 69 | }) |
64 | | - const { input_geode_object } = props |
65 | | -
|
66 | | - const geode_objects_and_output_extensions = ref([]) |
| 70 | + const { input_geode_object, filenames } = props |
| 71 | + const geode_objects_and_output_extensions = ref({}) |
67 | 72 | const loading = ref(false) |
68 | 73 |
|
69 | 74 | const toggle_loading = useToggle(loading) |
70 | 75 |
|
71 | 76 | async function get_output_file_extensions() { |
72 | 77 | toggle_loading() |
73 | | - const params = { input_geode_object } |
74 | | - await api_fetch( |
75 | | - { schema, params }, |
76 | | - { |
77 | | - response_function: (response) => { |
78 | | - geode_objects_and_output_extensions.value = |
79 | | - response._data.geode_objects_and_output_extensions |
80 | | - }, |
81 | | - }, |
82 | | - ) |
| 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) |
83 | 120 | toggle_loading() |
84 | 121 | } |
85 | 122 |
|
86 | | - function set_variables(geode_object, output_extension) { |
87 | | - if (geode_object != "" && output_extension != "") { |
| 123 | + function set_variables(output_geode_object, output_extension) { |
| 124 | + if (output_geode_object != "" && output_extension != "") { |
88 | 125 | const keys_values_object = { |
89 | | - output_geode_object: geode_object, |
| 126 | + output_geode_object, |
90 | 127 | output_extension, |
91 | 128 | } |
92 | 129 | emit("update_values", keys_values_object) |
|
0 commit comments