Skip to content

Commit c2573d9

Browse files
committed
Add tif download buttons
1 parent 4b6a9c2 commit c2573d9

4 files changed

Lines changed: 80 additions & 39 deletions

File tree

src/components/ImageDisplay/ImageNavigationToolbar.vue

Lines changed: 79 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="image-toolbar-wrapper">
3-
<b-field grouped>
3+
<b-field grouped style="margin-bottom: 0;">
44
<b-field>
55
<button title="open the JS9 analysis tools"
66
class="button is-small" @click="toggleJS9">JS9</button> </b-field>
@@ -27,37 +27,42 @@
2727
</b-field>
2828
</b-field>
2929

30-
<b-field >
31-
<p class="control">
32-
<a class="button has-text-white is-small"
33-
:disabled="!small_fits_exists"
34-
@click="download_current_fits('small')">
35-
<b-icon icon="download" size="is-small" />
36-
<span>small fits</span>
37-
</a>
38-
</p>
39-
<p class="control">
40-
<a class="button has-text-white is-small"
41-
:disabled="!large_fits_exists"
42-
@click="download_current_fits('large')">
43-
<b-icon icon="download" size="is-small" />
44-
<span>large fits</span>
45-
</a>
46-
</p>
47-
<p class="control">
48-
<a class="button has-text-white is-small"
49-
@click="download_jpg">
50-
<b-icon icon="download" size="is-small" />
51-
<span>jpg</span>
52-
</a>
53-
</p>
54-
<p class="control">
55-
<b-button :loading="zip_download_waiting" class="button has-text-white is-small" @click="download_fits_previous_24hrs">
56-
<b-icon icon="download" size="is-small" />
57-
<span>last 24hrs fits</span>
58-
</b-button>
59-
</p>
60-
</b-field>
30+
<b-dropdown aria-role="list" position="is-top-left" >
31+
<template #trigger="{ active }">
32+
<b-button
33+
:loading="download_waiting"
34+
type="is-small"
35+
:icon-right="active ? 'menu-up' : 'menu-down'" >
36+
<b-icon icon="download" size="is-small" />
37+
<span>download</span>
38+
</b-button>
39+
</template>
40+
41+
<b-dropdown-item aria-role="listitem" @click="download_current_fits('small')" :disabled="!small_fits_exists">
42+
small fits
43+
</b-dropdown-item>
44+
<b-dropdown-item aria-role="listitem" @click="download_current_fits('large')" :disabled="!large_fits_exists">
45+
large fits
46+
</b-dropdown-item>
47+
<b-dropdown-item aria-role="listitem" @click="download_tif('small', 'linear')" :disabled="!small_fits_exists">
48+
small tif (linear)
49+
</b-dropdown-item>
50+
<b-dropdown-item aria-role="listitem" @click="download_tif('large', 'linear')" :disabled="!large_fits_exists">
51+
large tif (linear)
52+
</b-dropdown-item>
53+
<b-dropdown-item aria-role="listitem" @click="download_tif('small', 'arcsinh')" :disabled="!small_fits_exists">
54+
small tif (arcsinh)
55+
</b-dropdown-item>
56+
<b-dropdown-item aria-role="listitem" @click="download_tif('large', 'arcsinh')" :disabled="!large_fits_exists">
57+
large tif (arcsinh)
58+
</b-dropdown-item>
59+
<b-dropdown-item aria-role="listitem" @click="download_jpg">
60+
jpg
61+
</b-dropdown-item>
62+
<b-dropdown-item aria-role="listitem" @click="download_fits_previous_24hrs">
63+
last 24hrs fits
64+
</b-dropdown-item>
65+
</b-dropdown>
6166
</div>
6267
</template>
6368

