From fdf3870bc2fe676a790e492a6c0870898c863011 Mon Sep 17 00:00:00 2001 From: maltheism <16293415+maltheism@users.noreply.github.com> Date: Mon, 28 Jun 2021 17:40:50 -0400 Subject: [PATCH] update --- python/eeg2bids.py | 7 ++++--- src/jsx/elements/authentication.js | 23 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/python/eeg2bids.py b/python/eeg2bids.py index 75ea34f..ae58eeb 100644 --- a/python/eeg2bids.py +++ b/python/eeg2bids.py @@ -68,6 +68,7 @@ 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()) @@ -75,7 +76,7 @@ def set_loris_credentials(sid, data): 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()) @@ -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='"') diff --git a/src/jsx/elements/authentication.js b/src/jsx/elements/authentication.js index 5a5c640..218d6b1 100644 --- a/src/jsx/elements/authentication.js +++ b/src/jsx/elements/authentication.js @@ -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); @@ -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.. */