Skip to content

Commit

Permalink
add image thumbnails to inventory list
Browse files Browse the repository at this point in the history
  • Loading branch information
wbbaker committed Sep 10, 2024
1 parent f54c7eb commit d1d6426
Showing 1 changed file with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<template>
<VCard class="mb-4">
<ClientOnly>
<img
v-if="imageInfo"
:src="imageInfo.thumb"
alt="Collection thumbnail"
class="object-cover"
/>
<div v-if="errorMessage" class="text-red-500">
{{ errorMessage }}
</div>
</ClientOnly>
</VCard>
</template>

<script setup>
import { ref, watch } from 'vue'
import { useOtuPageRequest } from "@/modules/otus/helpers/useOtuPageRequest.js"
import TaxonWorks from "@/modules/otus/services/TaxonWorks.js"
const props = defineProps({
imageUrl: {
type: String,
required: true
}
})
// An image description from TaxonWorks, with thumbnail, various resolutions, etc.
const imageInfo = ref(null)
const isLoading = ref(false)
const errorMessage = ref(null)
watch(
() => props.imageUrl,
async () => {
isLoading.value = true
errorMessage.value = false
try {
const response = await useOtuPageRequest('component:thumbnail', () =>
TaxonWorks.getImageFromUrl(props.imageUrl)
)
imageInfo.value = response.data
}
catch (e) {
console.error(e)
errorMessage.value = `Error loading image: ${e}`
}
finally {
isLoading.value = false
}
},
{immediate: true}
)
</script>

0 comments on commit d1d6426

Please sign in to comment.