Skip to content

Commit 7d402fe

Browse files
Merge pull request #56 from Geode-solutions/next
2 parents b28ea13 + c7e759d commit 7d402fe

18 files changed

+354
-146
lines changed

components/CrsSelector.vue

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,19 @@
2424
</template>
2525

2626
<script setup>
27-
import { useToggle } from "@vueuse/core"
28-
29-
const stepper_tree = inject("stepper_tree")
30-
const { geode_object } = stepper_tree
27+
const emit = defineEmits([
28+
"update_values",
29+
"increment_step",
30+
"decrement_step",
31+
])
3132
3233
const props = defineProps({
33-
variable_to_update: { type: String, required: true },
34-
variable_to_increment: { type: String, required: true },
34+
input_geode_object: { type: String, required: true },
35+
key_to_update: { type: String, required: true },
3536
schema: { type: Object, required: true },
3637
})
3738
38-
const { variable_to_update, variable_to_increment, schema } = props
39+
const { input_geode_object, key_to_update, schema } = props
3940
4041
const search = ref("")
4142
const data_table_loading = ref(false)
@@ -45,14 +46,13 @@
4546
4647
watch(selected_crs, (new_value) => {
4748
const crs = get_selected_crs(new_value[0])
48-
set_crs(crs)
49+
const keys_values_object = {
50+
[key_to_update]: crs,
51+
}
52+
emit("update_values", keys_values_object)
53+
emit("increment_step")
4954
})
5055
51-
function set_crs(crs_value) {
52-
stepper_tree[variable_to_update] = crs_value
53-
stepper_tree[variable_to_increment]++
54-
}
55-
5656
function get_selected_crs(crs_code) {
5757
for (let i = 0; i <= crs_list.value.length; i++) {
5858
if (crs_list.value[i]["code"] == crs_code) {
@@ -62,7 +62,7 @@
6262
}
6363
6464
async function get_crs_table() {
65-
const params = { geode_object: geode_object }
65+
const params = { input_geode_object }
6666
toggle_loading()
6767
await api_fetch(
6868
{ schema, params },

components/Errors/Banner.vue

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,3 @@
5050
window.location.reload()
5151
}
5252
</script>
53-
54-
<style scoped>
55-
.v-btn {
56-
text-transform: unset !important;
57-
}
58-
</style>

components/ExtensionSelector.vue

Lines changed: 61 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,88 @@
11
<template>
2-
<v-row class="justify-left">
3-
<v-col
4-
v-for="file_extension in file_extensions"
5-
:key="file_extension"
6-
cols="2"
7-
>
8-
<v-card
9-
class="card ma-2"
10-
hover
11-
elevation="5"
12-
@click="set_output_extension(file_extension)"
13-
>
14-
<v-card-title align="center">
15-
{{ file_extension }}
16-
</v-card-title>
17-
</v-card>
18-
</v-col>
2+
<FetchingData v-if="loading" />
3+
<v-row
4+
v-for="item in geode_objects_and_output_extensions"
5+
:key="item.geode_object"
6+
class="justify-left"
7+
>
8+
<v-card class="card ma-2 pa-2" width="100%">
9+
<v-tooltip :text="`Export as a ${item.geode_object}`" location="bottom">
10+
<template v-slot:activator="{ props }">
11+
<v-card-title v-bind="props">
12+
{{ item.geode_object }}
13+
</v-card-title>
14+
</template>
15+
</v-tooltip>
16+
<v-card-text>
17+
<v-row>
18+
<v-col
19+
v-for="output_extension in item.output_extensions"
20+
:key="output_extension"
21+
cols="auto"
22+
class="pa-0"
23+
>
24+
<v-card
25+
class="card ma-2"
26+
color="primary"
27+
hover
28+
@click="set_variables(item.geode_object, output_extension)"
29+
>
30+
<v-card-title align="center">
31+
{{ output_extension }}
32+
</v-card-title>
33+
</v-card>
34+
</v-col>
35+
</v-row>
36+
</v-card-text>
37+
</v-card>
1938
</v-row>
2039
</template>
2140

2241
<script setup>
23-
const stepper_tree = inject("stepper_tree")
24-
const { geode_object } = stepper_tree
42+
const emit = defineEmits([
43+
"update_values",
44+
"increment_step",
45+
"decrement_step",
46+
])
2547
2648
const props = defineProps({
27-
variable_to_update: { type: String, required: true },
28-
variable_to_increment: { type: String, required: true },
49+
input_geode_object: { type: String, required: true },
2950
schema: { type: Object, required: true },
3051
})
31-
const { variable_to_update, variable_to_increment, schema } = props
52+
const { input_geode_object, schema } = props
3253
33-
const file_extensions = ref([])
54+
const geode_objects_and_output_extensions = ref([])
55+
const loading = ref(false)
56+
57+
const toggle_loading = useToggle(loading)
3458
3559
async function get_output_file_extensions() {
36-
const params = { geode_object: geode_object }
60+
toggle_loading()
61+
const params = { input_geode_object }
3762
await api_fetch(
3863
{ schema, params },
3964
{
4065
response_function: (response) => {
41-
file_extensions.value = response._data.output_file_extensions
66+
geode_objects_and_output_extensions.value =
67+
response._data.geode_objects_and_output_extensions
4268
},
4369
},
4470
)
71+
toggle_loading()
4572
}
4673
47-
function set_output_extension(extension) {
48-
stepper_tree[variable_to_update] = extension
49-
stepper_tree[variable_to_increment]++
74+
function set_variables(geode_object, output_extension) {
75+
if (geode_object != "" && output_extension != "") {
76+
const keys_values_object = {
77+
output_geode_object: geode_object,
78+
output_extension,
79+
}
80+
emit("update_values", keys_values_object)
81+
emit("increment_step")
82+
}
5083
}
5184
5285
onMounted(() => {
5386
get_output_file_extensions()
5487
})
5588
</script>
56-
57-
<style scoped>
58-
.card {
59-
border-radius: 15px;
60-
}
61-
</style>

components/FetchingData.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<Transition name="slide-fade" class="pa-0">
3+
<v-row align="center" class="pa-0">
4+
<v-col cols="auto" class="pa-0">
5+
<v-progress-circular
6+
:size="22"
7+
:width="3"
8+
color="primary"
9+
indeterminate
10+
/>
11+
</v-col>
12+
<v-col cols="auto">
13+
<p>Fetching data...</p>
14+
</v-col>
15+
</v-row>
16+
</Transition>
17+
</template>

components/FileSelector.vue

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,56 @@
11
<template>
2-
<v-file-input
3-
v-model="files"
4-
:multiple="multiple"
5-
:label="label"
6-
:accept="accept"
7-
:rules="[(value) => !!value || 'The file is mandatory']"
8-
color="primary"
9-
chips
10-
counter
11-
show-size
12-
@click:clear="stepper_tree.files = []"
2+
<FetchingData v-if="loading" />
3+
<FileUploader
4+
v-else
5+
v-bind="{ multiple, accept, route }"
6+
@files_uploaded="files_uploaded_event"
137
/>
148
</template>
159

1610
<script setup>
17-
const stepper_tree = inject("stepper_tree")
11+
const emit = defineEmits([
12+
"update_values",
13+
"increment_step",
14+
"decrement_step",
15+
])
1816
1917
const props = defineProps({
2018
multiple: { type: Boolean, required: true },
21-
label: { type: String, required: true },
22-
variable_to_update: { type: String, required: true },
23-
variable_to_increment: { type: String, required: true },
19+
key: { type: String, required: false, default: "" },
20+
route: { type: String, required: false, default: "" },
2421
schema: { type: Object, required: true },
2522
})
26-
const { multiple, label, variable_to_update, variable_to_increment, schema } =
27-
props
23+
24+
const { multiple, key, route, schema } = props
2825
2926
const accept = ref("")
30-
const files = ref([])
27+
const loading = ref(false)
3128
32-
watch(files, (value) => {
33-
stepper_tree[variable_to_update] = value
34-
stepper_tree[variable_to_increment]++
35-
})
29+
const toggle_loading = useToggle(loading)
3630
37-
function fill_extensions(response) {
38-
const extensions = response._data.extensions
39-
.map((extension) => "." + extension)
40-
.join(",")
41-
accept.value = extensions
31+
function files_uploaded_event(value) {
32+
if (value.length) {
33+
emit("update_values", { files: value })
34+
emit("increment_step")
35+
}
4236
}
4337
4438
async function get_allowed_files() {
39+
toggle_loading()
40+
const params = { key }
4541
await api_fetch(
46-
{ schema },
42+
{ schema, params },
4743
{
4844
response_function: (response) => {
49-
fill_extensions(response)
45+
accept.value = response._data.extensions
46+
.map((extension) => "." + extension)
47+
.join(",")
5048
},
5149
},
5250
)
51+
toggle_loading()
5352
}
54-
55-
onMounted(async () => {
56-
await get_allowed_files()
53+
onMounted(() => {
54+
get_allowed_files()
5755
})
5856
</script>

components/FileUploader.vue

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<template>
2+
<v-row>
3+
<v-col class="pa-0">
4+
<v-file-input
5+
v-model="files"
6+
:multiple="multiple"
7+
:label="label"
8+
:accept="accept"
9+
:rules="[(value) => !!value || 'The file is mandatory']"
10+
color="primary"
11+
chips
12+
counter
13+
show-size
14+
@click:clear="clear()"
15+
/>
16+
</v-col>
17+
</v-row>
18+
<v-row>
19+
<v-col cols="auto">
20+
<v-btn
21+
@click="upload_files()"
22+
color="primary"
23+
:disabled="!files.length && !files_uploaded"
24+
:loading="loading"
25+
class="pa-2"
26+
>
27+
Upload file(s)</v-btn
28+
>
29+
</v-col>
30+
</v-row>
31+
</template>
32+
33+
<script setup>
34+
const emit = defineEmits(["files_uploaded", "decrement_step"])
35+
36+
const props = defineProps({
37+
multiple: { type: Boolean, required: true },
38+
accept: { type: String, required: true },
39+
route: { type: String, required: true },
40+
})
41+
const { multiple, accept, route } = toRefs(props)
42+
43+
const label = multiple ? "Please select file(s)" : "Please select a file"
44+
const files = ref([])
45+
const loading = ref(false)
46+
const files_uploaded = ref(false)
47+
48+
const toggle_loading = useToggle(loading)
49+
50+
async function upload_files() {
51+
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+
)
61+
toggle_loading()
62+
}
63+
64+
function clear() {
65+
files.value = []
66+
emit("files_uploaded", files.value)
67+
}
68+
69+
watch(files, () => {
70+
files_uploaded.value = false
71+
})
72+
</script>

components/Header.vue

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@
66
<v-col>
77
<v-row class="justify-center">
88
<v-col v-for="(card, i) in cards_list" :key="i" cols="11" md="5">
9-
<v-card
10-
class="card"
11-
hover
12-
elevation="5"
13-
:href="card.href"
14-
rounded
15-
target="_blank"
16-
>
9+
<v-card class="card" hover :href="card.href" rounded target="_blank">
1710
<v-card-title
1811
primary-title
1912
class="justify-center text-h6"

0 commit comments

Comments
 (0)