Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
598fd38
[data_release] Introduce Manage File, Revamp Manage Permissions, Hide…
skarya22 Nov 4, 2024
d7fd7e1
Update documentation
skarya22 Nov 4, 2024
389b2d5
Update raisinbread
skarya22 Nov 4, 2024
f0764a4
Remove problematic line
skarya22 Nov 5, 2024
bb5ffae
Fix for lint
skarya22 Nov 5, 2024
0d7fafd
fix deletion error
skarya22 Nov 13, 2024
5af3f50
Merge remote-tracking branch 'aces/main' into 2024_11_04_Data_Release…
skarya22 Nov 13, 2024
1642e95
Fix oversight in merge
skarya22 Nov 15, 2024
d3e886d
Add missing hide and delete permissions
skarya22 Nov 15, 2024
fe38d4f
Lint fix
skarya22 Nov 15, 2024
5a637ef
Rename hidden_by_id_ & remove subquery
skarya22 Jan 28, 2025
df1f86d
Missed a spot
skarya22 Jan 28, 2025
6d6bdb4
Merge remote-tracking branch 'aces/main' into 2024_11_04_Data_Release…
skarya22 Jan 28, 2025
8586f95
Merge remote-tracking branch 'aces/main' into 2024_11_04_Data_Release…
skarya22 Mar 21, 2025
d06bbaa
Merge remote-tracking branch 'aces/main' into 2023_11_04_Data_Release…
skarya22 Apr 7, 2025
d0369d2
Add improvement to versions select from CCNA
skarya22 Apr 7, 2025
6b3e101
Merge remote-tracking branch 'aces/main' into 2024_11_04_Data_Release…
skarya22 May 22, 2025
b1cb4a7
Merge remote-tracking branch 'aces/main' into 2024_11_04_Data_Release…
skarya22 Jul 8, 2025
cc977a5
Merge remote-tracking branch 'aces/main' into 2024_11_04_Data_Release…
skarya22 Jul 31, 2025
1eead23
Merge remote-tracking branch 'aces/main' into 2024_11_04_Data_Release…
skarya22 Oct 30, 2025
b46b95d
Fix for tests
skarya22 Oct 30, 2025
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
4 changes: 3 additions & 1 deletion SQL/0000-00-00-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2097,8 +2097,10 @@ CREATE TABLE `data_release` (
`version` varchar(255),
`upload_date` date,
`ProjectID` INT(10) UNSIGNED NULL,
`hidden_by_id` INT(10) UNSIGNED NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (ProjectID) REFERENCES Project (ProjectID)
FOREIGN KEY (ProjectID) REFERENCES Project (ProjectID),
FOREIGN KEY (hidden_by_id) REFERENCES users (ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `data_release_permissions` (
Expand Down
52 changes: 27 additions & 25 deletions SQL/0000-00-02-Permission.sql
Original file line number Diff line number Diff line change
Expand Up @@ -112,31 +112,33 @@ INSERT INTO `permissions` VALUES
(40,'data_release_view', 'Release Files',(SELECT ID FROM modules WHERE Name='data_release'),'View', 2),
(41,'data_release_upload', 'Release Files',(SELECT ID FROM modules WHERE Name='data_release'),'Upload', 2),
(42,'data_release_edit_file_access', 'Grant Other Users Access to Releases',(SELECT ID FROM modules WHERE Name='data_release'),NULL, 2),
(43,'instrument_manager_read', 'Installed Instruments',(SELECT ID FROM modules WHERE Name='instrument_manager'),'View', 2),
(44,'instrument_manager_write', 'Upload and Install Instruments',(SELECT ID FROM modules WHERE Name='instrument_manager'),NULL, 2),
(45,'publication_view', 'Publication Projects',(SELECT ID FROM modules WHERE Name='publication'),'View', 2),
(46,'publication_propose', 'Propose Publication Projects',(SELECT ID FROM modules WHERE Name='publication'),NULL, 2),
(47,'publication_approve', 'Accept/Reject Publication Projects',(SELECT ID FROM modules WHERE Name='publication'),NULL, 2),
(48,'candidate_dob_edit', 'Dates of Birth',(SELECT ID FROM modules WHERE Name='candidate_parameters'),'Edit', 2),
(49,'electrophysiology_browser_view_allsites', 'EEGs - All Sites',(SELECT ID FROM modules WHERE Name='electrophysiology_browser'),'View', 2),
(50,'electrophysiology_browser_view_site', 'EEGs - Own Sites',(SELECT ID FROM modules WHERE Name='electrophysiology_browser'),'View', 2),
(51,'battery_manager_view','Battery Entries',(SELECT ID FROM modules WHERE Name='battery_manager'),'View',2),
(52,'battery_manager_edit','Battery Entries',(SELECT ID FROM modules WHERE Name='battery_manager'),'Create/Edit',2),
(53,'module_manager_view', 'Installed Modules',(SELECT ID FROM modules WHERE Name='module_manager'),'View', 2),
(54,'module_manager_edit', 'Installed Modules',(SELECT ID FROM modules WHERE Name='module_manager'),'Edit', 2),
(55,'candidate_dod_edit', 'Dates of Death',(SELECT ID FROM modules WHERE Name='candidate_parameters'),'Edit', 2),
(56,'violated_scans_view_ownsite','Violated Scans - Own Sites',(SELECT ID FROM modules WHERE Name='mri_violations'),'View','2'),
(57,'document_repository_upload_edit','Documents',(SELECT ID FROM modules WHERE Name='document_repository'),'Edit/Upload','2'),
(58,'survey_accounts_view', 'Candidate Surveys',(SELECT ID FROM modules WHERE Name='survey_accounts'),'View', 2),
(59,'imaging_quality_control_view','Flagged Imaging Entries',(SELECT ID FROM modules WHERE Name='imaging_qc'),'View','2'),
(60,'behavioural_quality_control_view','Flagged Behavioural Entries',(SELECT ID FROM modules WHERE Name='behavioural_qc'),'View','2'),
(61,'api_docs','API documentation',(SELECT ID FROM modules WHERE Name='api_docs'),'View','2'),
(62,'electrophysiology_browser_edit_annotations','Annotations',(SELECT ID FROM modules WHERE Name='electrophysiology_browser'), 'Create/Edit', '2'),
(63,'monitor_eeg_uploads','Monitor EEG uploads',(SELECT ID FROM modules WHERE Name='electrophysiology_uploader'),NULL,'2'),
(64,'dataquery_admin','Admin dataquery queries',(SELECT ID FROM modules WHERE Name='dataquery'),NULL,'2'),
(65,'schedule_module','Schedule Module - edit and delete the appointment',(SELECT ID FROM modules WHERE Name='schedule_module'),'View/Create/Edit','2'),
(66,'document_repository_categories','Categories',(SELECT ID FROM modules WHERE Name='document_repository'), 'Edit/Upload/Delete', '2'),
(67,'document_repository_hidden','Restricted files',(SELECT ID FROM modules WHERE Name='document_repository'), 'View', '2');
(43,'data_release_hide', 'Hide data release files',(SELECT ID FROM modules WHERE Name='data_release'),NULL, 2),
(44,'data_release_delete', 'Delete data release files',(SELECT ID FROM modules WHERE Name='data_release'),NULL, 2),
(45,'instrument_manager_read', 'Installed Instruments',(SELECT ID FROM modules WHERE Name='instrument_manager'),'View', 2),
(46,'instrument_manager_write', 'Upload and Install Instruments',(SELECT ID FROM modules WHERE Name='instrument_manager'),NULL, 2),
(47,'publication_view', 'Publication Projects',(SELECT ID FROM modules WHERE Name='publication'),'View', 2),
(48,'publication_propose', 'Propose Publication Projects',(SELECT ID FROM modules WHERE Name='publication'),NULL, 2),
(49,'publication_approve', 'Accept/Reject Publication Projects',(SELECT ID FROM modules WHERE Name='publication'),NULL, 2),
(50,'candidate_dob_edit', 'Dates of Birth',(SELECT ID FROM modules WHERE Name='candidate_parameters'),'Edit', 2),
(51,'electrophysiology_browser_view_allsites', 'EEGs - All Sites',(SELECT ID FROM modules WHERE Name='electrophysiology_browser'),'View', 2),
(52,'electrophysiology_browser_view_site', 'EEGs - Own Sites',(SELECT ID FROM modules WHERE Name='electrophysiology_browser'),'View', 2),
(53,'battery_manager_view','Battery Entries',(SELECT ID FROM modules WHERE Name='battery_manager'),'View',2),
(54,'battery_manager_edit','Battery Entries',(SELECT ID FROM modules WHERE Name='battery_manager'),'Create/Edit',2),
(55,'module_manager_view', 'Installed Modules',(SELECT ID FROM modules WHERE Name='module_manager'),'View', 2),
(56,'module_manager_edit', 'Installed Modules',(SELECT ID FROM modules WHERE Name='module_manager'),'Edit', 2),
(57,'candidate_dod_edit', 'Dates of Death',(SELECT ID FROM modules WHERE Name='candidate_parameters'),'Edit', 2),
(58,'violated_scans_view_ownsite','Violated Scans - Own Sites',(SELECT ID FROM modules WHERE Name='mri_violations'),'View','2'),
(59,'document_repository_upload_edit','Documents',(SELECT ID FROM modules WHERE Name='document_repository'),'Edit/Upload','2'),
(60,'survey_accounts_view', 'Candidate Surveys',(SELECT ID FROM modules WHERE Name='survey_accounts'),'View', 2),
(61,'imaging_quality_control_view','Flagged Imaging Entries',(SELECT ID FROM modules WHERE Name='imaging_qc'),'View','2'),
(62,'behavioural_quality_control_view','Flagged Behavioural Entries',(SELECT ID FROM modules WHERE Name='behavioural_qc'),'View','2'),
(63,'api_docs','API documentation',(SELECT ID FROM modules WHERE Name='api_docs'),'View','2'),
(65,'electrophysiology_browser_edit_annotations','Annotations',(SELECT ID FROM modules WHERE Name='electrophysiology_browser'), 'Create/Edit', '2'),
(66,'monitor_eeg_uploads','Monitor EEG uploads',(SELECT ID FROM modules WHERE Name='electrophysiology_uploader'),NULL,'2'),
(67,'dataquery_admin','Admin dataquery queries',(SELECT ID FROM modules WHERE Name='dataquery'),NULL,'2'),
(68,'schedule_module','Schedule Module - edit and delete the appointment',(SELECT ID FROM modules WHERE Name='schedule_module'),'View/Create/Edit','2'),
(69,'document_repository_categories','Categories',(SELECT ID FROM modules WHERE Name='document_repository'), 'Edit/Upload/Delete', '2'),
(70,'document_repository_hidden','Restricted files',(SELECT ID FROM modules WHERE Name='document_repository'), 'View', '2');

INSERT INTO `user_perm_rel` (userID, permID)
SELECT u.ID, p.permID
Expand Down
4 changes: 4 additions & 0 deletions SQL/New_patches/2024-10-31-Data_Release_Hide_File.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE data_release
ADD COLUMN hidden_by_id int(10) unsigned NULL DEFAULT NULL,
ADD CONSTRAINT FK_hidden_by_id
FOREIGN KEY (hidden_by_id) REFERENCES users (ID);
2 changes: 2 additions & 0 deletions modules/data_release/help/data_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ Click **Upload File** to upload a file and specify a version (based on your own
Click **Add Permission** to grant access to any of your users at the file or version level.

Click **Manage Permissions** to modify existing user permissions.

Click on the pencil beside the file name to edit file access, hide or delete the file.
88 changes: 62 additions & 26 deletions modules/data_release/jsx/addPermissionForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class AddPermissionForm extends Component {
errorMessage: {},
isLoaded: false,
loadedData: 0,
specificReleaseId: null,
};

this.setFormData = this.setFormData.bind(this);
Expand Down Expand Up @@ -59,7 +60,21 @@ class AddPermissionForm extends Component {
* Called by React when the component has been rendered on the page.
*/
componentDidMount() {
this.fetchData().then(() => this.setState({isLoaded: true}));
// if data was not provided from manageFileForm, fetch it.
if (!this.props.data) {
this.fetchData()
.then(() => this.setState({isLoaded: true}));
} else {
this.setState({
data: this.props.data,
fieldOptions: this.props.fieldOptions,
isLoaded: true,
specificReleaseId: this.props.specificReleaseId,
formData: {
data_release_id: this.props.specificReleaseId,
},
});
}
}

/**
Expand Down Expand Up @@ -99,33 +114,50 @@ class AddPermissionForm extends Component {
errorMessage={this.state.errorMessage.Username}
required={true}
value={this.state.formData.userid}
/>
<h3>Choose a specific file or an entire release below</h3><br/>
<SelectElement
name='data_release_id'
label='Data Release File'
options={this.state.fieldOptions.filenames}
onUserInput={this.setFormData}
ref='data_release_id'
hasError={this.state.hasError.Filename}
errorMessage={this.state.errorMessage.Filename}
required={false}
value={this.state.formData.data_release_id}
autoSelect={false}
/>
<h4>OR</h4><br/>
<SelectElement
name='data_release_version'
label='Data Release Version'
options={this.state.fieldOptions.versions}
onUserInput={this.setFormData}
ref='data_release_version'
hasError={this.state.hasError.Version}
errorMessage={this.state.errorMessage.Version}
required={false}
value={this.state.formData.data_release_version}
autoSelect={false}
/>
{this.state.specificReleaseId === null ?
<>
<h3>Choose a specific file or an entire release below</h3><br/>
<SelectElement
name='data_release_id'
label='Data Release File'
options={this.state.fieldOptions.filenames}
onUserInput={this.setFormData}
ref='data_release_id'
hasError={this.state.hasError.Filename}
errorMessage={this.state.errorMessage.Filename}
required={false}
value={this.state.formData.data_release_id}
autoSelect={false}
/>
<h4>OR</h4><br/>
<SelectElement
name='data_release_version'
label='Data Release Version'
options={this.state.fieldOptions.versions}
onUserInput={this.setFormData}
ref='data_release_version'
hasError={this.state.hasError.Version}
errorMessage={this.state.errorMessage.Version}
required={false}
value={this.state.formData.data_release_version}
autoSelect={false}
/>
</>
:
// If from manageFileForm, don't allow user to change the file
<SelectElement
name='data_release_id'
label='Data Release File'
options={this.state.fieldOptions.filenames}
onUserInput={() => {}}
ref='data_release_id'
disabled={true}
value={this.state.specificReleaseId}
autoSelect={false}
/>
}
<ButtonElement label='Add Permission'/>
</FormElement>
);
Expand Down Expand Up @@ -241,6 +273,10 @@ AddPermissionForm.propTypes = {
DataURL: PropTypes.string.isRequired,
action: PropTypes.string.isRequired,
fetchData: PropTypes.func,
data_release_id: PropTypes.number,
specificReleaseId: PropTypes.number,
fieldOptions: PropTypes.object,
data: PropTypes.object,
};

export default AddPermissionForm;
74 changes: 70 additions & 4 deletions modules/data_release/jsx/dataReleaseIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Modal from 'Modal';
import UploadFileForm from './uploadFileForm';
import AddPermissionForm from './addPermissionForm';
import ManagePermissionsForm from './managePermissionsForm';
import ManageFileForm from './manageFileForm';

/**
* Data Release
Expand All @@ -33,7 +34,9 @@ class DataReleaseIndex extends Component {
uploadFileForm: false,
addPermissionForm: false,
managePermissionsForm: false,
manageFileForm: false,
},
managingFile: null,
};

this.fetchData = this.fetchData.bind(this);
Expand Down Expand Up @@ -80,7 +83,9 @@ class DataReleaseIndex extends Component {
fetchData() {
return fetch(this.props.dataURL, {credentials: 'same-origin'})
.then((resp) => resp.json())
.then((data) => this.setState({data}))
.then((data) => {
this.setState({data});
})
.catch((error) => {
this.setState({error: true});
console.error(error);
Expand All @@ -97,7 +102,11 @@ class DataReleaseIndex extends Component {
*/
formatColumn(column, cell, row) {
// Set class to 'bg-danger' if file is hidden.
let result = <td>{cell}</td>;
let hidden = row['Hidden By ID']
&& this.props.hasPermission('data_release_hide');
let result = <td
className={hidden ? 'bg-danger' : ''}
>{cell}</td>;
switch (column) {
case 'File Name':
if (this.props.hasPermission('superuser')
Expand All @@ -108,17 +117,50 @@ class DataReleaseIndex extends Component {
+ '/data_release/files/'
+ encodeURIComponent(row['Data Release ID']);
result = (
<td>
<td
className={hidden ? 'bg-danger' : ''}
style={{display: 'flex',
justifyContent: 'space-between',
}}
>
<a
href = {downloadURL}
target = "_blank"
download = {row['File Name']} >
{cell}
</a>
{
(this.props.hasPermission('data_release_edit_file_access')
|| this.props.hasPermission('data_release_delete')
|| this.props.hasPermission('data_release_hide')
) &&
<a
style={{marginLeft: 'auto'}}
onClick={() => {
this.setState({
managingFile: {
fileName: row['File Name'],
version: row['Version'],
hiddenById: row['Hidden By ID'],
dataReleaseID: row['Data Release ID'],
},
});
this.show('manageFileForm');
}}
>
<span className='glyphicon glyphicon-pencil' />
</a>
}
</td>
);
}
break;
case 'Version':
result = <td
className={hidden ? 'bg-danger' : ''}>
{cell}
</td>;
break;
}
return result;
}
Expand Down Expand Up @@ -162,8 +204,11 @@ class DataReleaseIndex extends Component {
type: 'select',
options: this.state.data.fieldOptions.projects,
}},
{label: 'Data Release ID', show: false,
{label: 'Data Release ID',
show: false,
name: 'dataReleaseID',
},
{label: 'Hidden By ID', show: false},
];

// Upload File modal window
Expand Down Expand Up @@ -231,6 +276,26 @@ class DataReleaseIndex extends Component {
onClose={() => this.hide('managePermissionsForm')}
/>
);
// Manage File modal window
const manageFileForm = (
<Modal
title="Manage File"
label="Manage File"
show={this.state.show.manageFileForm}
onClose={() => {
this.hide('manageFileForm');
}}
onClick={this.manageFile}
>
<ManageFileForm
DataURL={`${loris.BaseURL}/data_release/?format=json`}
manageFileActions={`${loris.BaseURL}/data_release/files/`}
managePermissionActions={`${loris.BaseURL}/data_release/permissions`}
fetchData={this.fetchData}
managingFile={this.state.managingFile}
/>
</Modal>
);

const actions = [
{
Expand All @@ -257,6 +322,7 @@ class DataReleaseIndex extends Component {
<div>
{uploadFileForm}
{addPermissionForm}
{manageFileForm}
{managePermissionsForm}
<FilterableDataTable
name="data_release"
Expand Down
Loading