diff --git a/frontend/src/js/dialog/wb-browse-dialog-collection-content.js b/frontend/src/js/dialog/wb-browse-dialog-collection-content.js new file mode 100644 index 0000000..e69de29 diff --git a/frontend/src/js/dialog/wb-browse-dialog-collection-list.js b/frontend/src/js/dialog/wb-browse-dialog-collection-list.js new file mode 100644 index 0000000..e69de29 diff --git a/frontend/src/js/dialog/wb-browse-dialog-project-list.js b/frontend/src/js/dialog/wb-browse-dialog-project-list.js new file mode 100644 index 0000000..ff84e28 --- /dev/null +++ b/frontend/src/js/dialog/wb-browse-dialog-project-list.js @@ -0,0 +1,82 @@ +import { h, Component } from 'preact'; +import makeArvadosRequest from 'make-arvados-request'; +import WBPagination from 'wb-pagination'; +import WBTable from 'wb-table'; + +class WBBrowseDialogProjectList extends Component { + constructor(...args) { + super(...args); + this.state.rows = []; + } + + componentDidMount() { + this.fetchRows(); + } + + componentWillReceiveProps(nextProps) { + this.props = nextProps; + this.setState({ + 'page': 0 + }); + this.fetchRows(); + } + + changePage(page) { + this.setState({ + 'page': page + }); + this.fetchRows(); + } + + prepareRows(items) { + return items.map(it => [ + it.name, + it.file_count, + it.file_size_total + ]); + } + + fetchRows() { + const { arvHost, arvToken } = this.props.app.state; + const { textSearch, itemsPerPage } = this.props; + const ownerUuid = ('ownerUuid' in this.state ? + this.state.ownerUuid : this.props.ownerUuid); + const { page } = this.state; + const filters = [ + ['group_class', '=', 'project'] + ]; + if (ownerUuid) + filters.push(['owner_uuid', '=', ownerUuid]); + if (textSearch) + filters.push(['name', 'ilike', '%' + textSearch + '%']); + let prom = makeArvadosRequest(arvHost, arvToken, + '/arvados/v1/groups?filters=' + + encodeURIComponent(JSON.stringify(filters)) + + '&limit=' + itemsPerPage + + '&offset=' + (page * itemsPerPage)); + prom = prom.then(xhr => { + this.setState({ + 'rows': this.prepareRows(xhr.response.items), + 'numPages': xhr.response.items_available / itemsPerPage + }); + }); + } + + render({ app }, { ownerUuid, textSearch, page, numPages, rows }) { + return ( +