Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[genomic_browser] Download button not showing up in the Files tab #8480

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions modules/genomic_browser/jsx/tabs_content/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Files extends Component {
},
};
this.fetchData = this.fetchData.bind(this);
this.formatColumn = this.formatColumn.bind(this);
this.openFileUploadModal = this.openFileUploadModal.bind(this);
this.closeFileUploadModal = this.closeFileUploadModal.bind(this);
this.renderFileUploadForm = this.renderFileUploadForm.bind(this);
Expand Down Expand Up @@ -151,9 +152,16 @@ class Files extends Component {
formatColumn(column, cell, rowData, rowHeaders) {
let reactElement;
switch (column) {
case 'Name':
const fileName = rowData.Name.split('/').pop();
const url =
`${this.props.baseURL
}/genomic_browser/FileManager?filename=${fileName}`;
reactElement = <td><a href={url}>{fileName}</a></td>;
break;
case 'PSCID':
const url = `${this.props.baseURL}/${rowData.DCCID}/`;
reactElement = <td><a href={url}>{rowData.PSCID}</a></td>;
const urlPscid = `${this.props.baseURL}/${rowData.DCCID}/`;
reactElement = <td><a href={urlPscid}>{rowData.PSCID}</a></td>;
break;
case 'Subproject':
reactElement = <td>{this.state.data.subprojects[parseInt(cell)]}</td>;
Expand Down
27 changes: 27 additions & 0 deletions modules/genomic_browser/php/filemanager.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,33 @@ class FileManager extends \NDB_Page implements ETagCalculator
*/
private function _handleGET(ServerRequestInterface $request) : ResponseInterface
{
// Parse GET query params.
$values = $request->getQueryParams();
// GET request for downloading file by ID.
if ($values['filename']) {
$factory = \NDB_Factory::singleton();
$config = $factory->config();
$filesDir = \Utility::appendForwardSlash(
$config->getSetting('GenomicDataPath')
);
try {
$downloadhandler = new \LORIS\FilesDownloadHandler(
new \SplFileInfo($filesDir)
);
$request = $request->withAttribute(
'filename',
$values['filename']
);
return $downloadhandler->handle($request);
} catch (\LorisException $e) {
// FilesUploadHandler throws an exception if there's a problem with
// the downloaddir.
return new \LORIS\Http\Response\JSON\InternalServerError(
$e->getMessage()
);
}
}

$provisioner = new FilesProvisioner();
$user = $request->getAttribute('user');

Expand Down
6 changes: 4 additions & 2 deletions modules/genomic_browser/php/uploading/genomicfile.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,10 @@ class Genomicfile
function setFullPath(&$fileToUpload) : void
{
$config = \NDB_Config::singleton();
$genomic_data_dir = rtrim($config->getSetting('GenomicDataPath'), '/')
. '/genomic_uploader/';
$genomic_data_dir = rtrim(
$config->getSetting('GenomicDataPath'),
'/'
) . '/';

$fileToUpload->full_path = $genomic_data_dir
. $fileToUpload->file_name;
Expand Down