|
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_extension in item.output_extensions" |
| 21 | + v-for="(extension, output_extension) in output_extensions" |
20 | 22 | :key="output_extension" |
21 | 23 | cols="auto" |
22 | 24 | class="pa-0" |
23 | 25 | > |
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" |
29 | 30 | > |
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> |
34 | 49 | </v-col> |
35 | 50 | </v-row> |
36 | 51 | </v-card-text> |
|
39 | 54 | </template> |
40 | 55 |
|
41 | 56 | <script setup> |
| 57 | + import _ from "lodash" |
| 58 | + import schema from "@/assets/schemas/ExtensionSelector.json" |
| 59 | +
|
42 | 60 | const emit = defineEmits([ |
43 | 61 | "update_values", |
44 | 62 | "increment_step", |
|
47 | 65 |
|
48 | 66 | const props = defineProps({ |
49 | 67 | input_geode_object: { type: String, required: true }, |
50 | | - schema: { type: Object, required: true }, |
| 68 | + filenames: { type: Array, required: true }, |
51 | 69 | }) |
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({}) |
55 | 72 | const loading = ref(false) |
56 | 73 |
|
57 | 74 | const toggle_loading = useToggle(loading) |
58 | 75 |
|
59 | 76 | async function get_output_file_extensions() { |
60 | 77 | 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) |
71 | 120 | toggle_loading() |
72 | 121 | } |
73 | 122 |
|
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 != "") { |
76 | 125 | const keys_values_object = { |
77 | | - output_geode_object: geode_object, |
| 126 | + output_geode_object, |
78 | 127 | output_extension, |
79 | 128 | } |
80 | 129 | emit("update_values", keys_values_object) |
|
0 commit comments