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 ad612c8 commit f54c7eb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
<ul v-else class="tree ml-2">
<li v-for="specimen in inventoryDWC" :key="specimen.id" class="mt-1">
<SpecimenSummary :specimen="specimen" :otu-id="otuId"/>
<div v-if="specimen.associatedMedia" class="ml-2 flex flex-row gap-4">
<ImageThumbnail
v-for="imageUrl in specimen.associatedMedia.split('|')"
:imageUrl="imageUrl.trim()"
/>
</div>
</li>
</ul>
</VCardContent>
Expand All @@ -31,6 +37,7 @@ import PanelDropdown from '../PanelDropdown.vue'
import { useOtuPageRequest } from "@/modules/otus/helpers/useOtuPageRequest.js"
import TaxonWorks from "@/modules/otus/services/TaxonWorks.js"
import SpecimenSummary from "@/modules/otus/components/Panel/PanelSpecimens/SpecimenSummary.vue"
import ImageThumbnail from "@/modules/otus/components/Panel/PanelSpecimens/ImageThumbnail.vue"
const props = defineProps({
otuId: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ function describeSpecimen(specimen) {
specimen.catalogNumber,
describeLocation(specimen),
specimen.year,
specimen.associatedMedia && 'photo',
// `length ${JSON.stringify(item).length}`,
].filter(Boolean).join("; ")
}
Expand Down
10 changes: 10 additions & 0 deletions src/modules/otus/services/TaxonWorks.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ export default class TaxonWorks {
return makeAPIRequest.get(`/otus/${otuId}/inventory/dwc.json`, opt)
}

/** Load image info (thumbnail, etc) from a URL such as one in a Darwin Core 'associatedMedia' field. */
static getImageFromUrl(url, opt) {
// sanity check that this is the kind of URL we're looking for
// if it isn't, the data is likely to not work downstream
if (!url.indexOf('/api/v1') < 0)
throw new Error('Unsupported URL. Must be a TaxonWorks v1 API URL (containing "/api/v1").')
const path = url.split('/api/v1')[1] // remove the base URL -- just keep the part after /api/v1
return makeAPIRequest.get(path, opt)
}

static getCachedMap(id) {
return makeAPIRequest.get(`/cached_maps/${id}`)
}
Expand Down

0 comments on commit f54c7eb

Please sign in to comment.