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