import dash import dash_bootstrap_components as dbc import dash_html_components as html import dash_core_components as dcc import socket import arvados import functools from .projects import list_projects_html from .collections import list_collections_html from .processes import list_processes_html # list_projects_html = functools.lru_cache(maxsize=128)(list_projects_html) # list_collections_html = functools.lru_cache(maxsize=128)(list_collections_html) # list_processes_html = functools.lru_cache(maxsize=128)(list_processes_html) def main(): app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP]) arv = arvados.api('v1') user = arv.users().current().execute() # nav_btns = [ dbc.Button(a['name']) for a in projects ] app.layout = html.Div([ dcc.Location(id='url', refresh=False), html.Div(id='page-content') ], style={ 'margin': '10px' }) projects_table = list_projects_html(arv, user['uuid']) collections_table = list_collections_html(arv, user['uuid']) processes_table = list_processes_html(arv, user['uuid']) @app.callback(dash.dependencies.Output('page-content', 'children'), [ dash.dependencies.Input('url', 'pathname') ]) def display_page(pathname): print('display_page(), pathname:', pathname) return html.Div([ dbc.Tabs([ dbc.Tab(projects_table, label="Projects", label_style={ 'cursor': 'pointer' }) ], style={ 'borderBottom': 'none' }), dbc.Tabs([ dbc.Tab(collections_table, label="Collections", label_style={ 'cursor': 'pointer' }), dbc.Tab(processes_table, label="Processes", label_style={ 'cursor': 'pointer' }) ], style={ 'borderBottom': 'none' }) ]) app.run_server(host=socket.getfqdn(), debug=False) main()