def __reset_canvas(self, reset_click: int): ctx = dash.callback_context if not ctx.triggered: raise PreventUpdate upload_last_modified = [] upload_file_namne = [] upload_contents = [] new_badges = [ dbc.Badge(id="energy_badge", children="Energy", pill=True, color="light"), dbc.Badge(id="distance_badge", children="Distance", pill=True, color="light"), dbc.Badge(id="contact_badge", children="Contacts", pill=True, color="light") ] new_spinner = dbc.Spinner( html.Div(id="trace-spinner", className="option_log_text", style={"marginBottom": "10px"})) self.__initialize_empty_components() return upload_contents, upload_file_namne, upload_last_modified, new_spinner, new_badges, "localhost:8050"
def build_tabs(simu): init_params(simu) tab1_content = build_chart_panel(simu) tab2_content = html.Div(children=build_cards(simu)) tab3_content = dbc.Card( dbc.CardBody([ build_sliders(), html.Div( className="row", children=[ html.Div(html.Button('Submit', id='submit-val', n_clicks=0)), html.Div( id="spin_pending", style={'visibility': 'none'}, children=[dbc.Spinner(color="warning", type="grow")]) ], style={"align-content": "center"}), ]), className="mt-3", ) tabs = dbc.Tabs([ dbc.Tab(tab1_content, label="Graphiques"), dbc.Tab(tab2_content, label="Vidéos"), dbc.Tab(tab3_content, label="Configuration"), ]) return html.Div([tabs])
def spinner_button(name, spinner_id, **kwargs): return html.Div( children=[ dbc.Button(name, **kwargs), dbc.Spinner(html.Div(id=spinner_id)), ], )
def main_layout_header(): """Dash layout with a top-header""" return html.Div( [ make_header(), dbc.Container( dbc.Row(dbc.Col(id=server.config["CONTENT_CONTAINER_ID"])), fluid=True ), dcc.Location(id=server.config["LOCATION_COMPONENT_ID"], refresh=False), dbc.Toast( id="db-refresh-toast", header="Fit.ly", is_open=False, dismissable=False, icon="danger", # top: 66 positions the toast below the navbar style={"position": "fixed", "top": 66, "right": 10, "width": 350}, children=[ dbc.Row(className='align-items-center text-center', children=[ dbc.Col(className='col-2', children=[dbc.Spinner(size='md', color="danger")]), dbc.Col(className='col-8 text-center', children=['Database Refresh in Progress']) ]) ], ), dcc.Interval(id='db-refresh-toast-interval', interval=3 * 1000, n_intervals=0), ] )
def roll_skill(n_inc, sess_id): ctx = dash.callback_context if not ctx.triggered or ctx.triggered[0]["value"] is None: raise PreventUpdate trigger_obj = json.loads(ctx.triggered[0]["prop_id"].split(".")[0]) attr = trigger_obj["name"] p_num = g_sessions[sess_id]["p_num"] p = g_players_list[p_num] # makes the player difficutly test button visible in the GM layout p.testing_attribute = attr p.attribute_tested.children = attr + " test: " p.btn_div.style = None if g_verbose: print("[" + sess_id[:8] + "-" + g_sessions[sess_id]["name"] + "] Rolling (" + attr + ")") # tell the GM session to update their layout for gm_id in g_gm_list: g_sessions[gm_id]["update"] = True p.is_rolling = True p.roll_outs[attr].children = dbc.Spinner(color="primary") # Disable any other roll for s in p.skill_bar_obj: p.skill_bar_obj[s]["button_roll"].disabled = True g_sessions[sess_id]["update"] = True while p.is_rolling is True: time.sleep(1) # Renable any other roll for s in p.skill_bar_obj: p.skill_bar_obj[s]["button_roll"].disabled = False g_sessions[sess_id]["update"] = True return [""] * len(ctx.outputs_list)
def set_DASHboard_layout(self): self.app.layout = html.Div(children=[ html.H1(id='dashboard-title', children='Options Trading Assistant'), html.Div( id='tabs-div', children=[ dcc.Tabs(id='dashboard-tabs', value='tab-1', children=[ dcc.Tab(label='Tab 1', value='tab-1'), dcc.Tab(label='Tab 2', value='tab-2'), ]), dbc.Spinner( id='tab-loading-spinner', children=[ html.Div(id="tab-content"), html.Div(id='shitty-redis', style={'display': 'none'}) ], spinner_style={ "width": "3rem", "height": "3rem" }, #https://dash-bootstrap-components.opensource.faculty.ai/docs/components/spinner/ ), ]) ]) # debugging advice -> https://community.plotly.com/t/solved-dash-layout-not-working-as-expected-general-debugging-tips/4724
def display_upload_tab(): upload_div = html.Div(["Drag and Drop or ", html.A("Select File")]) content = dbc.Card( dbc.CardBody([ dcc.Upload( id="upload-data", children=upload_div, style={ "width": "100%", "height": "30px", "lineHeight": "30px", "borderWidth": "1px", "borderStyle": "dashed", "borderRadius": "5px", "textAlign": "center", }, multiple=False, ), dbc.Spinner( html.Div(id="output-data-upload"), spinner_style={ "width": "3rem", "height": "3rem" }, ), ]), className="card border-primary mb-3", ) return content
def v1_page_content(): sidebar = dbc.Col( id='page-sidebar', children=[ html.P('Images directory:'), dbc.Input( id='images-directory', type='text', ), html.Br(), html.P('Name:'), dbc.Spinner(dcc.Dropdown(id='names-dropdown',)), html.Br(), html.P('Detection:'), dbc.Spinner(dcc.Dropdown(id='detect-dropdown', options=DETECT_OPTIONS)), ], width=2, style=SIDEBAR_STYLE, ) return dbc.Row(children=[ sidebar, dbc.Col( id='display-col', children=[ html.H5('Images:'), dbc.Spinner(dbc.Row( id='images_row', form=True, style={'flex-wrap': 'nowrap', 'overflow':'auto'})), html.Br(), html.H5('Images filename:'), dbc.Spinner(dbc.Row( id='logs_row', children= dcc.Textarea( id='logs_text', disabled=True, style={'width': '100%','height': '200px'} ), )), ], width=10, ) ])
def initial_path(challenger, opponent): return [ dbc.Button(challenger, id='ch-button', className='ch-button'), dbc.Spinner( id='path-loader', children=[html.Div(id='path-holder', className='path-holder')]), dbc.Button(opponent, id='op-button', className='op-button'), html.Div(challenger, id='current-figure', style={'display': 'none'}), ]
def display_right_col(): return [ dbc.Spinner( html.Div(id="extract-output"), spinner_style={ "width": "3rem", "height": "3rem" }, ), ]
def _page() -> Component: return html.Div([ html.H1('Convertisseur'), upload_row(_UPLOAD, _DROPDOWN, load_sample_documents()), _progress(), dcc.Store(id=_DOCUMENT_ID), dcc.Store(id=_PROCESSING_DONE), dcc.Interval(id=_INTERVAL, interval=2000), html.Div('', id=_OCR_OUTPUT), html.Div(dbc.Spinner(html.Div(), id=_LOADER)), ])
def UserPortalCard(username): return dbc.Card([ dbc.CardBody([ html.H3('User portal', className="card-text", style={'text-align': "center"}), html.Hr(), html.Br(), dbc.Spinner(html.Div(UserPortalCardBody(username), id='user-portal-div')), html.Br(), html.Div(id='user-portal-alert-div'), ]) ])
def status_update(n_clicks, job_id): if n_clicks and job_id: response = requests.get(f'http://retraining_api:8080/status_retraining/{job_id}') if response.status_code == 200: meta = response.json() if meta['progress'] != 'Done!': return [dbc.Spinner(size="sm"), ' ' + meta['progress']], True else: return 'Trigger Retraining', False else: raise PreventUpdate else: raise PreventUpdate
def update_graph_bar(interval, simu,n): global simulationName conn = create_connection(r"./database.db") cur = conn.cursor() cur.execute("SELECT simu FROM parameters WHERE step=-1 AND simu='"+simulationName+"'") dff = list(cur.fetchall()) if(len(dff)==0): style = [] else: style = [dbc.Spinner(color="warning", type="grow")] cur.close() conn.close() return go.Figure(build_rewards_graph(simu)), go.Figure(build_total_reward_graph(simu)),style
def notify_re_build_database(n_clicks): if not n_clicks: raise PreventUpdate return dbc.Toast( [ dbc.Spinner(color="info", size="sm", style={"margin-right": "5px"}), "Re-building database", ], id="database-build-noti", header="In progress", is_open=True, icon="info", )
def set_state(*args: tp.Tuple[int]) -> tuple: values, args = args[:3], args[3:] if not all(values): return "Check Parameters", "primary", True, "fa fa-times", None, "primary", True _, _, tab, *states = args trigger = dash.callback_context.triggered[0] if trigger["prop_id"].startswith("select"): return states if trigger["prop_id"].endswith( "n_clicks") and states[0] == "Play" and tab == "gol": return "Pause", "warning", False, None, dbc.Spinner( size="sm"), "warning", False return "Play", "primary", False, "fa fa-play", None, "primary", True
def update_output(list_of_contents, list_of_names, list_of_dates, model): if list_of_contents is not None: analysed_information = [ analyse_image_func(c, n, d, m) for c, n, d, m in zip( list_of_contents, list_of_names, list_of_dates, model) ] return analysed_information else: time.sleep(3), loading_spinner = html.Div([ dbc.Spinner(html.Div(id="loading-output")), ]) return '' # Place holder for the call back
def retrieve_output(n_intervals, fmu_hash): if fmu_hash is None: raise PreventUpdate pickle_file = os.path.join(workdir, fmu_hash + '.p') if os.path.isfile(pickle_file): with open(pickle_file, 'rb') as f: components = pickle.load(f) return components, fmu_hash else: return dbc.Container([dbc.Spinner(color='secondary')], className='mt-5 text-center'), None
def skillsgap_details_tabs(): tabs = html.Div([ dbc.Tabs(id="skillsgap_details_tabs", children=[ dbc.Tab(label="Salary", ), dbc.Tab(label="Similarity", ), dbc.Tab(label="Gaps", ), dbc.Tab(label="Typical Level Of Training") ]), dbc.Spinner(html.Div(id="skillsgap_details_content")) ]) return tabs
def UserSharedSessionsCard(username, current_session_pkid=None): return dbc.Card([ dbc.CardBody([ html.H3('Shared sessions', className="card-text", style={'text-align': "center"}), html.Hr(), html.P('Here you will find a list with all the sessions that other users have shared with you. You only ' 'have read permissions to these sessions, but once you load them you will be able to save a copy ' 'into your personal storage from the Plot tab. You can also decide to stop sharing them at any ' 'moment.', style={'text-align': "center"}), html.Br(), dbc.Spinner(components.SessionList(username, components.SessionListType.SHARED, current_session_pkid), id='shared-sessions-list-spinner') ]) ])
def UserStoredSessionsCard(username, current_session_pkid=None): return dbc.Card([ dbc.CardBody([ html.H3('Stored sessions', className="card-text", style={'text-align': "center"}), html.Hr(), html.P('Here you will find a list of all the sessions you have saved in your personal storage. These ' 'sessions are private and only you and those user you decide to share them with will be able ' 'to access them.', style={'text-align': "center"}), html.Br(), dbc.Spinner(components.SessionList(username, components.SessionListType.STORED, current_session_pkid), id='stored-sessions-list-spinner') ]) ])
def ChangeUserPasswordCard(username): return dbc.Card([ dbc.CardBody([ html.H3("Change %s's password" % username, className="card-text", style={'text-align': "center"}), html.Hr(), html.Br(), components.PasswordInput(id='old-password-input', addon='Old', placeholder='password'), components.PasswordInput(id='new-password-input', addon='New', placeholder='password'), html.Br(), dbc.Spinner(html.Div(id='success-change-password-alert-div')), html.Br(), dbc.Button("Change", color="primary", block=True, id='user-change-password-button'), html.Br(), ]) ])
def button(id, name, clr='primary', disabled=False): stl = {'visibility': 'visible'} if disabled: stl = {'visibility': 'hidden'} return dbc.Button([ dbc.Spinner(spinner_style={'pointer-events': 'none'}, size="sm", children=[html.Div(id=id + '_spinner'), name]) ], color=clr, block=True, id=id, outline=True, className="mr-1", style=stl)
def _return_pie_chart_fig(total_hours_fig): return dbc.Spinner( id='pie-chart-loading', color="primary", fullscreen=True, children=[ html.Div(className='graph-displayer', children=[ dcc.Graph( id='total-hours-pie', figure=total_hours_fig, config={'displayModeBar': False} ) ]) ] )
def body(page=""): return html.Div( [ dcc.Location(id="url", refresh=False), html.Div(id="page-content", className="main-container"), dbc.Modal( [ dbc.ModalBody( [ dbc.Spinner(color="primary", type="grow"), html.P("loading graph..."), ] ) ], id="loading_modal", ), ] )
def UserLoginCard(): return dbc.Card([ dbc.CardBody([ html.H3('User login', className="card-text", style={'text-align': "center", 'color': 'red'}), html.Hr(), html.H5('You must login before accessing the members only area', style={'text-align': "center", 'color': 'red'}), html.Br(), components.UserNameInput(), components.PasswordInput(), components.InvalidLoginCollapse(), html.Br(), dbc.Spinner(html.Div(id='success-login-alert-div')), html.Br(), dbc.Button("Login", color="primary", block=True, id='require-user-login-button'), html.Br(), ]) ])
def CreateUserCard(): return dbc.Card([ dbc.CardBody([ html.Div(id='create-user-modal-div'), html.H3('Create a new user', className="card-text", style={'text-align': "center"}), html.Hr(), html.Br(), components.UserNameInput('create-username-input'), components.PasswordInput('create-password-input'), components.EmailInput('create-email-input'), components.InvalidNewUserCollapse(), html.Br(), components.GdprAgreementCheckbox(), html.Br(), dbc.Button([ dbc.Spinner(html.Div("Create new user", id='create-user-button-div'), size='sm') ], color="primary", block=True, id='create-user-button', disabled=True) ]), ])
def RecoveryPortalCard(): return dbc.Card([ dbc.CardHeader(dbc.Col(html.H1('ConPlot', style={'font-size': '7vh', 'text-align': 'center'}))), dbc.CardBody([ html.H3('Account recovery portal', className="card-text", style={'text-align': "center"}), html.Hr(), html.Br(), dbc.Spinner(html.Div([ components.UserNameInput('recovery-portal-username-input'), components.EmailInput('recovery-portal-email-input', show_tooltip=False), components.VerificationCodeInput(id='recovery-portal-secret-input'), components.PasswordInput(id='recovery-portal-password-1-input', addon='New Password'), components.PasswordInput(id='recovery-portal-password-2-input', addon='Repeat Password'), html.Br(), html.Div(id='recovery-portal-modal-div'), dbc.Button("Recover", color="primary", block=True, id='recover-account-button') ], id='recovery-portal-div')), html.Br(), ]) ])
def _return_minutes_comparison_div(overall_hours_fig): return html.Div([ dbc.Spinner( id='loading-chart-comparison', color="primary", fullscreen=True, children=[ html.Div(children=[ html.Div(className='graph-displayer', children = [ dcc.Graph( id='overall-week-hours', figure=overall_hours_fig, config={'displayModeBar': False, 'staticPlot': True} ) ]) ]) ] ) ])
def render_app_layout(): sidebar = dbc.NavbarSimple( children=[ dbc.Nav( [ dbc.NavLink("Home", href="/page-1", id="page-1-link"), dbc.NavLink("Charts", href="/page-2", id="page-2-link"), dbc.NavLink("Historical Charts", href="/page-3", id="page-3-link"), dbc.NavLink("Transactions", href="/page-4", id="page-4-link"), ], pills=True, fill=True, ), ], brand="Investscape", brand_href="/", color="dark", dark=True, fluid=True, fixed="top", ) content = dbc.Spinner( size="lg", color="dark", fullscreen=True, children=[ html.Div( id="page-content", style=constants.CONTENT_STYLE, className="container-lg bg-light mx-auto \ shadow-lg border-secondary" ) ] ) return html.Div([dcc.Location(id="url"), sidebar, content])