diff --git a/src/modules/otus/components/Panel/PanelCollectionObjects/PanelCollectionObjects.vue b/src/modules/otus/components/Panel/PanelCollectionObjects/PanelCollectionObjects.vue index b58000b..ce1f709 100644 --- a/src/modules/otus/components/Panel/PanelCollectionObjects/PanelCollectionObjects.vue +++ b/src/modules/otus/components/Panel/PanelCollectionObjects/PanelCollectionObjects.vue @@ -2,7 +2,7 @@ @@ -12,7 +12,10 @@ -

+

Collection Objects

+

+

Inventory

+

@@ -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} + ) + diff --git a/src/modules/otus/services/TaxonWorks.js b/src/modules/otus/services/TaxonWorks.js index 8b00aeb..88024fb 100644 --- a/src/modules/otus/services/TaxonWorks.js +++ b/src/modules/otus/services/TaxonWorks.js @@ -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) {