Skip to content

Commit

Permalink
fetch actual CollectionObjects from API
Browse files Browse the repository at this point in the history
  • Loading branch information
wbbaker committed Aug 2, 2024
1 parent b3875a0 commit b989bf2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<script setup>
import { ref, watch } from 'vue'
import PanelDropdown from '../PanelDropdown.vue'
import { useOtuPageRequest } from "@/modules/otus/helpers/useOtuPageRequest.js"
import TaxonWorks from "@/modules/otus/services/TaxonWorks.js"
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
Expand All @@ -42,9 +44,13 @@ watch(
}
isLoading.value = true
await sleep(2000)
content.value = `Collection objects content for ${props.otuId}.`
isLoading.value = false
useOtuPageRequest('panel:collection-objects', () =>
TaxonWorks.getCollectionObjects(props.otuId)
).then(({data}) => {
content.value = `Collection objects for ${props.otuId}: ${JSON.stringify(data)}`
}).catch(
e => content.value = `Error: ${JSON.stringify(e)}`
).finally(() => isLoading.value = false)
},
{immediate: true}
)
Expand Down
6 changes: 6 additions & 0 deletions src/modules/otus/services/TaxonWorks.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ export default class TaxonWorks {
return makeAPIRequest.get(`/otus/${otuId}/inventory/content`, opt)
}

// Note that this could support multiple OTUs.
// The API takes a comma-separated list of OTU IDs.
static getCollectionObjects(otuId, opt) {
return makeAPIRequest.get(`/collection_objects?otu_id[]=${otuId}`, opt)
}

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

0 comments on commit b989bf2

Please sign in to comment.