From 60a523a0abfec5f1f59b78629858a94dfb5a3a25 Mon Sep 17 00:00:00 2001 From: W Beecher Baker Date: Wed, 2 Oct 2024 13:03:04 -0400 Subject: [PATCH] paginate Darwin Core results --- .../Panel/PanelSpecimens/PanelSpecimens.vue | 40 +++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/modules/otus/components/Panel/PanelSpecimens/PanelSpecimens.vue b/src/modules/otus/components/Panel/PanelSpecimens/PanelSpecimens.vue index 961515e..2eaf3c1 100644 --- a/src/modules/otus/components/Panel/PanelSpecimens/PanelSpecimens.vue +++ b/src/modules/otus/components/Panel/PanelSpecimens/PanelSpecimens.vue @@ -10,8 +10,28 @@

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

@@ -36,7 +56,6 @@ 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: { @@ -49,9 +68,9 @@ const inventoryDWC = ref("Loading...") const inventoryGallery = ref(undefined) const isLoading = ref({dwc: false, gallery: false}) const page = ref(1) -const perPage = ref(5) +const perPage = ref(20) // TODO populate once the API has this info -const total = ref(20) +const total = ref("???") const getSpecimenImages = (specimen) => { return !inventoryGallery.value ? [] : inventoryGallery.value.filter( @@ -64,7 +83,7 @@ const getSpecimenImages = (specimen) => { } watch( - () => props.otuId, + () => [props.otuId , page.value], async () => { if (!props.otuId) { inventoryDWC.value = 'No OTU specified.' @@ -73,9 +92,16 @@ watch( isLoading.value = {...isLoading.value, dwc: true} useOtuPageRequest('panel:specimens', () => - TaxonWorks.getDescendantsDarwinCore(props.otuId, {per: 5}) + TaxonWorks.getDescendantsDarwinCore( + props.otuId, + {per: perPage.value, page: page.value}, + ) ).then(({data}) => { inventoryDWC.value = data + // if we've reached the end, so we know the total + if (Array.isArray(data) && data.length < perPage.value) { + total.value = (page.value - 1) * perPage.value + data.length + } }).catch( e => inventoryDWC.value = `Error loading Darwin Core: ${e}` ).finally(() => isLoading.value = {...isLoading.value, dwc: false})