Skip to content

Commit aab3af8

Browse files
authored
Merge pull request #99 from LCOGT/feature/tif-downloads
Feature/tif downloads
2 parents 6aa74c6 + 709eed2 commit aab3af8

File tree

2 files changed

+67
-11
lines changed

2 files changed

+67
-11
lines changed

src/components/Project/ImageAnalysis/ImageAnalyzer.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { useConfigurationStore } from '@/stores/configuration'
55
import ImageViewer from './ImageViewer.vue'
66
import LinePlot from './LinePlot.vue'
77
import FilterBadge from '@/components/Global/FilterBadge.vue'
8+
import ImageDownloadMenu from '@/components/Project/ImageAnalysis/ImageDownloadMenu.vue'
89
9-
// eslint-disable-next-line no-unused-vars
1010
const props = defineProps(['modelValue', 'image'])
1111
const emit = defineEmits(['update:modelValue'])
1212
const configStore = useConfigurationStore()
@@ -26,17 +26,17 @@ function closeDialog() {
2626
}
2727
2828
// This function runs when imageViewer emits an analysis-action event and should be extended to handle other analysis types
29-
function requestAnalysis(action, input){
29+
function requestAnalysis(action, input, action_callback=null){
3030
const url = configStore.datalabApiBaseUrl + 'analysis/' + action + '/'
3131
const body = {
3232
'basename': props.image.basename,
3333
...input
3434
}
35-
fetchApiCall({url: url, method: 'POST', body: body, successCallback: (response) => {handleAnalysisOutput(response, action)}})
35+
fetchApiCall({url: url, method: 'POST', body: body, successCallback: (response) => {handleAnalysisOutput(response, action, action_callback)}})
3636
}
3737
3838
// The successCallback function for the fetchApiCall in requestAnalysis new operations can be added here as an additional case
39-
function handleAnalysisOutput(response, action){
39+
function handleAnalysisOutput(response, action, action_callback){
4040
switch (action) {
4141
case 'line-profile':
4242
lineProfile.value = response.line_profile
@@ -47,6 +47,9 @@ function handleAnalysisOutput(response, action){
4747
case 'source-catalog':
4848
catalog.value = response
4949
break
50+
case 'get-tif':
51+
action_callback(response.tif_url, props.image.basename, 'TIF')
52+
break
5053
default:
5154
console.error('Invalid action:', action)
5255
break
@@ -65,13 +68,10 @@ function handleAnalysisOutput(response, action){
6568
density="comfortable"
6669
:title="image.target_name"
6770
>
68-
<a
69-
:href="image.url"
70-
:download="image.basename"
71-
target="_blank"
72-
>
73-
<v-icon icon="mdi-download" />
74-
</a>
71+
<image-download-menu
72+
:image="image"
73+
@analysis-action="requestAnalysis"
74+
/>
7575
<v-btn
7676
icon="mdi-close"
7777
@click="closeDialog()"
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<script setup>
2+
import { useAlertsStore } from '@/stores/alerts'
3+
4+
const props = defineProps(['image', 'tifUrl'])
5+
6+
defineEmits(['analysisAction'])
7+
8+
const alertStore = useAlertsStore()
9+
10+
function downloadLink(link, filename, fileType='file'){
11+
if(!link){
12+
alertStore.setAlert('error', `No ${fileType} available for download`)
13+
return
14+
}
15+
const a = document.createElement('a')
16+
a.href = link
17+
a.download = filename
18+
document.body.appendChild(a)
19+
a.click()
20+
document.body.removeChild(a)
21+
}
22+
23+
</script>
24+
<template>
25+
<v-speed-dial
26+
location="left center"
27+
transition="fade-transition"
28+
>
29+
<template #activator="{ props: activatorProps }">
30+
<v-btn
31+
v-bind="activatorProps"
32+
icon="mdi-download"
33+
/>
34+
</template>
35+
<v-btn
36+
key="1"
37+
text=".FITS"
38+
@click="downloadLink(props.image.url, props.image.basename, 'FITs')"
39+
/>
40+
<v-btn
41+
key="2"
42+
text=".TIF"
43+
@click="$emit('analysisAction', 'get-tif', {'basename': props.image.basename}, downloadLink)"
44+
/>
45+
<v-btn
46+
key="3"
47+
text=".JPG"
48+
@click="downloadLink(props.image.largeCachedUrl, props.image.basename, 'JPG')"
49+
/>
50+
</v-speed-dial>
51+
</template>
52+
<style scoped>
53+
.v-btn{
54+
background-color: var(--metal);
55+
}
56+
</style>

0 commit comments

Comments
 (0)