From 913c658b3c176a34329c6c69afb09f142e477b65 Mon Sep 17 00:00:00 2001 From: W Beecher Baker Date: Mon, 30 Sep 2024 15:55:51 -0400 Subject: [PATCH] use new images endpoint to complement Darwin Core info; render images using GalleryImage, for interactivity. --- .../Panel/PanelSpecimens/PanelSpecimens.vue | 46 +++++++++++++++---- .../Panel/PanelSpecimens/SpecimenSummary.vue | 18 ++++---- 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/src/modules/otus/components/Panel/PanelSpecimens/PanelSpecimens.vue b/src/modules/otus/components/Panel/PanelSpecimens/PanelSpecimens.vue index 30937a6..961515e 100644 --- a/src/modules/otus/components/Panel/PanelSpecimens/PanelSpecimens.vue +++ b/src/modules/otus/components/Panel/PanelSpecimens/PanelSpecimens.vue @@ -2,7 +2,7 @@ @@ -10,7 +10,8 @@

In the Collection - [{{ inventoryDWC.length }}] + + ({{ inventoryDWC.length }})

@@ -18,7 +19,11 @@

  • - +
@@ -41,7 +46,22 @@ const props = defineProps({ }) const inventoryDWC = ref("Loading...") -const isLoading = ref(false) +const inventoryGallery = ref(undefined) +const isLoading = ref({dwc: false, gallery: false}) +const page = ref(1) +const perPage = ref(5) +// TODO populate once the API has this info +const total = ref(20) + +const getSpecimenImages = (specimen) => { + return !inventoryGallery.value ? [] : inventoryGallery.value.filter( + // just the images for this specimen + i => i.dwc_occurrence_id === specimen.id + ).reduce( + // extract image records from the rest of the API response + (result, i) => [...result, ...i.images], [] + ) +} watch( () => props.otuId, @@ -51,16 +71,24 @@ watch( return } - isLoading.value = true + isLoading.value = {...isLoading.value, dwc: true} useOtuPageRequest('panel:specimens', () => - TaxonWorks.getOtuInventoryDarwinCore(props.otuId) + TaxonWorks.getDescendantsDarwinCore(props.otuId, {per: 5}) ).then(({data}) => { inventoryDWC.value = data }).catch( - e => inventoryDWC.value = `Error: ${e}` - ).finally(() => isLoading.value = false) + e => inventoryDWC.value = `Error loading Darwin Core: ${e}` + ).finally(() => isLoading.value = {...isLoading.value, dwc: false}) + + isLoading.value = {...isLoading.value, gallery: true} + useOtuPageRequest('panel:gallery', () => + TaxonWorks.getDescendantsImageGallery(props.otuId) + ).then(({data}) => { + inventoryGallery.value = data + }).catch( + e => console.error(`Error loading gallery: ${e}`) + ).finally(() => isLoading.value = {...isLoading.value, gallery: false}) }, {immediate: true} ) - diff --git a/src/modules/otus/components/Panel/PanelSpecimens/SpecimenSummary.vue b/src/modules/otus/components/Panel/PanelSpecimens/SpecimenSummary.vue index 5783ac5..0e33f78 100644 --- a/src/modules/otus/components/Panel/PanelSpecimens/SpecimenSummary.vue +++ b/src/modules/otus/components/Panel/PanelSpecimens/SpecimenSummary.vue @@ -9,17 +9,15 @@ For further reference see https://dwc.tdwg.org/terms/.
  • {{ describeSpecimen(specimen) }}
  • {{describeDetails(specimen).join(', ')}}
  • -
  • - -
  • +