Commit 03c499f3 authored by Josh Adam's avatar Josh Adam

Merge branch 'fix-612-request-uri-too-long' into 'development'

Fixes #612 by splitting download of sample files into 2 steps

Closes #612

See merge request !1262
parents 4b0b7ec0 14f912f3
Pipeline #6737 passed with stage
in 49 minutes and 23 seconds
......@@ -187,6 +187,7 @@
<li role="menuitem">
<a href="#" class="js-sample-export-btn t-download-btn"
data-enabled-at="1" data-toggle="tooltip" data-type="download"
data:prepare-url="@{/projects/{id}/download/prepare(id=${project.getId()})}"
data:url="@{/projects/{id}/download/files(id=${project.getId()})}"
data:enabled-msg="#{project.samples.tooltip.download.requires-more-than-one}">
<i class="fa fa-download fa-fw spaced-right__sm" aria-hidden="true"></i>
......
......@@ -21,6 +21,7 @@ import { FILTERS, SAMPLE_EVENTS } from "./constants";
import { download } from "../../../utilities/file.utilities";
import moment from "moment";
import "../../../../sass/pages/project-samples.scss";
import { showNotification } from "../../../modules/notifications";
/*
This is required to use select2 inside a modal.
......@@ -55,13 +56,32 @@ Initialize the sample export menu.
const EXPORT_HANDLERS = {
download() {
// this is set by the object calling (i.e. download btn)
const prepareDownloadUrl = this.data("prepareUrl");
const url = this.data("url");
const selected = $dt.select.selected()[0];
const ids = [];
selected.forEach(s => {
ids.push(s.sample);
ids.push(parseInt(s.sample));
});
$.ajax({
type: "POST",
url: prepareDownloadUrl,
contentType: "application/json; charset=utf-8",
data: JSON.stringify(ids),
success: function(response, status, request) {
download(`${url}?${$.param({ path: response.path })}`);
},
error: function(jqXHR, textStatus, errorThrown) {
showNotification({
timeout: false,
progressBar: false,
type: "error",
closeWith: ["button"],
text: `${textStatus}: ${prepareDownloadUrl}: ${errorThrown}`
});
}
});
download(`${url}?${$.param({ ids })}`);
},
file() {
// this is set by the object calling (i.e. download btn)
......
......@@ -337,7 +337,10 @@ public class ProjectSamplesControllerTest {
when(sampleService.readMultiple(ImmutableList.of(sample.getId()))).thenReturn(ImmutableList.of(sample));
when(sequencingObjectService.getSequencingObjectsForSample(sample)).thenReturn(filejoin);
controller.downloadSamples(project.getId(), ImmutableList.of(sample.getId()), response);
Map<String, Object> preparedDownloadMap = controller.prepareSampleDownload(project.getId(),
ImmutableList.of(sample.getId()));
controller.downloadSamples(project.getId(), (String) preparedDownloadMap.get("path"), response);
verify(projectService).read(project.getId());
verify(sampleService).readMultiple(ImmutableList.of(sample.getId()));
......@@ -373,7 +376,9 @@ public class ProjectSamplesControllerTest {
when(sampleService.readMultiple(ImmutableList.of(sample.getId()))).thenReturn(ImmutableList.of(sample));
when(sequencingObjectService.getSequencingObjectsForSample(sample)).thenReturn(filejoin);
controller.downloadSamples(project.getId(), ImmutableList.of(sample.getId()), response);
Map<String, Object> preparedDownloadMap = controller.prepareSampleDownload(project.getId(),
ImmutableList.of(sample.getId()));
controller.downloadSamples(project.getId(), (String) preparedDownloadMap.get("path"), response);
verify(projectService).read(project.getId());
verify(sampleService).readMultiple(ImmutableList.of(sample.getId()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment