Skip to content

Commit

Permalink
ALS-7712: ALlow PFB Export to 3rd party via signed URL (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramari16 authored Nov 15, 2024
1 parent 14cc8bd commit 466a066
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/lib/components/explorer/export/ExportStepper.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -184,13 +194,23 @@
}
let tabSet: number = 0;
$: exportLoading = false;
function dataLimitExceeded(): boolean {
let participantCount: number =
typeof $totalParticipants === 'number' ? $totalParticipants : MAX_DATA_POINTS_FOR_EXPORT + 1;
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;
}
</script>

<Stepper
Expand Down Expand Up @@ -429,8 +449,21 @@
{:else if query.query.expectedResultType === 'DATAFRAME_PFB'}
<section class="flex flex-col gap-8">
<div class="flex justify-center mt-4">
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.
</div>
{#if features.explorer.enableTerraExport}
<div class="grid grid-cols-3">
<div></div>
<div>
<button
disabled={exportLoading}
class="flex-initial w-64 btn variant-filled-primary disabled:variant-ghost-primary"
on:click={() => exportToTerra()}
><i class="fa-solid fa-arrow-up-right-from-square"></i>Export to Terra</button
>
</div>
</div>
{/if}
<div class="grid grid-cols-3">
<div></div>
<div>
Expand All @@ -441,7 +474,6 @@
><i class="fa-solid fa-download"></i>Download as PFB</button
>
</div>
<div></div>
</div>
</section>
{/if}
Expand Down
1 change: 1 addition & 0 deletions src/lib/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 466a066

Please sign in to comment.