From 57eb2907fe78e813048e59a880a0ff57c460b39c Mon Sep 17 00:00:00 2001 From: Remi PLANEL <rplanel@pasteur.fr> Date: Tue, 2 Apr 2024 13:59:15 +0200 Subject: [PATCH] use ms client --- components/ServerDbTable.vue | 22 ++++++++---- components/content/StructureDb.vue | 12 ------- components/content/SystemDb.vue | 56 +++++++++++++++++------------- 3 files changed, 47 insertions(+), 43 deletions(-) diff --git a/components/ServerDbTable.vue b/components/ServerDbTable.vue index 5fc47a9c..b34498f2 100644 --- a/components/ServerDbTable.vue +++ b/components/ServerDbTable.vue @@ -266,13 +266,23 @@ watch(search, () => { // }) async function downloadData() { - pendingDownloadData.value = true + try { - const { data } = await useAsyncMeiliSearch({ - index: props.autocompleteMeiliFacetsProps.db, - params: { ...toValue(notPaginatedParams), filter: toValue(computedFilter), sort: toValue(msSortBy) }, - query: toValue(search), - }) + pendingDownloadData.value = true + + const data = await client + .index(props.autocompleteMeiliFacetsProps.db) + .search( + toValue(search), + { + ...toValue(notPaginatedParams), filter: toValue(computedFilter), sort: toValue(msSortBy) + }) + + // const { data } = await useAsyncMeiliSearch({ + // index: props.autocompleteMeiliFacetsProps.db, + // params: { ...toValue(notPaginatedParams), filter: toValue(computedFilter), sort: toValue(msSortBy) }, + // query: toValue(search), + // }) useCsvDownload(data, props.columnsToDownload, props.title) } finally { diff --git a/components/content/StructureDb.vue b/components/content/StructureDb.vue index fbc5137e..8fcbd9d1 100644 --- a/components/content/StructureDb.vue +++ b/components/content/StructureDb.vue @@ -38,18 +38,6 @@ onMounted(async () => { }) -// onBeforeMount(async () => { -// const { data } = await useAsyncMeiliSearch({ -// index: toValue(dbName), query: "", params: { -// facets: ["*"], -// filter: [], -// page: 1, -// hitsPerPage: 25, -// } -// }) -// autocompleteMeiliFacetsProps.value.facetDistribution = toValue(data)?.facetDistribution - -// }) const autocompleteMeiliFacetsProps = ref<AutocompleteMeiliFacetProps>({ db: toValue(dbName), diff --git a/components/content/SystemDb.vue b/components/content/SystemDb.vue index 81f591a2..700214dc 100644 --- a/components/content/SystemDb.vue +++ b/components/content/SystemDb.vue @@ -5,31 +5,36 @@ const sortBy: Ref<SortItem[]> = ref([{ key: 'title', order: "asc" }]) const itemValue = ref("title"); const dbName = ref("systems") -onBeforeMount(async () => { - const { data } = await useAsyncMeiliSearch({ - index: toValue(dbName), query: "", params: { - facets: ["*"], - filter: [], - page: 1, - hitsPerPage: 25, - } - }) +const client = useMeiliSearchRef() - autocompleteMeiliFacetsProps.value.facetDistribution = toValue(data)?.facetDistribution -}) -onMounted(async () => { - const { data } = await useAsyncMeiliSearch({ - index: toValue(dbName), query: "", params: { - facets: ["*"], - filter: [], - page: 1, - hitsPerPage: 25, - } - }) +// onBeforeMount(async () => { +// const { data } = await useAsyncMeiliSearch({ +// index: toValue(dbName), query: "", params: { +// facets: ["*"], +// filter: [], +// page: 1, +// hitsPerPage: 25, +// } +// }) - autocompleteMeiliFacetsProps.value.facetDistribution = toValue(data)?.facetDistribution +// autocompleteMeiliFacetsProps.value.facetDistribution = toValue(data)?.facetDistribution +// }) +onMounted(async () => { + try { + const data = await client + .index(toValue(dbName)) + .search("", { + facets: ["*"], + filter: [], + page: 1, + hitsPerPage: 25, + }) + autocompleteMeiliFacetsProps.value.facetDistribution = data?.facetDistribution + } catch (error) { + throw createError("Unable to get list of systems") + } }) @@ -118,18 +123,19 @@ const columnsToDownload = ref(['title', 'doi', 'Sensor', 'Activator', 'Effector' <template #[`item.title`]="{ item }"> <v-chip color="info" link :to="`/defense-systems/${item.title.toLowerCase()}`">{{ - item.title - }}</v-chip> + item.title + }}</v-chip> </template> <template #[`item.doi`]="{ item }"> - <ArticleDoi v-if="item?.doi" :doi="item.doi" :abstract="item?.abstract" :divider="false" :enumerate="false" /> + <ArticleDoi v-if="item?.doi" :doi="item.doi" :abstract="item?.abstract" :divider="false" + :enumerate="false" /> </template> <template #[`item.PFAM`]="{ item }"> <pfam-chips v-if="item?.PFAM" :pfams="item.PFAM"></pfam-chips> </template> <template #[`item.contributors`]="{ item }"> - <CollapsibleChips v-if="item?.contributors" :items="item.contributors.map(it => ({ title: it }))"> + <CollapsibleChips v-if="item?.contributors" :items="item.contributors.map(it => ({ title: it })) "> </CollapsibleChips> </template> </ServerDbTable> -- GitLab