Skip to content

Commit 9672ce6

Browse files
committed
Add endpoint to get url for some data object types
For now this includes only Krona plots. This endpoint "bypasses" the need to log in to get the download URL for these data objects.
1 parent 7062467 commit 9672ce6

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

nmdc_server/api.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,25 @@ async def download_data_object(
616616
}
617617

618618

619+
@router.get("/data_object/{data_object_id}/get_html_content_url")
620+
async def get_data_object_html_content(data_object_id: str, db: Session = Depends(get_db)):
621+
data_object = crud.get_data_object(db, data_object_id)
622+
if data_object is None:
623+
raise HTTPException(status_code=404, detail="DataObject not found")
624+
url = data_object.url
625+
if url is None:
626+
raise HTTPException(status_code=404, detail="DataObject has no url reference")
627+
if data_object.file_type in [
628+
"Kraken2 Krona Plot",
629+
"GOTTCHA2 Krona Plot",
630+
"Centrifuge Krona Plot",
631+
]:
632+
return {
633+
"url": url,
634+
}
635+
return HTTPException(status_code=400, detail="DataObject has no relevant HTML content")
636+
637+
619638
@router.post(
620639
"/data_object/workflow_summary",
621640
response_model=schemas.DataObjectAggregation,

web/src/components/DataObjectTable.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default defineComponent({
106106
async function openHtmlDataModal(item: any) {
107107
iframeLoading.value = true;
108108
dataModal.value = true;
109-
iframeDataSource.value = await api.getDataObjectUrl(item.id);
109+
iframeDataSource.value = await api.getDataObjectHtmlContentUrl(item.id);
110110
selectedHtmlDataObject.value = item;
111111
}
112112
watch(dataModal, () => {
@@ -269,7 +269,9 @@ export default defineComponent({
269269
class="d-flex align-center justify-center flex-grow-1"
270270
>
271271
<v-progress-circular
272+
class="mr-2"
272273
color="primary"
274+
size="24"
273275
indeterminate
274276
/>
275277
Loading...
@@ -283,10 +285,6 @@ export default defineComponent({
283285
loading="lazy"
284286
@load="onIframeLoaded"
285287
/>
286-
<div
287-
class="iframe-blocker"
288-
:style="{ position: 'absolute', height: '100%', width: '100%'}"
289-
/>
290288
</v-card-text>
291289
<v-card-actions class="flex-row">
292290
<v-spacer />

web/src/data/api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,8 @@ async function createBulkDownload(conditions: Condition[], dataObjectFilter: Dat
641641
};
642642
}
643643

644-
async function getDataObjectUrl(dataObjectId: string): Promise<string> {
645-
const { data } = await client.get<{ url: string }>(`data_object/${dataObjectId}/download`);
644+
async function getDataObjectHtmlContentUrl(dataObjectId: string): Promise<string> {
645+
const { data } = await client.get<{ url: string }>(`data_object/${dataObjectId}/get_html_content_url`);
646646
return data.url;
647647
}
648648

@@ -851,7 +851,7 @@ client.interceptors.response.use(undefined, async (error: AxiosError) => {
851851

852852
const api = {
853853
createBulkDownload,
854-
getDataObjectUrl,
854+
getDataObjectHtmlContentUrl,
855855
getBinnedFacet,
856856
getBulkDownloadSummary,
857857
getBulkDownloadAggregateSummary,

0 commit comments

Comments
 (0)