@@ -73,7 +78,7 @@ export default {
7378
data() {
7479
return {
7580
isDownloadModalActive: false,
76-
zip_download_waiting: false,
81+
download_waiting: false,
7782
}
7883
},
7984
@@ -86,7 +91,7 @@ export default {
8691
start_timestamp_s: Math.round(new Date().getTime() / 1000) - (24 * 3600),
8792
end_timestamp_s: Math.round(new Date().getTime() / 1000),
8893
}
89-
this.zip_download_waiting = true
94+
this.download_waiting = true
9095
axios.post(url, args)
9196
.then(response => {
9297
let download_url = response.data.message
@@ -120,13 +125,14 @@ export default {
120125
121126
122127
})
123-
.finally(r => {this.zip_download_waiting = false})
128+
.finally(r => {this.download_waiting = false})
124129
},
125130
/**
126131
* Allows users to download a fits file (from the current image displayed).
127132
*/
128133
async download_current_fits(size) {
129134
let fits_url = ""
135+
this.download_waiting = true
130136
131137
// First we need to get the url that points to the file we want to download
132138
// If the file is from an info image...
@@ -154,19 +160,52 @@ export default {
154160
fits_url = await this.$store.dispatch('images/get_fits_url', params)
155161
}
156162
163+
this.download_waiting = false
157164
// The following line downloads the file
158165
window.location.assign(fits_url)
159166
160167
},
161168
async download_fits_file(base_filename, data_type, reduction_level) {
169+
this.download_waiting = true
162170
const params = {
163171
base_filename: base_filename,
164172
data_type: data_type,
165173
reduction_level: reduction_level,
166174
}
167-
const fits_url = await this.$store.dispatch('images/get_fits_url', params)
175+
let fits_url = await this.$store.dispatch('images/get_fits_url', params)
176+
this.download_waiting = false
168177
window.location.assign(fits_url)
169178
},
179+
180+
async download_tif(size, stretch) {
181+
this.download_waiting = true
182+
const url = `${this.$store.state.dev.active_api}/download`
183+
let body = {}
184+
185+
if (size == "large") {
186+
body = {
187+
s3_directory: this.current_image.s3_directory,
188+
object_name: this.large_fits_filename,
189+
stretch: stretch,
190+
image_type: 'tif',
191+
}
192+
}
193+
else if (size == "small") {
194+
body = {
195+
s3_directory: this.current_image.s3_directory,
196+
object_name: this.small_fits_filename,
197+
stretch: stretch,
198+
image_type: 'tif',
199+
}
200+
}
201+
else {
202+
// handle error
203+
}
204+
let tif_url = await axios.post(url, body)
205+
console.log(tif_url.data)
206+
window.location.assign(tif_url.data)
207+
this.download_waiting = false
208+
},
170209
download_jpg() {
171210
window.location.assign(this.current_image.jpg_url)
172211
},
@@ -218,4 +257,8 @@ export default {
218257
justify-content: space-between;
219258
}
220259
260+
.image-toolbar-wrapper > * {
261+
margin-bottom: 0;
262+
}
263+
221264
</style>

src/components/sitepages/SiteData.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ $visible-content-height: calc(100vh - #{$top-bottom-height + #{(2 * $site-data-w
738738
grid-area: image;
739739
width: 100%;
740740
display: grid;
741-
grid-template-rows: $infobar-height auto auto 80px 1fr;
741+
grid-template-rows: $infobar-height auto auto auto 1fr;
742742
grid-template-columns: auto;
743743
overflow: hidden;
744744

src/datastreamer/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const datastreamer = {
1313
websocket = new ReconnectingWebSocket(datastreamurl)
1414
websocket.onmessage = msg => {
1515
let payload = JSON.parse(msg.data)
16-
console.log(payload.topic)
1716

1817
if (payload.topic == "sitestatus") {
1918
topic_handlers.status_stream_handler(payload.data)

src/datastreamer/topic_handlers.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const status_stream_handler = message => {
55
let statusType = message.statusType
66
let status = message.status
77
let now = Date.now()
8-
console.log(message)
98

109
if (statusType == 'device') {
1110
store.commit('sitestatus/latest_device_timestamp_ms', message.server_timestamp_ms)

0 commit comments

Comments
 (0)