Skip to content

Commit

Permalink
Merge pull request #13681 from davelopez/use_datasets_api_link_for_do…
Browse files Browse the repository at this point in the history
…wnload

Use API link to download datasets
  • Loading branch information
jmchilton authored Apr 7, 2022
2 parents 5935182 + a04763a commit 308db49
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default {
},
computed: {
downloadUrl() {
return prependPath(`datasets/${this.item.id}/display?to_ext=${this.item.extension}`);
return prependPath(`api/datasets/${this.item.id}/display?to_ext=${this.item.extension}`);
},
showDownloads() {
return !this.item.purged && ["ok", "failed_metadata", "error"].includes(this.item.state);
Expand Down
2 changes: 1 addition & 1 deletion client/src/mvc/dataset/dataset-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var DatasetAssociation = Backbone.Model.extend(BASE_MVC.LoggableMixin).extend(
purge: `datasets/${id}/purge_async`,
display: `datasets/${id}/display/?preview=True`,
edit: `datasets/edit?dataset_id=${id}`,
download: `datasets/${id}/display${this._downloadQueryParameters()}`,
download: `api/datasets/${id}/display${this._downloadQueryParameters()}`,
report_error: `dataset/errors?id=${id}`,
rerun: `tool_runner/rerun?id=${id}`,
show_params: `datasets/${id}/details`,
Expand Down
16 changes: 12 additions & 4 deletions lib/galaxy/webapps/galaxy/api/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,26 @@ def extra_files(
):
return self.service.extra_files(trans, history_content_id)

@router.get(
"/api/datasets/{history_content_id}/display",
summary="Displays (preview) or downloads dataset content.",
response_class=StreamingResponse,
)
@router.get(
"/api/histories/{history_id}/contents/{history_content_id}/display",
name="history_contents_display",
summary="Displays dataset (preview) content.",
summary="Displays (preview) or downloads dataset content.",
tags=["histories"],
response_class=StreamingResponse,
)
def display(
self,
request: Request,
trans=DependsOnTrans,
history_id: EncodedDatabaseIdField = HistoryIDPathParam,
history_id: Optional[EncodedDatabaseIdField] = Query(
default=None,
description="The encoded database identifier of the History.",
),
history_content_id: EncodedDatabaseIdField = DatasetIDPathParam,
preview: bool = Query(
default=False,
Expand Down Expand Up @@ -234,10 +242,10 @@ def display(
),
),
):
"""Streams the preview contents of a dataset to be displayed in a browser."""
"""Streams the dataset for download or the contents preview to be displayed in a browser."""
extra_params = get_query_parameters_from_request_excluding(request, {"preview", "filename", "to_ext", "raw"})
display_data, headers = self.service.display(
trans, history_content_id, history_id, preview, filename, to_ext, raw, **extra_params
trans, history_content_id, preview, filename, to_ext, raw, **extra_params
)
return StreamingResponse(display_data, headers=headers)

Expand Down
4 changes: 0 additions & 4 deletions lib/galaxy/webapps/galaxy/services/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ def display(
self,
trans: ProvidesHistoryContext,
history_content_id: EncodedDatabaseIdField,
history_id: EncodedDatabaseIdField,
preview: bool = False,
filename: Optional[str] = None,
to_ext: Optional[str] = None,
Expand Down Expand Up @@ -443,9 +442,6 @@ def display(
except galaxy_exceptions.MessageException:
raise
except Exception as e:
log.exception(
"Server error getting display data for dataset (%s) from history (%s)", history_content_id, history_id
)
raise galaxy_exceptions.InternalServerError(f"Could not get display data for dataset: {util.unicodify(e)}")
return rval, headers

Expand Down

0 comments on commit 308db49

Please sign in to comment.