Skip to content

Commit 889797d

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 d7cdd2c commit 889797d

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
@@ -613,6 +613,25 @@ async def download_data_object(
613613
}
614614

615615

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

web/src/components/DataObjectTable.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default defineComponent({
104104
async function openHtmlDataModal(item: any) {
105105
iframeLoading.value = true;
106106
dataModal.value = true;
107-
iframeDataSource.value = await api.getDataObjectUrl(item.id);
107+
iframeDataSource.value = await api.getDataObjectHtmlContentUrl(item.id);
108108
selectedHtmlDataObject.value = item;
109109
}
110110
watch(dataModal, () => {
@@ -243,7 +243,9 @@ export default defineComponent({
243243
class="d-flex align-center justify-center flex-grow-1"
244244
>
245245
<v-progress-circular
246+
class="mr-2"
246247
color="primary"
248+
size="24"
247249
indeterminate
248250
/>
249251
Loading...
@@ -257,10 +259,6 @@ export default defineComponent({
257259
loading="lazy"
258260
@load="onIframeLoaded"
259261
/>
260-
<div
261-
class="iframe-blocker"
262-
:style="{ position: 'absolute', height: '100%', width: '100%'}"
263-
/>
264262
</v-card-text>
265263
<v-card-actions class="flex-row">
266264
<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)