From 466a066f966e33cd04a39449a8f1e5182766b364 Mon Sep 17 00:00:00 2001 From: ramari16 Date: Fri, 15 Nov 2024 10:17:33 -0500 Subject: [PATCH] ALS-7712: ALlow PFB Export to 3rd party via signed URL (#295) --- .../explorer/export/ExportStepper.svelte | 36 +++++++++++++++++-- src/lib/configuration.ts | 1 + 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/lib/components/explorer/export/ExportStepper.svelte b/src/lib/components/explorer/export/ExportStepper.svelte index 2af264b8..8fc0a7a3 100644 --- a/src/lib/components/explorer/export/ExportStepper.svelte +++ b/src/lib/components/explorer/export/ExportStepper.svelte @@ -173,6 +173,16 @@ return 'ERROR'; } + async function getSignedUrl() { + const path = 'picsure/query/' + datasetId + '/signed-url'; + try { + const res = await api.post(path, query); + return res.signedUrl; + } catch (error) { + console.error('Error in getSignedUrl', error); + } + } + export let activeType: ExpectedResultType; function selectExportType(exportType: ExpectedResultType) { query.query.expectedResultType = exportType; @@ -184,6 +194,7 @@ } let tabSet: number = 0; + $: exportLoading = false; function dataLimitExceeded(): boolean { let participantCount: number = @@ -191,6 +202,15 @@ let totalDataPoints: number = participantCount + $filters.length + $exports.length; return totalDataPoints > MAX_DATA_POINTS_FOR_EXPORT; } + + async function exportToTerra() { + exportLoading = true; + let signedUrl = await getSignedUrl(); + window.open( + 'https://app.terra.bio/#import-data?format=pfb&url=' + encodeURIComponent(signedUrl), + ); + exportLoading = false; + }
- Use the option below to download your selected data in the PFB format. + Select an option below to export your selected data in PFB format.
+ {#if features.explorer.enableTerraExport} +
+
+
+ +
+
+ {/if}
@@ -441,7 +474,6 @@ >Download as PFB
-
{/if} diff --git a/src/lib/configuration.ts b/src/lib/configuration.ts index bbb548a7..a01f4a83 100644 --- a/src/lib/configuration.ts +++ b/src/lib/configuration.ts @@ -121,6 +121,7 @@ export const features: Indexable = { enableTour: import.meta.env?.EXPLORER_TOUR ? import.meta.env?.EXPLORE_TOUR === 'true' : true, // default to true unless set otherwise authTour: import.meta.env?.VITE_OPEN_TOUR_NAME ?? 'NHANES-Auth', enableHierarchy: import.meta.env?.VITE_ENABLE_HIERARCHY === 'true', + enableTerraExport: import.meta.env?.VITE_ENABLE_TERRA_EXPORT === 'true', }, login: { open: import.meta.env?.VITE_OPEN === 'true',