Skip to content
Snippets Groups Projects
Commit 718aacb6 authored by Suireen's avatar Suireen
Browse files

README and Dokumentation in citation_parser_main

parent b6691b33
No related branches found
No related tags found
1 merge request!27Main
...@@ -22,7 +22,7 @@ app = dash.Dash(__name__, external_stylesheets=[dbc.themes.SPACELAB]) ...@@ -22,7 +22,7 @@ app = dash.Dash(__name__, external_stylesheets=[dbc.themes.SPACELAB])
additional_options = ['Update Automatically','Smart Input'] additional_options = ['Update Automatically','Smart Input']
# Reads the contents of info_box.txt. # Reads the contents of info_box.txt.
# They can later be displayed by pressing the corresponding button. # They can later be displayed by pressing the corresponding "Show Info" button.
f = open('info_box.txt', 'r') f = open('info_box.txt', 'r')
boxcontent = f.read() boxcontent = f.read()
f.close() f.close()
...@@ -30,6 +30,7 @@ f.close() ...@@ -30,6 +30,7 @@ f.close()
app.layout = html.Div([ app.layout = html.Div([
html.Div(children=[ html.Div(children=[
# Layer 0: For the Header and Help Function(s) # Layer 0: For the Header and Help Function(s)
#Show Info button for showing Informations
dbc.Button( dbc.Button(
'Show Info', 'Show Info',
id='collapse-button', id='collapse-button',
...@@ -37,6 +38,7 @@ html.Div(children=[ ...@@ -37,6 +38,7 @@ html.Div(children=[
color="primary", color="primary",
n_clicks=0, n_clicks=0,
), ),
#state is set to be collapsed at first
dbc.Collapse( dbc.Collapse(
dbc.Card(dbc.CardBody(html.Div(boxcontent, style={'whiteSpace': 'pre-line', 'font-size': '10px'}))), dbc.Card(dbc.CardBody(html.Div(boxcontent, style={'whiteSpace': 'pre-line', 'font-size': '10px'}))),
id='collapse', id='collapse',
...@@ -72,14 +74,22 @@ html.Div(children=[ ...@@ -72,14 +74,22 @@ html.Div(children=[
#Drag and drop or click to select a file to upload #Drag and drop or click to select a file to upload
["Drag and drop"]), ["Drag and drop"]),
style={ style={
<<<<<<< HEAD:citation_parser_main.py
"width": "400px",
=======
"width": "360px", "width": "360px",
>>>>>>> main:citation_parser_ui.py
"height": "60px", "height": "60px",
"lineHeight": "60px", "lineHeight": "60px",
"borderWidth": "1px", "borderWidth": "1px",
"borderStyle": "dashed", "borderStyle": "dashed",
"borderRadius": "5px", "borderRadius": "5px",
"textAlign": "center", "textAlign": "center",
<<<<<<< HEAD:citation_parser_main.py
"margin": "10px",
=======
"margin": "10px" "margin": "10px"
>>>>>>> main:citation_parser_ui.py
}),size="lg", color="primary", type="border", fullscreen=True,), }),size="lg", color="primary", type="border", fullscreen=True,),
]), ]),
...@@ -105,17 +115,28 @@ html.Div(children=[ ...@@ -105,17 +115,28 @@ html.Div(children=[
dcc.Checklist(id='additional-options', dcc.Checklist(id='additional-options',
options=[{'label':k,'value':k} for k in additional_options], options=[{'label':k,'value':k} for k in additional_options],
value=[],labelStyle = dict(display= 'block')) value=[],labelStyle = dict(display= 'block'))
<<<<<<< HEAD:citation_parser_main.py
]),
=======
],style={'margin-top': "50px"}), ],style={'margin-top': "50px"}),
>>>>>>> main:citation_parser_ui.py
], style={'padding': 10, 'flex': 0.8}), ], style={'padding': 10, 'flex': 0.8}),
html.Div(children=[ html.Div(children=[
# Layer 5: For the Graph and corresponding error messages # Layer 5: For the Graph and corresponding error messages
dbc.Spinner(html.Div([ dbc.Spinner(html.Div([
<<<<<<< HEAD:citation_parser_main.py
html.Div(id='generate-graph-error',style={'color':'red'}),
html.Iframe(
src="assets/index.html",
style={"height": "650px", "width": "100%"},
=======
html.Div(id='generate-graph-error',style={'color':'red', 'position': "absolute", 'margin-top': "650px"}), html.Div(id='generate-graph-error',style={'color':'red', 'position': "absolute", 'margin-top': "650px"}),
html.Iframe( html.Iframe(
src="assets/index.html", src="assets/index.html",
style={"height": "650px", "width": "1000px"}, style={"height": "650px", "width": "1000px"},
>>>>>>> main:citation_parser_ui.py
), ),
]),size="lg", color="primary", type="border", fullscreen=True,), ]),size="lg", color="primary", type="border", fullscreen=True,),
], style={'padding': 10, 'flex': 1.2}) ], style={'padding': 10, 'flex': 1.2})
...@@ -165,11 +186,7 @@ def update_input_checklist(input_value,btn1,btn2,filecontents,all_inputs, ...@@ -165,11 +186,7 @@ def update_input_checklist(input_value,btn1,btn2,filecontents,all_inputs,
# if clear-all-button was pressed: # if clear-all-button was pressed:
if 'clear-all-button' in changed_id: if 'clear-all-button' in changed_id:
# the try/except is needed so that clear-all may be used even if there is no json-file
try:
os.remove('assets/json_text.json') os.remove('assets/json_text.json')
except:
pass
return list(),list(),'','' return list(),list(),'',''
# if clear-selected-button was pressed: # if clear-selected-button was pressed:
...@@ -248,10 +265,12 @@ def update_input_checklist(input_value,btn1,btn2,filecontents,all_inputs, ...@@ -248,10 +265,12 @@ def update_input_checklist(input_value,btn1,btn2,filecontents,all_inputs,
) )
def toggle_collapse(n, is_open): def toggle_collapse(n, is_open):
''' '''
This callback shows and hides the (first) info-box by, checking how often This callback shows and hides the info-box. The text was loaded at the top from an extern .txt.
the button has been pressed. The text was loaded at the top.
:param n_clicks: number of times show-info has been clicked. :param n: number of times show-info has been clicked.
'type n_clicks: int :type n: int
:param is_open state of the show-info button
:type is_open: boolean
''' '''
if n: if n:
return not is_open return not is_open
...@@ -286,17 +305,22 @@ def generate_output(n_clicks,all_inputs,forward_depth,backward_depth,additional_ ...@@ -286,17 +305,22 @@ def generate_output(n_clicks,all_inputs,forward_depth,backward_depth,additional_
changed_id = [p['prop_id'] for p in callback_context.triggered][0] changed_id = [p['prop_id'] for p in callback_context.triggered][0]
if n_clicks is None: if n_clicks is None:
raise PreventUpdate raise PreventUpdate
# This branch is entered when 'Generate Graph' is pushed or 'Update Automatically' is selected
# and the checklist or recursion depths are changed.
elif 'Update Automatically' in additional_options \ elif 'Update Automatically' in additional_options \
or 'start-button' in changed_id: or 'start-button' in changed_id:
input_links = [x['value'] for x in all_inputs] input_links = [x['value'] for x in all_inputs]
# Processing only returns a potential error message. The data for the graph is simply saved
# in the specified file.
errors = Processing(input_links,int(forward_depth),int(backward_depth),'assets/json_text.json') errors = Processing(input_links,int(forward_depth),int(backward_depth),'assets/json_text.json')
if errors: if errors:
# This construct is needed because dash removes white spaces and newlines when concatinating
# strings with '\n'.join(...) or similar methods.
message = ['The following inputs are invalid and were not used:'] message = ['The following inputs are invalid and were not used:']
for error in errors: for error in errors:
message.append(html.Br()) message.append(html.Br())
message.append(error) message.append(error)
message = html.P(message) message = html.P(message)
#message = [html.P(error) for error in errors]
return message return message
if __name__ == '__main__': if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment