products/distill/Dashboard/app.py (65 lines of code) (raw):

# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import dash import dash_bootstrap_components as dbc import dash_labs as dl from dash import Input, Output, State, html app = dash.Dash( __name__, plugins=[dl.plugins.pages], suppress_callback_exceptions=True, external_stylesheets=[dbc.themes.BOOTSTRAP], ) navbar = dbc.NavbarSimple( children=[ dbc.NavItem(dbc.NavLink("Page 1", href="#")), dbc.DropdownMenu( children=[ dbc.DropdownMenuItem("More pages", header=True), dbc.DropdownMenuItem("Upload", href="/upload"), dbc.DropdownMenuItem("Page 3", href="#"), ], nav=True, in_navbar=True, label="More", ), ], brand="NavbarSimple", brand_href="#", color="primary", dark=True, ) offcanvas = html.Div( [ dbc.Button("Menu", color="light", id="open-offcanvas", n_clicks=0), dbc.Offcanvas( dbc.ListGroup( [ # dbc.ListGroupItem(dcc.Link('Home',href ="/Home")), dbc.ListGroupItem(page["name"], href=page["path"]) for page in dash.page_registry.values() if page["module"] != "pages.not_found_404" ] ), id="offcanvas", is_open=False, ), ], className="my-3", ) app.layout = html.Div( [ # navbar, dbc.Container( [offcanvas, dl.plugins.page_container], fluid=True, ) ] ) @app.callback( Output("offcanvas", "is_open"), Input("open-offcanvas", "n_clicks"), [State("offcanvas", "is_open")], ) def toggle_offcanvas(n1, is_open): if n1: return not is_open return is_open if __name__ == "__main__": app.run_server(debug=True, port=5000)