Skip to content

Commit

Permalink
Notification system
Browse files Browse the repository at this point in the history
  • Loading branch information
laemtl committed Mar 30, 2023
1 parent e1f6e47 commit 4ca18d4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
3 changes: 2 additions & 1 deletion SQL/0000-00-02-Permission.sql
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ INSERT INTO `permissions` VALUES
(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');
(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');

INSERT INTO `user_perm_rel` (userID, permID)
SELECT u.ID, p.permID
Expand Down
6 changes: 5 additions & 1 deletion SQL/New_patches/2023-02-24-electrophysiology_uploader.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ CREATE TABLE `electrophysiology_uploader` (
INSERT INTO modules (Name, Active) VALUES ('electrophysiology_uploader', 'Y');

-- Add new configurations for eeg uploader
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'EEGUploadIncomingPath', 'Path to the upload directory for incoming EEG studies', 1, 0, 'text', ID, 'EEG Incoming Directory', 7 FROM ConfigSettings WHERE Name="paths";
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber)
SELECT 'EEGUploadIncomingPath', 'Path to the upload directory for incoming EEG studies', 1, 0, 'text', ID, 'EEG Incoming Directory', 7 FROM ConfigSettings WHERE Name="paths";

-- Add new permissions for eeg uploader
INSERT INTO permissions (code, description, moduleID, action, categoryID) VALUES
('monitor_eeg_uploads','Monitor EEG uploads',(SELECT ID FROM modules WHERE Name='electrophysiology_uploader'),NULL,'2');
17 changes: 13 additions & 4 deletions modules/electrophysiology_uploader/jsx/UploadForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ export default function UploadForm(props) {
const [errorMessage, setErrorMessage] = useState({});
const [uploadProgress, setuploadProgress] = useState(-1);

/**
* Reset form
*/
const resetForm = () => {
setFormData({});
setErrorMessage({});
setHasError({});
setuploadProgress(-1);
};

/**
* Updates values in formData
*
Expand Down Expand Up @@ -139,7 +149,6 @@ export default function UploadForm(props) {
pscid: null,
visit: null,
});

setHasError({
eegFile: false,
candID: false,
Expand All @@ -149,15 +158,15 @@ export default function UploadForm(props) {

let text = '';
if (props.autoLaunch === 'true' || props.autoLaunch === '1') {
text = 'Processing of this file by the MRI pipeline has started\n'
+ 'Select this upload in the result table '
+ 'to view the processing progress';
text = 'Processing of this file by the EEG pipeline has started';
}
swal.fire({
title: 'Upload Successful!',
text: text,
type: 'success',
});

resetForm();
} else {
processError(xhr);
}
Expand Down
20 changes: 10 additions & 10 deletions modules/electrophysiology_uploader/php/upload.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,15 @@ class Upload extends \NDB_Page

$db->insert('electrophysiology_uploader', $saveValues);

// Send notification to specific users
$to_list = [
'santiago.morales@usc.edu',
'lyoder@umd.edu',
'fox@umd.edu',
'mmcsw1@umd.edu',
'mantunez@umd.edu'
];
// Send notification to eeg managers
$emails = $db->pselectCol(
"SELECT Email
FROM users u
JOIN user_perm_rel upr ON upr.userID = u.ID
JOIN permissions p ON upr.permID = p.permID
WHERE p.code='monitor_eeg_uploads'",
[]
);
$timepoint = \TimePoint::singleton(new \SessionID($sessionID));
$msg_data = [
'Site' => $timepoint->getPSC(),
Expand All @@ -227,8 +228,7 @@ class Upload extends \NDB_Page
'UploadLocation' => $saveValues['UploadLocation'],
'UploadUrl' => null,
];

foreach ($to_list as $email) {
foreach ($emails as $email) {
\Email::send(
$email,
'new_electrophysiology_upload.tpl',
Expand Down

0 comments on commit 4ca18d4

Please # to comment.