Skip to content

Commit

Permalink
Merge pull request #103 from SpeciesFileGroup/development
Browse files Browse the repository at this point in the history
Add spinners and cached map information
  • Loading branch information
José Luis Pereira authored and GitHub committed Jul 3, 2023
2 parents 379c719 + 2aa1f00 commit 339f248
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/components/VSkeleton.global.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<span
v-for="line in lines"
:key="line"
class="inline-block w-full rounded-sm bg-base-muted leading-5"
class="inline-block w-full rounded-sm bg-base-muted leading-5 animate-pulse"
>
&zwnj;
</span>
Expand Down
27 changes: 16 additions & 11 deletions src/components/VSpinner.global.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
:style="logoSize"
aria-hidden="true"
class="text-base-lighter animate-spin fill-primary-color"
:class="logoClass"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
Expand All @@ -29,7 +30,9 @@
<span class="sr-only">Loading...</span>

<div
class="text-base-content"
v-if="legend.length"
class="text-base-content text-center"
:class="legendClass"
:style="legendStyle"
>
<span
Expand Down Expand Up @@ -76,10 +79,12 @@ const props = defineProps({
legendStyle: {
type: Object,
default: () => ({
marginTop: '30px',
textAlign: 'center'
})
default: () => ({})
},
legendClass: {
type: String,
default: 'mt-5'
},
showLegend: {
Expand All @@ -99,10 +104,12 @@ const props = defineProps({
logoSize: {
type: Object,
default: () => ({
width: '50px',
height: '50px'
})
default: () => ({})
},
logoClass: {
type: String,
default: 'w-12 h-12'
}
})
Expand Down Expand Up @@ -201,8 +208,6 @@ const checkResize = () => {
svg {
display: block;
position: relative;
width: 30px;
height: 30px;
margin: 0px auto;
}
Expand Down
1 change: 1 addition & 0 deletions src/modules/otus/components/DWCDownload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<VButton
primary
class="text-sm flex items-center"
title="Download DwC Occurrences"
@click="
() => {
downloadCSV()
Expand Down
17 changes: 13 additions & 4 deletions src/modules/otus/components/Panel/PanelDescendants/Descendants.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<template>
<VCard>
<VSpinner
v-if="isLoading"
logo-class="w-8 h-8"
legend=""
/>
<VCardHeader class="flex justify-between">
<h2 class="text-md">Descendants and synonyms</h2>
<PanelDropdown panel-key="panel:descendants" />
Expand All @@ -23,10 +28,10 @@

<script setup>
import { ref, watch } from 'vue'
import { useOtuPageRequest } from '@/modules/otus/helpers/useOtuPageRequest'
import DescendantsTree from './DescendantsTree.vue'
import TaxonWorks from '../../../services/TaxonWorks'
import PanelDropdown from '../PanelDropdown.vue'
import { useOtuPageRequest } from '@/modules/otus/helpers/useOtuPageRequest'
const props = defineProps({
otuId: {
Expand All @@ -36,6 +41,7 @@ const props = defineProps({
})
const taxonomy = ref(null)
const isLoading = ref(false)
watch(
() => props.otuId,
Expand All @@ -44,11 +50,14 @@ watch(
return
}
isLoading.value = true
useOtuPageRequest('panel:descendants', () =>
TaxonWorks.getTaxonomy(props.otuId, { max_descendants_depth: 1 })
).then(({ data }) => {
taxonomy.value = data
})
)
.then(({ data }) => {
taxonomy.value = data
})
.finally(() => (isLoading.value = false))
},
{ immediate: true }
)
Expand Down
18 changes: 15 additions & 3 deletions src/modules/otus/components/Panel/PanelMap/CachedMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@close="() => (isModalVisible = false)"
>
<template #header>
<h3>Cached map</h3>
<h3 class="font-medium">Cached map</h3>
</template>
<div class="p-4 pt-0">
<VTable>
Expand All @@ -37,14 +37,18 @@
v-if="cachedMap.synced"
>
<IconCheck class="w-4 h-4" />
<span class="ml-1">Map is synchronized</span>
<span class="ml-1">
Map is synchronized with the latest changes *
</span>
</p>
<p
class="text-warning flex text-sm items-center"
v-else
>
<IconWarning class="w-4 h-4" />
<span class="ml-1">Map is not synchronized</span>
<span class="ml-1">
Map is not synchronized with the latest changes *
</span>
</p>
</VTableBodyCell>
</VTableBodyRow>
Expand Down Expand Up @@ -75,6 +79,14 @@
</VTableBodyRow>
</VTableBody>
</VTable>
<p class="italic text-xs pt-4">
* Aggregate maps are generated from georeference and asserted
distribution data. Map computation takes time, and as such they are
re-calculated periodically rather than when individual georeferences and
asserted distributions are created, destroyed, or updated. When a
warning notice is present then the map is not syncronized with the
latest changes to the underlying data.
</p>
</div>
</VModal>
</template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<template>
<VCard>
<VSpinner
v-if="store.catalog.isLoading"
logo-class="w-8 h-8"
legend=""
/>
<VCardHeader class="flex justify-between">
<h2 class="text-md">
Nomenclature ({{ store.catalog.timeline.length }})
Expand All @@ -9,7 +14,6 @@
panel-key="taxonomy"
/>
</VCardHeader>

<ul class="text-sm">
<CitationRow
v-for="citation in citationList.first"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<template>
<VCard>
<VSpinner
v-if="store.catalog.isLoading"
logo-class="w-8 h-8"
legend=""
/>
<VCardHeader class="flex justify-between">
<h2 class="text-md">
Nomenclature references ({{ store.catalog.sources.length }})
Expand Down
5 changes: 5 additions & 0 deletions src/modules/otus/components/Panel/PanelStats/PanelStats.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<template>
<VCard>
<VSpinner
v-if="store.catalog.isLoading"
logo-class="w-8 h-8"
legend=""
/>
<VCardHeader class="flex justify-between">
<h2 class="text-md">Stats</h2>
<PanelDropdown panel-key="taxonomy" />
Expand Down
1 change: 1 addition & 0 deletions src/modules/otus/components/SiteMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<VButton
primary
class="text-sm md:flex items-center gap-1 hidden"
title="Links used to obtain the information present on this page in JSON format."
@click="isModalVisible = true"
>
<IconJson class="w-4 h-4" />
Expand Down
5 changes: 4 additions & 1 deletion src/modules/otus/store/actions/loadCatalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useOtuPageRequest } from '../../helpers/useOtuPageRequest'

export const actionLoadCatalog = {
async loadCatalog(taxonId) {
this.catalog.isLoading = true

const response = await useOtuPageRequest('taxonomy', () =>
TaxonWorks.getTaxonNameCitations(taxonId)
)
Expand All @@ -11,7 +13,8 @@ export const actionLoadCatalog = {
...response.data,
sources: response.data.sources.map(({ cached, url }) =>
cached.replace(url, `<a href="${url}">${url}</a>`)
)
),
isLoading: false
}
}
}
3 changes: 2 additions & 1 deletion src/modules/otus/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export const useOtuStore = defineStore('otuStore', {
catalog: {
sources: [],
stats: {},
timeline: []
timeline: [],
isLoading: false
},
taxonomy: {
commonNames: [],
Expand Down

0 comments on commit 339f248

Please sign in to comment.