IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Browse Source

Initial commit.

master
commit
110b0b4014
5 changed files with 146 additions and 0 deletions
  1. +3
    -0
      .gitignore
  2. +31
    -0
      wbadvanced/__main__.py
  3. +56
    -0
      wbadvanced/collections.py
  4. +50
    -0
      wbadvanced/projects.py
  5. +6
    -0
      wbadvanced/users.py

+ 3
- 0
.gitignore View File

@@ -0,0 +1,3 @@
__pycache__
*.pyc


+ 31
- 0
wbadvanced/__main__.py View File

@@ -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()

+ 56
- 0
wbadvanced/collections.py View File

@@ -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

+ 50
- 0
wbadvanced/projects.py View File

@@ -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

+ 6
- 0
wbadvanced/users.py View File

@@ -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

Loading…
Cancel
Save