Skip to content

Commit

Permalink
Merge pull request #233 from SpeciesFileGroup/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
jlpereira authored Sep 25, 2024
2 parents bf1d4c9 + d7488dc commit 3571b4e
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
79 changes: 79 additions & 0 deletions src/modules/otus/components/Panel/PanelKeys/PanelKeys.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<template>
<VCard v-if="count">
<VCardHeader>Keys ({{ count }})</VCardHeader>
<VCardContent>
<template
v-for="(group, key) in observationMatrices"
:key="key"
>
<div v-if="Object.keys(group).length">
<VTable>
<VTableHeader>
<VTableHeaderRow>
<VTableHeaderCell>
{{ key }}
</VTableHeaderCell>
</VTableHeaderRow>
</VTableHeader>
<VTableBody>
<VTableBodyRow v-for="(label, id) in group">
<VTableBodyCell>
<RouterLink
:to="{ name: 'interactive-keys-id', params: { id } }"
v-text="label"
/>
</VTableBodyCell>
</VTableBodyRow>
</VTableBody>
</VTable>
</div>
</template>
</VCardContent>
</VCard>
</template>

<script setup>
import TaxonWorks from '../../../services/TaxonWorks.js'
import { useOtuPageRequest } from '../../../helpers/useOtuPageRequest.js'
import { onMounted, onBeforeUnmount, ref, computed } from 'vue'
const props = defineProps({
otuId: {
type: Object
}
})
const controller = new AbortController()
const observationMatrices = ref({
to: {},
in: {}
})
const count = computed(
() =>
[]
.concat(...Object.values(observationMatrices.value))
.filter((item) => Object.keys(item).length).length
)
onMounted(() => {
const params = {
otu_id: props.otuId
}
useOtuPageRequest('panel keys', () =>
TaxonWorks.getKeys(props.otuId, { signal: controller.signal, params })
)
.then(({ data }) => {
observationMatrices.value = {
to: data.observation_matrices.scoped,
in: data.observation_matrices.in
}
})
.catch(() => {})
})
onBeforeUnmount(() => {
controller?.abort()
})
</script>
6 changes: 6 additions & 0 deletions src/modules/otus/components/Panel/PanelKeys/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import PanelKeys from './PanelKeys.vue'

export default {
id: 'panel:keys',
component: PanelKeys
}
1 change: 1 addition & 0 deletions src/modules/otus/constants/layouts/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const DEFAULT_OVERVIEW_LAYOUT = {
'panel:map',
'panel:descendants',
'panel:content',
'panel:keys',
'panel:statistics'
]
]
Expand Down
4 changes: 4 additions & 0 deletions src/modules/otus/services/TaxonWorks.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ export default class TaxonWorks {
static getCachedMap(id) {
return makeAPIRequest.get(`/cached_maps/${id}`)
}

static getKeys(otuId) {
return makeAPIRequest.get(`/otus/${otuId}/inventory/keys`)
}
}

0 comments on commit 3571b4e

Please sign in to comment.