Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Doc Repo] Refactor to use new File Uploader class #5234

Merged
merged 30 commits into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bb72c65
[Doc Repo] Refactor to use new File Uploader class
johnsaigle Sep 18, 2019
0a1c2af
fix swal and typos
johnsaigle Sep 18, 2019
fa6c8e6
Update documentation
johnsaigle Sep 23, 2019
8054fad
add raisinbread
johnsaigle Oct 28, 2019
bed4985
Remove unreachable code and update documentation
johnsaigle Oct 30, 2019
0488bbb
fix typo
johnsaigle Nov 27, 2019
f9cdfe2
Resolve rebase
johnsaigle Jan 14, 2020
62c97a6
Update patch
johnsaigle Jan 14, 2020
be4dd57
Fix typos
johnsaigle Jan 14, 2020
c688183
Cleanup errors from rebase
johnsaigle Jan 22, 2020
1a9c6dc
Fix ID error in patch
johnsaigle Feb 18, 2020
15acee0
Fix bug in building path
johnsaigle Mar 3, 2020
0d9a33d
improve error handling
johnsaigle Mar 3, 2020
c479cb2
remove unnecessary comments
johnsaigle Mar 3, 2020
2d12ba1
Fix SWAL issues
johnsaigle Mar 9, 2020
d616d48
Undo changes to instrument manager
johnsaigle Mar 10, 2020
162d304
Update modules/instrument_manager/jsx/uploadForm.js
johnsaigle Mar 10, 2020
c308cc3
Fix config variable name
johnsaigle Mar 10, 2020
8745aa3
add new permissions to admin rb user
johnsaigle Jun 30, 2020
9a74115
phpcs
johnsaigle Jun 30, 2020
9733047
Helping to fix javascript
HenriRabalais Jul 6, 2020
b0bf21e
handling unknown errors
HenriRabalais Jul 6, 2020
546e8ca
update error handling message
HenriRabalais Jul 6, 2020
bc47728
fix json
johnsaigle Jul 6, 2020
8dffe61
update permission descriptions
johnsaigle Jul 7, 2020
ae890d5
finalized unknown error message
HenriRabalais Jul 6, 2020
0f00d77
remove print statement
HenriRabalais Jul 6, 2020
e8044da
fixing error upon file upload
HenriRabalais Jul 7, 2020
21711d3
fix typo
johnsaigle Jul 7, 2020
d94fc48
restore uploading files to a user sub directory
johnsaigle Jul 7, 2020
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
7 changes: 4 additions & 3 deletions SQL/0000-00-01-Permission.sql
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ INSERT INTO `permissions` VALUES
(32,'candidate_parameter_edit','Edit Candidate Parameters','2'),
(33,'genomic_browser_view_site','View Genomic Browser data from own site','2'),
(34,'genomic_browser_view_allsites','View Genomic Browser data across all sites','2'),
(35,'document_repository_view','View and upload files in Document Repository','2'),
(36,'document_repository_delete','Delete files in Document Repository','2'),
(35,'document_repository_view','Document Repository: View','2'),
(36,'document_repository_delete','Document Repository: Delete','2'),
(37,'server_processes_manager','View and manage server processes','2'),
(38,'imaging_uploader','Imaging Uploader','2'),
(39,'acknowledgements_view','View Acknowledgements','2'),
Expand Down Expand Up @@ -110,7 +110,8 @@ INSERT INTO `permissions` VALUES
(62,'module_manager_view', 'Module Manager: access the module', 2),
(63,'module_manager_edit', 'Module Manager: edit installed modules', 2),
(64,'candidate_dod_edit', 'Edit dates of death', 2),
(65,'violated_scans_view_ownsite','Violated Scans: View Violated Scans from own site','2');
(65,'violated_scans_view_ownsite','Violated Scans: View Violated Scans from own site','2'),
(66,'document_repository_edit','Document Repository: Edit and Upload','2');

INSERT INTO `user_perm_rel` (userID, permID)
SELECT u.ID, p.permID
Expand Down
1 change: 0 additions & 1 deletion SQL/0000-00-03-ConfigTables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType,
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'dateDisplayFormat', 'The date format to use throughout LORIS for displaying date information - formats for date inputs are browser- and locale-dependent.', 1, 0, 'text', ID, 'Date display format', 28 FROM ConfigSettings WHERE Name="study";
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'adminContactEmail', 'An email address that users can write to in order to report issues or ask question', 1, 0, 'text', ID, 'Administrator Email', 29 FROM ConfigSettings WHERE Name="study";


INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, Label, OrderNumber) VALUES ('paths', 'Specify directories where LORIS-related files are stored or created. Take care when editing these fields as changing them incorrectly can cause certain modules to lose functionality.', 1, 0, 'Paths', 2);
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'imagePath', 'Path to images for display in Imaging Browser (e.g. /data/$project/data/) ', 1, 0, 'text', ID, 'Images', 9 FROM ConfigSettings WHERE Name="paths";
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'base', 'The base filesystem path where LORIS is installed', 1, 0, 'text', ID, 'Base', 1 FROM ConfigSettings WHERE Name="paths";
Expand Down
4 changes: 4 additions & 0 deletions SQL/New_patches/2019-09-18_DocRepoEdit.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
INSERT INTO `permissions` (code,description,categoryID) VALUES ('document_repository_edit','Upload and edit files in Document Repository','2');
UPDATE `permissions` SET description='Document Repository: View' WHERE code='document_repository_view';
UPDATE `permissions` SET description='Document Repository: Edit and upload' WHERE code='document_repository_edit';
UPDATE `permissions` SET description='Document Repository: Delete' WHERE code='document_repository_delete';
13 changes: 4 additions & 9 deletions modules/document_repository/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,16 @@ This module is used primarily by study coordinators/administrators who share stu

## Permissions

A user that has "document_repository_view" permission can view and upload files in Document Repository.
A user that has "document_repository_view" permission can view files in Document Repository.
A user that has "document_repository_edit" permission upload and edit files in Document Repository.
A user that has "document_repository_delete" permission can delete files in Document Repository.

## Configurations

- The Document Repository enables users to upload and organize project files of any type (PDF,Photo,Txt...) that can easily be viewable for users with appropriate permissions ("document_repository_view").

- Check that the following settings are in the php.ini file.
```
session.gc_maxlifetime = 10800 // After this number of seconds, stored data will be seen as 'garbage' and cleaned up by the garbage collection process.
max_input_time = 10800 // Maximum amount of time each script may spend parsing request data (in seconds)
max_execution_time = 10800 // Maximum execution time of each script (in seconds)
upload_max_filesize = 1024M // Maximum allowed size for uploaded files.
post_max_size = 1024M // Maximum size of POST data that PHP will accept.
```
The `documentRepositoryPath` configuration setting is the path to the folder on the
uploaded file system where new files will be written.

- A mail server is required to send out email notification regarding the Document Repository updates.

Expand Down
16 changes: 9 additions & 7 deletions modules/document_repository/jsx/uploadForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,21 +158,23 @@ class DocUploadForm extends Component {
credentials: 'same-origin',
body: formObject,
})
.then((resp) => resp.json())
.then((data) => {
if (data == 'uploaded successfully') {
.then((resp) => {
console.error(resp);
if (resp.ok) {
swal.fire('Upload Successful!', '', 'success').then((result) => {
if (result.value) {
this.setState({formData: {}});
this.props.refreshPage();
}
});
} else {
swal.fire('Duplicate File Name!', '', 'error');
resp.json().then((data) => {
swal.fire('Could not upload file', data.error, 'error');
}).catch((error) => {
console.error(error);
swal.fire('Unknown Error', 'Please report the issue or contact your administrator', 'error');
});
}
})
.catch((error) => {
console.error(error);
});
}

Expand Down
16 changes: 8 additions & 8 deletions modules/document_repository/php/document_repository.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ namespace LORIS\document_repository;
*/
class Document_Repository extends \NDB_Menu_Filter_Form
{
public $AjaxModule = true;
public $skipTemplate = true;
private const PERMISSIONS = [
'document_repository_view',
'document_repository_edit',
'document_repository_delete',
];
public $AjaxModule = true;
public $skipTemplate = true;

/**
* Checking user permissions
Expand All @@ -36,12 +41,7 @@ class Document_Repository extends \NDB_Menu_Filter_Form
*/
function _hasAccess(\User $user) : bool
{
return $user->hasAnyPermission(
[
'document_repository_view',
'document_repository_delete',
]
);
return $user->hasAnyPermission(self::PERMISSIONS);
}
/**
* Function _setupVariables
Expand Down
Loading