Skip to content

Commit

Permalink
add inventory/dwc.json API call
Browse files Browse the repository at this point in the history
  • Loading branch information
wbbaker committed Aug 2, 2024
1 parent b989bf2 commit ba7972d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<VCard>
<ClientOnly>
<VSpinner
v-if="isLoading"
v-if="isLoading.collectionObjects || isLoading.inventory"
logo-class="w-8 h-8"
legend=""
/>
Expand All @@ -12,7 +12,10 @@
<PanelDropdown panel-key="panel:collection-objects" />
</VCardHeader>
<VCardContent class="text-sm">
<p v-html="content"/>
<h3>Collection Objects</h3>
<p v-html="collectionObjects"/>
<h3>Inventory</h3>
<p v-html="inventory"/>
</VCardContent>
</VCard>
</template>
Expand All @@ -32,26 +35,51 @@ const props = defineProps({
}
})
const content = ref("Loading...")
const isLoading = ref(false)
const collectionObjects = ref("Loading...")
const inventory = ref("Loading...")
const isLoading = ref({collectionObjects: false, inventory: false})
watch(
() => props.otuId,
async () => {
if (!props.otuId) {
content.value = 'No OTU specified.'
collectionObjects.value = 'No OTU specified.'
inventory.value = 'No OTU specified.'
return
}
isLoading.value = true
isLoading.value = {...isLoading.value, collectionObjects: true}
useOtuPageRequest('panel:collection-objects', () =>
TaxonWorks.getCollectionObjects(props.otuId)
).then(({data}) => {
content.value = `Collection objects for ${props.otuId}: ${JSON.stringify(data)}`
collectionObjects.value = `Collection objects for ${props.otuId}: ${JSON.stringify(data)}`
console.log({data})
}).catch(
e => content.value = `Error: ${JSON.stringify(e)}`
).finally(() => isLoading.value = false)
e => collectionObjects.value = `Error: ${e}`
).finally(() => isLoading.value = {...isLoading.value, collectionObjects: false})
},
{immediate: true}
)
)
watch(
() => props.otuId,
async () => {
if (!props.otuId) {
inventory.value = 'No OTU specified.'
return
}
isLoading.value = {...isLoading.value, inventory: true}
useOtuPageRequest('panel:inventory', () =>
TaxonWorks.getInventory(props.otuId)
).then(({data}) => {
inventory.value = `Inventory for ${props.otuId}: ${JSON.stringify(data)}`
console.log({data})
}).catch(
e => inventory.value = `Error: ${e}`
).finally(() => isLoading.value = {...isLoading.value, inventory: false})
},
{immediate: true}
)
</script>
14 changes: 13 additions & 1 deletion src/modules/otus/services/TaxonWorks.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,19 @@ export default class TaxonWorks {
// 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)
// See taxonworks/lib/collection_object/filter.rb Queries:CollectionObject:Filter for full list of options
/*
@with_buffered_collecting_event = boolean_param(params, :with_buffered_collecting_event)
@with_buffered_determinations = boolean_param(params, :with_buffered_determinations)
@with_buffered_other_labels = boolean_param(params, :with_buffered_other_labels)
*/
return makeAPIRequest.get(`/collection_objects?otu_id[]=${otuId}&with_buffered_determination=true`, opt)
// return makeAPIRequest.get(`/collection_objects?otu_id[]=${otuId}&descendants=true`, opt)
// return makeAPIRequest.get(`/collection_objects?otu_id[]=${otuId}`, opt)
}

static getInventory(otuId, opt) {
return makeAPIRequest.get(`/otus/${otuId}/inventory/dwc.json`, opt)
}

static getCachedMap(id) {
Expand Down

0 comments on commit ba7972d

Please sign in to comment.