Skip to content

Commit

Permalink
Merge pull request #98 from LCOGT/feature/archive_thumbnails
Browse files Browse the repository at this point in the history
Add support for thumbnails in the archive
  • Loading branch information
jnation3406 authored Aug 28, 2024
2 parents aab3af8 + b91b363 commit 6544a7f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/Global/ImageGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ watch(() => props.images, () => {
props.images.forEach(image => {
if (image.basename && !(image.basename in imageDetails.value)) {
imageDetails.value[image.basename] = ref('')
const url = image.thumbnail_url || ''
const url = image.thumbnail_url || image.smallThumbUrl || ''
thumbnailsStore.cacheImage('small', configurationStore.archiveType, url, image.basename).then((cachedUrl) => {
imageDetails.value[image.basename] = cachedUrl
})
Expand Down
2 changes: 1 addition & 1 deletion src/components/Project/ImageCarousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const handleThumbnailClick = (item, index) => {
watch(currLargeImage, async (newValue) => {
if (newValue){
currLargeImage.value.largeCachedUrl = ref('')
thumbnailsStore.cacheImage('large', configurationStore.archiveType, '', newValue.basename).then((cachedUrl) => {
thumbnailsStore.cacheImage('large', configurationStore.archiveType, newValue.largeThumbUrl, newValue.basename).then((cachedUrl) => {
currLargeImage.value.largeCachedUrl = cachedUrl
})
}
Expand Down
13 changes: 12 additions & 1 deletion src/stores/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,24 @@ export const useSettingsStore = defineStore('settings', {
const timeStr = `start=${this.startDate.toISOString()}&end=${this.endDate.toISOString()}`
option = option ? `${option}&${timeStr}` : timeStr
option += '&proposal_id=' + proposal
option += '&include_thumbnails=true'
const imageUrl = option ? `${baseUrl}?${option}` : baseUrl
const responseData = await fetchApiCall({ url: imageUrl, method: 'GET' })
if (responseData && responseData.results) {
// Preload all the small thumbnails into the cache. The large thumbnails will be loaded on demand
responseData.results.forEach((frame) => {
frame.smallThumbUrl = ''
frame.largeThumbUrl = ''
for (const thumbnail of frame.thumbnails) {
if (thumbnail.size === 'small') {
frame.smallThumbUrl = thumbnail.url
}
else if (thumbnail.size === 'large') {
frame.largeThumbUrl = thumbnail.url
}
}
frame.smallCachedUrl = ref('')
thumbnailsStore.cacheImage('small', configurationStore.archiveType, '', frame.basename).then((cachedUrl) => {
thumbnailsStore.cacheImage('small', configurationStore.archiveType, frame.smallThumbUrl, frame.basename).then((cachedUrl) => {
frame.smallCachedUrl.value = cachedUrl
})
})
Expand Down

0 comments on commit 6544a7f

Please sign in to comment.