Skip to content

Commit

Permalink
Merge branch 'main' into main_login_component
Browse files Browse the repository at this point in the history
  • Loading branch information
maltheism authored Jun 28, 2021
2 parents 2d0e38d + baf60f6 commit 573e0cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
14 changes: 5 additions & 9 deletions python/eeg2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# Create socket listener.
sio = socketio.Server(async_mode='eventlet', cors_allowed_origins=[])
app = socketio.WSGIApp(sio)
loris_api = LorisAPI()


# Create Loris API handler.
Expand Down Expand Up @@ -71,27 +72,22 @@ def set_loris_credentials(sid, data):
sio.emit('loris_projects', loris_api.get_projects())


@sio.event
def get_loris_sites(sid):
print('get_loris_sites has ran!')
sio.emit('loris_sites', loris_api.get_sites())


@sio.event
def get_loris_projects(sid):
print('get_loris_projects has ran!')
sio.emit('loris_projects', loris_api.get_projects())


@sio.event
def get_loris_subprojects(sid, project):
print('get_loris_subprojects has ran!')
sio.emit('loris_subprojects', loris_api.get_subprojects(project))


@sio.event
def get_loris_visits(sid, project):
print('get_loris_visits has ran!')
sio.emit('loris_visits', loris_api.get_visits(project))


Expand All @@ -117,18 +113,18 @@ 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='"')
response = {
'metadata': {rows['Field']: rows['Value'] for rows in reader}
'metadata': {rows['Field']:rows['Value'] for rows in reader}
}
except IOError:
print("Could not read the metadata file.")
Expand Down
19 changes: 4 additions & 15 deletions python/libs/loris_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,19 @@ class LorisAPI:
username = ''
password = ''

# url = 'https://inhance-dev.loris.ca/api/v0.0.3/'
# username = 'admin'
# password = 'LORISitb2021!'
token = ''

def __init__(self):
# self.login()
# self.get_projects()
# self.get_sites()
# self.save_instrument()
# self.get_project('Pumpernickel')
# self.create_candidate()
# visit = self.get_visit(317604, 'Visit 01', 'Data Coordinating Center', 'Stale', 'Pumpernickel')
# print(visit)
# self.start_next_stage(317604, 'Visit 01', 'Data Coordinating Center', 'Stale', 'Pumpernickel', "2021-03-06")

def login(self):
resp = json.loads(requests.post(
url=self.url + 'login',
json={
'username': self.username,
url = self.url + 'login',
json = {
'username': self.username,
'password': self.password
},
verify=False
verify = False
).content.decode('ascii'))

if resp.get('error'):
Expand Down
8 changes: 6 additions & 2 deletions src/jsx/Configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ const Configuration = (props) => {
Object.keys(state).map((key) => appContext.setTask(key, state[key].get));
}, []);

useEffect(() => {
Object.keys(state).map((key) => appContext.setTask(key, state[key].get));
}, []);

/**
* Similar to componentDidMount and componentDidUpdate.
*/
Expand Down Expand Up @@ -683,7 +687,7 @@ const Configuration = (props) => {
/>
</div>
}
{state.participantEntryMode.get === 'loris' &&
{state.participantEntryMode.get == 'loris' &&
<>
<div className='small-pad'>
<label className="label" htmlFor={props.id}>
Expand Down Expand Up @@ -732,7 +736,7 @@ const Configuration = (props) => {
/>
</>
}
{state.participantEntryMode.get === 'manual' &&
{state.participantEntryMode.get == 'manual' &&
<>
<div className='small-pad'>
<TextInput id='participantID'
Expand Down

0 comments on commit 573e0cc

Please sign in to comment.