From f042e6d7d674d9e716cd0deebcb227036022c06f Mon Sep 17 00:00:00 2001 From: stanislavsulc Date: Tue, 2 Jul 2024 11:36:01 +0200 Subject: [PATCH] Web UI - variable for base URL --- webapi/index.py | 51 ++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/webapi/index.py b/webapi/index.py index 8e1ba16..45f47ec 100644 --- a/webapi/index.py +++ b/webapi/index.py @@ -58,6 +58,13 @@ def update_user_picture_url(user_id: str, val): def update_user_name(user_id: str, val): db.Users.update_one({'id': user_id}, { "$set": { 'name': val } }) +web_ui_config = {"BASE_URL": ""} +web_ui_configPath = "/var/lib/mupif/persistent/google_auth_config.json" +if os.path.exists(web_ui_configPath): + with open(web_ui_configPath) as config_json: + web_ui_config = json.load(config_json) +BASE_URL = web_ui_config.get("BASE_URL", "") + login_config = {} googleConfigPath = os.path.expanduser("/var/lib/mupif/persistent/google_auth_config.json") if os.path.exists(googleConfigPath): @@ -255,7 +262,7 @@ def callback(): if user is None: return "User email not available or not verified by Google.", 400 - # return redirect("/") + return redirect(f"{BASE_URL}/") return homepage() @@ -264,7 +271,7 @@ def callback(): @login_required def logout(): logout_user() - return redirect("/") + return redirect(f"{BASE_URL}/") @app.route('/about') @@ -329,15 +336,15 @@ def usecases(): html += '' html += '' + uc['ucid'] + '' html += '' + uc['Description'] + '' - html += 'List of workflows' + html += f'List of workflows' html += '' if admin_rights: - html += 'Register new workflow' + html += f'Register new workflow' html += '' html += '' html += '' if admin_rights: - html += '
Register new UseCase' + html += f"
Register new UseCase" return my_render_template('basic.html', body=Markup(html), login=login_header_html()) @@ -362,7 +369,7 @@ def addUseCase(): if new_usecase_id is not None: html = '
UseCase has been registered
' - html += 'Go back to UseCases' + html += f'Go back to UseCases' return my_render_template('basic.html', body=Markup(html), login=login_header_html()) else: message += '
UseCase was not registered
' @@ -463,7 +470,7 @@ def workflow(wid, version): html += '' html += "" - html += '

Executions of this workflow' + html += f'

Executions of this workflow' admin_rights = getUserHasAdminRights() if admin_rights: @@ -557,7 +564,7 @@ def addWorkflow(usecaseid): if new_workflow_id is not None: html = '

Workflow has been registered

' - html += 'Go to workflow detail' + html += f'Go to workflow detail' return my_render_template('basic.html', body=Markup(html), login=login_header_html()) else: # generate input form @@ -628,7 +635,7 @@ def executions(): for execution in data: html += '' html += ''+execution['Status']+'' - html += 'link' + html += f'link' html += ''+execution['WorkflowID']+'(v'+str(execution['WorkflowVersion'])+')' html += ''+str(execution['CreatedDate']).replace('None', '')[:19]+'' # html += ''+str(execution['SubmittedDate']).replace('None', '')[:19]+'' @@ -679,18 +686,18 @@ def executionStatus(weid): html += '
' html += 'Actions:
' html += '' @@ -782,7 +789,7 @@ def setExecutionInputs(weid): if obo_id is not None: restApiControl.setExecutionOntoBaseObjectID(weid, name=obo.get('Name', ''), value=obo_id) - msg += "
Back to Execution detail" + msg += f"
Back to Execution detail" # return my_render_template("basic.html", body=Markup(msg), login=login_header_html()) execution_record = restApiControl.getExecutionRecord(weid) @@ -791,7 +798,7 @@ def setExecutionInputs(weid): workflow_record = restApiControl.getWorkflowRecord(wid) winprec = workflow_record["IOCard"]["Inputs"] # generate input form - form = "Back to Execution detail
" + form = f"Back to Execution detail
" # form += f"

Execution inputs: {wid}


" @@ -1032,7 +1039,7 @@ def setExecutionInputs(weid): form += '' + obo.get('createFrom', '') + '' form += '' if obo_id != '': - form += 'inspect' + form += f'inspect' form += '' form += '' form += "" @@ -1040,9 +1047,9 @@ def setExecutionInputs(weid): if execution_record["Status"] == "Created": form += "
" if show_execution_links: - form += f"

Hide execution output links" + form += f"

Hide execution output links" else: - form += f"

Show execution output links" + form += f"

Show execution output links" return my_render_template('form.html', form=form, login=login_header_html()) @@ -1059,7 +1066,7 @@ def getExecutionOutputs(weid): # generate result table form - form = "Back to Execution detail" + form = f"Back to Execution detail" form += "

Execution outputs

" form += "" @@ -1069,7 +1076,7 @@ def getExecutionOutputs(weid): if i['Type'] == 'mupif.Property': if i['Object'].get('FileID') is not None and i['Object'].get('FileID') != '': - val = 'link' + val = f'link' else: if i.get('EDMPath', None) is not None: onto_path = i.get('EDMPath') @@ -1176,7 +1183,7 @@ def getExecutionOutputs(weid): if obo.get('EDMList', False) is True: form += '' else: - form += '' + form += f'' form += '' form += "
inspectinspect
" @@ -1227,10 +1234,10 @@ def propertyArrayView(file_id, page): if maxpage > 1: html += '

' if page > 1: - html += '  <' + html += f'  <' html += '   page ' + str(page) + ' / ' + str(maxpage) + '   ' if page < maxpage: - html += '>' + html += f'>' html += '

' html += ''