| @@ -0,0 +1,3 @@ | |||
| __pycache__ | |||
| *.pyc | |||
| @@ -0,0 +1,31 @@ | |||
| import dash | |||
| import dash_bootstrap_components as dbc | |||
| import dash_html_components as html | |||
| import socket | |||
| import arvados | |||
| import functools | |||
| from .projects import list_projects_html | |||
| from .collections import list_collections_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 ] | |||
| projects_table = list_projects_html(arv, user['uuid']) | |||
| collections_table = list_collections_html(arv, user['uuid']) | |||
| app.layout = html.Div([ | |||
| html.H5('Projects'), | |||
| projects_table, | |||
| html.H5('Collections'), | |||
| collections_table | |||
| ], style={ 'margin': '10px' }) | |||
| app.run_server(host=socket.getfqdn(), debug=True) | |||
| main() | |||
| @@ -0,0 +1,56 @@ | |||
| import dash_html_components as html | |||
| import dash_bootstrap_components as dbc | |||
| import humanize | |||
| from .users import get_user | |||
| def list_collections(arv, owner_uuid): | |||
| res = arv.collections().list(where = { | |||
| 'owner_uuid': owner_uuid | |||
| }).execute() | |||
| res = res['items'] | |||
| #while res['items_available'] > len(res['items']): | |||
| #res = arv.collections().list(where = {}) | |||
| return res | |||
| def list_collections_html(arv, parent): | |||
| projects = list_collections(arv, parent) | |||
| header = html.Tr([ | |||
| html.Th('Name'), | |||
| html.Th('Description'), | |||
| html.Th('Owner'), | |||
| html.Th('Size') | |||
| ]) | |||
| header = [ html.Thead(header) ] | |||
| rows = [] | |||
| for a in projects: | |||
| owner = get_user(arv, a['owner_uuid']) | |||
| rows.append( | |||
| html.Tr([ | |||
| html.Td([ | |||
| html.Div(html.A(href='/projects/' + a['uuid'], | |||
| children=a['name'])), | |||
| html.Div(a['uuid']) | |||
| ]), | |||
| html.Td(a['description'] or 'Modified at ' + a['modified_at']), | |||
| html.Td([ | |||
| html.Div(html.A(href='mailto:' + owner['email'], | |||
| children=owner['first_name'] + ' ' + owner['last_name'])), | |||
| html.Div(a['owner_uuid']) | |||
| ]), | |||
| html.Td(humanize.naturalsize(a['file_size_total'])) | |||
| ])) | |||
| rows = [ html.Tbody(rows) ] | |||
| res = dbc.Table(header + rows, | |||
| striped=True, | |||
| hover=True, | |||
| responsive=True) | |||
| return res | |||
| @@ -0,0 +1,50 @@ | |||
| import dash_bootstrap_components as dbc | |||
| import dash_html_components as html | |||
| from .users import get_user | |||
| def list_projects(arv, parent): | |||
| res = arv.groups().list(where={ | |||
| 'owner_uuid': parent, | |||
| 'group_class': 'project' | |||
| }).execute()['items'] | |||
| return res | |||
| def list_projects_html(arv, parent): | |||
| projects = list_projects(arv, parent) | |||
| header = html.Tr([ | |||
| html.Th('Name'), | |||
| html.Th('Description'), | |||
| html.Th('Owner') | |||
| ]) | |||
| header = [ html.Thead(header) ] | |||
| rows = [] | |||
| for a in projects: | |||
| owner = get_user(arv, a['owner_uuid']) | |||
| rows.append( | |||
| html.Tr([ | |||
| html.Td([ | |||
| html.Div(html.A(href='/projects/' + a['uuid'], | |||
| children=a['name'])), | |||
| html.Div(a['uuid']) | |||
| ]), | |||
| html.Td(a['description'] or 'Project'), | |||
| html.Td([ | |||
| html.Div(html.A(href='mailto:' + owner['email'], | |||
| children=owner['first_name'] + ' ' + owner['last_name'])), | |||
| html.Div(a['owner_uuid']) | |||
| ]) | |||
| ])) | |||
| rows = [ html.Tbody(rows) ] | |||
| res = dbc.Table(header + rows, | |||
| striped=True, | |||
| hover=True, | |||
| responsive=True) | |||
| return res | |||
| @@ -0,0 +1,6 @@ | |||
| import functools | |||
| @functools.lru_cache(maxsize=128) | |||
| def get_user(arv, uuid): | |||
| res = arv.users().get(uuid=uuid).execute() | |||
| return res | |||