Skip to content

Commit

Permalink
[genomic_browser] Download button not showing up in the Files tab (#…
Browse files Browse the repository at this point in the history
…8480)

Made the name column a link for downloading. Note: This module needs refactoring of the upload and download logic to be more robust.

    Resolves #7594
  • Loading branch information
ridz1208 authored Dec 12, 2023
1 parent 5b7ddb2 commit 18707d1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
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

0 comments on commit 18707d1

Please sign in to comment.