diff --git a/citation_parser_main.py b/citation_parser_main.py index 16932f389392754bef4f563ff904ee28b1f2ec03..85e78fd36b941c2bcabe45cca689a2fce8b5378c 100644 --- a/citation_parser_main.py +++ b/citation_parser_main.py @@ -22,7 +22,7 @@ app = dash.Dash(__name__, external_stylesheets=[dbc.themes.SPACELAB]) additional_options = ['Update Automatically','Smart Input'] # 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') boxcontent = f.read() f.close() @@ -30,6 +30,7 @@ f.close() app.layout = html.Div([ html.Div(children=[ # Layer 0: For the Header and Help Function(s) + #Show Info button for showing Informations dbc.Button( 'Show Info', id='collapse-button', @@ -37,6 +38,7 @@ html.Div(children=[ color="primary", n_clicks=0, ), + #state is set to be collapsed at first dbc.Collapse( dbc.Card(dbc.CardBody(html.Div(boxcontent, style={'whiteSpace': 'pre-line', 'font-size': '10px'}))), id='collapse', @@ -72,14 +74,22 @@ html.Div(children=[ #Drag and drop or click to select a file to upload ["Drag and drop"]), style={ +<<<<<<< HEAD:citation_parser_main.py + "width": "400px", +======= "width": "360px", +>>>>>>> main:citation_parser_ui.py "height": "60px", "lineHeight": "60px", "borderWidth": "1px", "borderStyle": "dashed", "borderRadius": "5px", "textAlign": "center", +<<<<<<< HEAD:citation_parser_main.py + "margin": "10px", +======= "margin": "10px" +>>>>>>> main:citation_parser_ui.py }),size="lg", color="primary", type="border", fullscreen=True,), ]), @@ -105,17 +115,28 @@ html.Div(children=[ dcc.Checklist(id='additional-options', options=[{'label':k,'value':k} for k in additional_options], value=[],labelStyle = dict(display= 'block')) +<<<<<<< HEAD:citation_parser_main.py + ]), +======= ],style={'margin-top': "50px"}), +>>>>>>> main:citation_parser_ui.py ], style={'padding': 10, 'flex': 0.8}), html.Div(children=[ # Layer 5: For the Graph and corresponding error messages 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.Iframe( src="assets/index.html", style={"height": "650px", "width": "1000px"}, +>>>>>>> main:citation_parser_ui.py ), ]),size="lg", color="primary", type="border", fullscreen=True,), ], style={'padding': 10, 'flex': 1.2}) @@ -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' 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') - except: - pass + os.remove('assets/json_text.json') return list(),list(),'','' # if clear-selected-button was pressed: @@ -248,10 +265,12 @@ def update_input_checklist(input_value,btn1,btn2,filecontents,all_inputs, ) def toggle_collapse(n, is_open): ''' - This callback shows and hides the (first) info-box by, checking how often - the button has been pressed. The text was loaded at the top. - :param n_clicks: number of times show-info has been clicked. - 'type n_clicks: int + This callback shows and hides the info-box. The text was loaded at the top from an extern .txt. + + :param n: number of times show-info has been clicked. + :type n: int + :param is_open state of the show-info button + :type is_open: boolean ''' if n: return not is_open @@ -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] if n_clicks is None: 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 \ or 'start-button' in changed_id: 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') 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:'] for error in errors: message.append(html.Br()) message.append(error) message = html.P(message) - #message = [html.P(error) for error in errors] return message if __name__ == '__main__':