From 5d33f010bec06660c6d1ea1afa8cecb550d4dffe Mon Sep 17 00:00:00 2001
From: maltheism <16293415+maltheism@users.noreply.github.com>
Date: Thu, 25 Nov 2021 11:41:07 -0500
Subject: [PATCH] update
update
Revert "update"
This reverts commit 6d56db990f51d6a64f1a0ba8fab4ee9488590a24.
Revert "update"
This reverts commit 3f8274d83a66afdae45f903c2ed5c9ec47ec8702.
update
remove additional directory for file storage
remove additional directory for file storage
update
update
Update files.js
---
.../genomic_browser/jsx/tabs_content/files.js | 12 +++++++--
.../genomic_browser/php/filemanager.class.inc | 27 +++++++++++++++++++
.../php/uploading/genomicfile.class.inc | 6 +++--
3 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/modules/genomic_browser/jsx/tabs_content/files.js b/modules/genomic_browser/jsx/tabs_content/files.js
index 0aa6d446690..3e80b07deaa 100644
--- a/modules/genomic_browser/jsx/tabs_content/files.js
+++ b/modules/genomic_browser/jsx/tabs_content/files.js
@@ -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);
@@ -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 =
{fileName} | ;
+ break;
case 'PSCID':
- const url = `${this.props.baseURL}/${rowData.DCCID}/`;
- reactElement = {rowData.PSCID} | ;
+ const urlPscid = `${this.props.baseURL}/${rowData.DCCID}/`;
+ reactElement = {rowData.PSCID} | ;
break;
case 'Subproject':
reactElement = {this.state.data.subprojects[parseInt(cell)]} | ;
diff --git a/modules/genomic_browser/php/filemanager.class.inc b/modules/genomic_browser/php/filemanager.class.inc
index 83de23c925a..cde651bb333 100644
--- a/modules/genomic_browser/php/filemanager.class.inc
+++ b/modules/genomic_browser/php/filemanager.class.inc
@@ -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');
diff --git a/modules/genomic_browser/php/uploading/genomicfile.class.inc b/modules/genomic_browser/php/uploading/genomicfile.class.inc
index f220a0cb836..46a9e209219 100644
--- a/modules/genomic_browser/php/uploading/genomicfile.class.inc
+++ b/modules/genomic_browser/php/uploading/genomicfile.class.inc
@@ -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;