Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
maltheism committed Jun 28, 2021
1 parent ea1f9e9 commit fdf3870
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
7 changes: 4 additions & 3 deletions python/eeg2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,15 @@ def set_loris_credentials(sid, data):
loris_api.username = lorisCredentials.lorisUsername
loris_api.password = lorisCredentials.lorisPassword
loris_api.login()
sio.emit('loris_login_response', {'success': 200})
sio.emit('loris_sites', loris_api.get_sites())
sio.emit('loris_projects', loris_api.get_projects())


def get_loris_sites(sid):
sio.emit('loris_sites', loris_api.get_sites())


@sio.event
def get_loris_projects(sid):
sio.emit('loris_projects', loris_api.get_projects())
Expand Down Expand Up @@ -113,13 +114,13 @@ def ieeg_get_header(sid, data):
def get_metadata(sid, data):
# data = { file_path: 'path to metadata file' }
print('metadata file:', data)

if not data['file_path']:
print('No file path found.')
response = {
'error': 'No file path found.',
}
else :
else :
try:
with open(data['file_path']) as fd:
reader = csv.DictReader(fd, delimiter="\t", quotechar='"')
Expand Down
23 changes: 22 additions & 1 deletion src/jsx/elements/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ export const AuthenticationMessage = (props) => {
useEffect(async () => {
const myAPI = window['myAPI'];
const credentials = await myAPI.getLorisAuthenticationCredentials();
if (credentials) {
console.log(credentials);
if (credentials &&
credentials.lorisURL &&
credentials.lorisUsername &&
credentials.lorisPassword
) {
setLoginMessage(`LORIS Account set as ${credentials.lorisUsername}`);
setLoginLink('Sign in to another account..');
appContext.setTask('lorisURL', credentials.lorisURL);
Expand All @@ -40,6 +45,22 @@ export const AuthenticationMessage = (props) => {
}
}, []);

/**
* Similar to componentDidMount and componentDidUpdate.
*/
useEffect(async () => {
if (socketContext) {
socketContext.on('loris_login_response', (data) => {
if (data.error) {
// todo display error message - login failure
} else {
setLoginMessage(`LORIS Account set as ${appContext.lorisUsername}`);
setLoginLink('Sign in to another account..');
}
});
}
}, [socketContext]);

/**
* User clicked sign in..
*/
Expand Down

0 comments on commit fdf3870

Please sign in to comment.