From 5272dfab8129bfff05d8ecee4ddfa57c5fa8672a Mon Sep 17 00:00:00 2001 From: Vincent Rubinetti Date: Fri, 12 Jan 2024 14:00:20 -0500 Subject: [PATCH 1/7] add associations tsv download to frontend --- frontend/src/api/associations.ts | 2 ++ frontend/src/pages/node/AssociationsTable.vue | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/frontend/src/api/associations.ts b/frontend/src/api/associations.ts index dc2f814de..e6f1955f0 100644 --- a/frontend/src/api/associations.ts +++ b/frontend/src/api/associations.ts @@ -10,6 +10,7 @@ export const getAssociations = async ( limit = 10, search?: string, sort: Sort = null, + download?: "tsv" | "json", ) => { /** make query params */ const params = { @@ -19,6 +20,7 @@ export const getAssociations = async ( sort: sort ? `${sort.key} ${sort.direction === "up" ? "asc" : "desc"}` : null, + ...(download && { format: download }), }; /** make query */ diff --git a/frontend/src/pages/node/AssociationsTable.vue b/frontend/src/pages/node/AssociationsTable.vue index bc5df3448..2eb08339f 100644 --- a/frontend/src/pages/node/AssociationsTable.vue +++ b/frontend/src/pages/node/AssociationsTable.vue @@ -108,7 +108,6 @@ import type { Cols, Sort } from "@/components/AppTable.vue"; import { snackbar } from "@/components/TheSnackbar.vue"; import { getBreadcrumbs } from "@/pages/node/AssociationsSummary.vue"; import { useQuery } from "@/util/composables"; -import { downloadJson } from "@/util/download"; type Props = { /** current node */ @@ -276,8 +275,8 @@ const { /** download table data */ async function download() { - /** max rows to try to query */ - const max = 100; + /** max supported rows to query */ + const max = 500; const total = associations.value.total; /** warn user */ @@ -285,17 +284,19 @@ async function download() { `Downloading data for ${total > max ? "first " : ""}${Math.min( total, max, - )} table entries.` + (total >= 100 ? " This may take a minute." : ""), + )} table rows. This may take a minute.`, ); - /** attempt to request all rows */ - const response = await getAssociations( + /** download as many rows as possible */ + await getAssociations( props.node.id, props.category.id, 0, max, + search.value, + sort.value, + "tsv", ); - downloadJson(response, "associations"); } /** get associations when category or table state changes */ From 950c3acfcd7057921cf56a5cc163b41128d987a6 Mon Sep 17 00:00:00 2001 From: Vincent Rubinetti Date: Fri, 12 Jan 2024 14:04:35 -0500 Subject: [PATCH 2/7] add download flag --- frontend/src/api/associations.ts | 2 +- frontend/src/pages/node/SectionOverview.vue | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/api/associations.ts b/frontend/src/api/associations.ts index e6f1955f0..4d60fbf52 100644 --- a/frontend/src/api/associations.ts +++ b/frontend/src/api/associations.ts @@ -20,7 +20,7 @@ export const getAssociations = async ( sort: sort ? `${sort.key} ${sort.direction === "up" ? "asc" : "desc"}` : null, - ...(download && { format: download }), + ...(download && { download: true, format: download }), }; /** make query */ diff --git a/frontend/src/pages/node/SectionOverview.vue b/frontend/src/pages/node/SectionOverview.vue index c89b3f942..75096575a 100644 --- a/frontend/src/pages/node/SectionOverview.vue +++ b/frontend/src/pages/node/SectionOverview.vue @@ -144,7 +144,6 @@