From d3da3055da4205334b2ca59344f009fa7e1209d1 Mon Sep 17 00:00:00 2001 From: Stanislaw Adaszewski Date: Mon, 10 Feb 2020 18:34:08 +0100 Subject: [PATCH] Started implementing proper browse dialog. --- .../wb-browse-dialog-collection-content.js | 0 .../wb-browse-dialog-collection-list.js | 0 .../dialog/wb-browse-dialog-project-list.js | 82 +++++++++++++++++++ frontend/src/js/dialog/wb-browse-dialog.js | 60 ++++++++++++++ .../src/js/page/wb-launch-workflow-page.js | 11 ++- 5 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 frontend/src/js/dialog/wb-browse-dialog-collection-content.js create mode 100644 frontend/src/js/dialog/wb-browse-dialog-collection-list.js create mode 100644 frontend/src/js/dialog/wb-browse-dialog-project-list.js create mode 100644 frontend/src/js/dialog/wb-browse-dialog.js 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 ( +
+ + + this.changePage(i) } /> +
+ ); + } +} + +WBBrowseDialogProjectList.defaultProps = { + 'itemsPerPage': 5 +}; + +export default WBBrowseDialogProjectList; diff --git a/frontend/src/js/dialog/wb-browse-dialog.js b/frontend/src/js/dialog/wb-browse-dialog.js new file mode 100644 index 0000000..647c9ad --- /dev/null +++ b/frontend/src/js/dialog/wb-browse-dialog.js @@ -0,0 +1,60 @@ +import { h, Component } from 'preact'; +import WBBrowseDialogProjectList from 'wb-browse-dialog-project-list'; +import WBBrowseDialogCollectionList from 'wb-browse-dialog-project-list'; + +class WBBrowseDialog extends Component { + render({ app, id }, { mode }) { + return ( + + ); + } +} + +export default WBBrowseDialog; diff --git a/frontend/src/js/page/wb-launch-workflow-page.js b/frontend/src/js/page/wb-launch-workflow-page.js index fdc9713..e71fcc4 100644 --- a/frontend/src/js/page/wb-launch-workflow-page.js +++ b/frontend/src/js/page/wb-launch-workflow-page.js @@ -2,6 +2,7 @@ import { h, Component, createRef } from 'preact'; import WBNavbarCommon from 'wb-navbar-common'; import WBArvadosCrumbs from 'wb-arvados-crumbs'; import WBToolboxDialog from 'wb-toolbox-dialog'; +import WBBrowseDialog from 'wb-browse-dialog'; import makeArvadosRequest from 'make-arvados-request'; import linkState from 'linkstate'; @@ -58,6 +59,7 @@ class WBLaunchWorkflowPage extends Component { this.state.browseDialogId = uuid.v4(); this.state.insertDialogId = uuid.v4(); this.state.insertManyDialogId = uuid.v4(); + this.state.realBrowseDialogId = uuid.v4(); this.inputsTextArea = createRef(); } @@ -82,7 +84,7 @@ class WBLaunchWorkflowPage extends Component { defaultProcessName, defaultProcessDescription, inputsFunctionText, browseDialogId, insertDialogId, insertManyDialogId, - inputsPreview }) { + realBrowseDialogId, inputsPreview }) { return (
@@ -108,6 +110,8 @@ class WBLaunchWorkflowPage extends Component { items={ app.state.toolboxItems } selectMany={ true } onAccepted={ values => alert(values) } /> + + { workflow ? (

Launch Workflow

@@ -171,6 +175,11 @@ class WBLaunchWorkflowPage extends Component { e.preventDefault(); $('#' + insertManyDialogId).modal(); } }>Insert Many + +