Skip to content

Commit a1f2b43

Browse files
committed
Notification system
1 parent e1f6e47 commit a1f2b43

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

SQL/0000-00-02-Permission.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ INSERT INTO `permissions` VALUES
130130
(59,'imaging_quality_control_view','Flagged Imaging Entries',(SELECT ID FROM modules WHERE Name='imaging_qc'),'View','2'),
131131
(60,'behavioural_quality_control_view','Flagged Behavioural Entries',(SELECT ID FROM modules WHERE Name='behavioural_qc'),'View','2'),
132132
(61,'api_docs','API documentation',(SELECT ID FROM modules WHERE Name='api_docs'),'View','2'),
133-
(62,'electrophysiology_browser_edit_annotations','Annotations',(SELECT ID FROM modules WHERE Name='electrophysiology_browser'), 'Create/Edit', '2');
133+
(62,'electrophysiology_browser_edit_annotations','Annotations',(SELECT ID FROM modules WHERE Name='electrophysiology_browser'),'Create/Edit','2'),
134+
(63,'monitor_eeg_uploads','Monitor EEG uploads',(SELECT ID FROM modules WHERE Name='electrophysiology_uploader'),NULL,'2');
134135

135136
INSERT INTO `user_perm_rel` (userID, permID)
136137
SELECT u.ID, p.permID

SQL/New_patches/2023-02-24-electrophysiology_uploader.sql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,9 @@ CREATE TABLE `electrophysiology_uploader` (
1717
INSERT INTO modules (Name, Active) VALUES ('electrophysiology_uploader', 'Y');
1818

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

23+
-- Add new permissions for eeg uploader
24+
INSERT INTO permissions (code, description, moduleID, action, categoryID) VALUES
25+
('monitor_eeg_uploads','Monitor EEG uploads',(SELECT ID FROM modules WHERE Name='electrophysiology_uploader'),NULL,'2');

modules/electrophysiology_uploader/jsx/UploadForm.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ export default function UploadForm(props) {
1515
const [errorMessage, setErrorMessage] = useState({});
1616
const [uploadProgress, setuploadProgress] = useState(-1);
1717

18+
/**
19+
* Reset form
20+
*/
21+
const resetForm = () => {
22+
setFormData({});
23+
setErrorMessage({});
24+
setHasError({});
25+
setuploadProgress(-1);
26+
};
27+
1828
/**
1929
* Updates values in formData
2030
*
@@ -139,7 +149,6 @@ export default function UploadForm(props) {
139149
pscid: null,
140150
visit: null,
141151
});
142-
143152
setHasError({
144153
eegFile: false,
145154
candID: false,
@@ -149,15 +158,15 @@ export default function UploadForm(props) {
149158

150159
let text = '';
151160
if (props.autoLaunch === 'true' || props.autoLaunch === '1') {
152-
text = 'Processing of this file by the MRI pipeline has started\n'
153-
+ 'Select this upload in the result table '
154-
+ 'to view the processing progress';
161+
text = 'Processing of this file by the EEG pipeline has started';
155162
}
156163
swal.fire({
157164
title: 'Upload Successful!',
158165
text: text,
159166
type: 'success',
160167
});
168+
169+
resetForm();
161170
} else {
162171
processError(xhr);
163172
}

modules/electrophysiology_uploader/php/upload.class.inc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,15 @@ class Upload extends \NDB_Page
208208

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

211-
// Send notification to specific users
212-
$to_list = [
213-
'santiago.morales@usc.edu',
214-
'lyoder@umd.edu',
215-
'fox@umd.edu',
216-
'mmcsw1@umd.edu',
217-
'mantunez@umd.edu'
218-
];
211+
// Send notification to eeg managers
212+
$emails = $db->pselectCol(
213+
"SELECT Email
214+
FROM users u
215+
JOIN user_perm_rel upr ON upr.userID = u.ID
216+
JOIN permissions p ON upr.permID = p.permID
217+
WHERE p.code='monitor_eeg_uploads'",
218+
[]
219+
);
219220
$timepoint = \TimePoint::singleton(new \SessionID($sessionID));
220221
$msg_data = [
221222
'Site' => $timepoint->getPSC(),
@@ -227,8 +228,7 @@ class Upload extends \NDB_Page
227228
'UploadLocation' => $saveValues['UploadLocation'],
228229
'UploadUrl' => null,
229230
];
230-
231-
foreach ($to_list as $email) {
231+
foreach ($emails as $email) {
232232
\Email::send(
233233
$email,
234234
'new_electrophysiology_upload.tpl',

0 commit comments

Comments
 (0)